aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2006-04-08 14:15:04 +0000
committerStefan Monnier2006-04-08 14:15:04 +0000
commitd0ebe33a4a3b847df1a5ac270e098d287ec9fa21 (patch)
treea496e997b9874fba29003465110210d2f7a39b67 /src
parent1d79e5217cd7996967fef3896357600b6fa7a5bf (diff)
downloademacs-d0ebe33a4a3b847df1a5ac270e098d287ec9fa21.tar.gz
emacs-d0ebe33a4a3b847df1a5ac270e098d287ec9fa21.zip
(OFFSETOF, PSEUDOVECSIZE): New macros.
Diffstat (limited to 'src')
-rw-r--r--src/lisp.h14
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
702 unsigned char *data; 702 unsigned char *data;
703 }; 703 };
704 704
705#ifdef offsetof
706#define OFFSETOF(type,field) offsetof(type,field)
707#else
708#define OFFSETOF(type,field) \
709 ((int)((char*)&((type*)0)->field - (char*)0))
710#endif
711
705/* If a struct is made to look like a vector, this macro returns the length 712/* If a struct is made to look like a vector, this macro returns the length
706 of the shortest vector that would hold that struct. */ 713 of the shortest vector that would hold that struct. */
707#define VECSIZE(type) ((sizeof (type) - (sizeof (struct Lisp_Vector) \ 714#define VECSIZE(type) ((sizeof (type) - (sizeof (struct Lisp_Vector) \
@@ -709,6 +716,13 @@ struct Lisp_String
709 + sizeof(Lisp_Object) - 1) /* round up */ \ 716 + sizeof(Lisp_Object) - 1) /* round up */ \
710 / sizeof (Lisp_Object)) 717 / sizeof (Lisp_Object))
711 718
719/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
720 at the end and we need to compute the number of Lisp_Object fields (the
721 ones that the GC needs to trace). */
722#define PSEUDOVECSIZE(type, nonlispfield) \
723 ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \
724 / sizeof (Lisp_Object))
725
712struct Lisp_Vector 726struct Lisp_Vector
713 { 727 {
714 EMACS_INT size; 728 EMACS_INT size;