diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2006-04-08 14:15:04 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2006-04-08 14:15:04 +0000 |
commit | d0ebe33a4a3b847df1a5ac270e098d287ec9fa21 (patch) | |
tree | a496e997b9874fba29003465110210d2f7a39b67 /src/lisp.h | |
parent | 1d79e5217cd7996967fef3896357600b6fa7a5bf (diff) | |
download | emacs-d0ebe33a4a3b847df1a5ac270e098d287ec9fa21.tar.gz |
(OFFSETOF, PSEUDOVECSIZE): New macros.
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 2eaa0987057..56b5645b9dc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -702,6 +702,13 @@ struct Lisp_String unsigned char *data; }; +#ifdef offsetof +#define OFFSETOF(type,field) offsetof(type,field) +#else +#define OFFSETOF(type,field) \ + ((int)((char*)&((type*)0)->field - (char*)0)) +#endif + /* If a struct is made to look like a vector, this macro returns the length of the shortest vector that would hold that struct. */ #define VECSIZE(type) ((sizeof (type) - (sizeof (struct Lisp_Vector) \ @@ -709,6 +716,13 @@ struct Lisp_String + sizeof(Lisp_Object) - 1) /* round up */ \ / sizeof (Lisp_Object)) +/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields + at the end and we need to compute the number of Lisp_Object fields (the + ones that the GC needs to trace). */ +#define PSEUDOVECSIZE(type, nonlispfield) \ + ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \ + / sizeof (Lisp_Object)) + struct Lisp_Vector { EMACS_INT size; |