diff src/lisp.h @ 109320:a0d2db31314d

Use offsetof instead of own definition * lisp.h: Include <stddef.h>. (OFFSETOF): Don't define. (VECSIZE): Use offsetof instead of OFFSETOF. (PSEUDOVECSIZE): Likewise. * process.c (conv_sockaddr_to_lisp): Likewise. * alloc.c: Don't include <stddef.h>. * buffer.h (PER_BUFFER_VAR_OFFSET): Use offsetof.
author Andreas Schwab <schwab@linux-m68k.org>
date Sun, 11 Jul 2010 20:34:43 +0200
parents e856a274549b
children 3e07e13fe30a
line wrap: on
line diff
--- a/src/lisp.h	Sun Jul 11 20:19:16 2010 +0200
+++ b/src/lisp.h	Sun Jul 11 20:34:43 2010 +0200
@@ -22,6 +22,7 @@
 #define EMACS_LISP_H
 
 #include <stdarg.h>
+#include <stddef.h>
 
 /* Use the configure flag --enable-checking[=LIST] to enable various
    types of run time checks for Lisp objects.  */
@@ -784,13 +785,6 @@
     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
-
 struct Lisp_Vector
   {
     EMACS_UINT size;
@@ -801,7 +795,7 @@
 /* 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)					  \
-			- OFFSETOF (struct Lisp_Vector, contents[0])      \
+			- offsetof (struct Lisp_Vector, contents[0])      \
                         + sizeof(Lisp_Object) - 1) /* round up */	  \
 		       / sizeof (Lisp_Object))
 
@@ -809,7 +803,7 @@
    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])) \
+  ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \
    / sizeof (Lisp_Object))
 
 /* A char-table is a kind of vectorlike, with contents are like a