Mercurial > emacs
comparison src/lisp.h @ 69869:89bc86c44d7c
(OFFSETOF, PSEUDOVECSIZE): New macros.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 08 Apr 2006 14:15:04 +0000 |
parents | c65249b41906 |
children | 8a7ecbca8672 |
comparison
equal
deleted
inserted
replaced
69868:5ae8bd3108d4 | 69869:89bc86c44d7c |
---|---|
700 EMACS_INT size_byte; | 700 EMACS_INT size_byte; |
701 INTERVAL intervals; /* text properties in this string */ | 701 INTERVAL intervals; /* text properties in this 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) \ |
708 - sizeof (Lisp_Object)) \ | 715 - sizeof (Lisp_Object)) \ |
709 + sizeof(Lisp_Object) - 1) /* round up */ \ | 716 + sizeof(Lisp_Object) - 1) /* round up */ \ |
710 / sizeof (Lisp_Object)) | 717 / sizeof (Lisp_Object)) |
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)) | |
711 | 725 |
712 struct Lisp_Vector | 726 struct Lisp_Vector |
713 { | 727 { |
714 EMACS_INT size; | 728 EMACS_INT size; |
715 struct Lisp_Vector *next; | 729 struct Lisp_Vector *next; |