]> Zhao Yanbai Git Server - minix.git/commitdiff
<stddef.h> - alternative definition of offsetof for gcc using builtin
authorBen Gras <ben@minix3.org>
Wed, 25 Aug 2010 07:25:32 +0000 (07:25 +0000)
committerBen Gras <ben@minix3.org>
Wed, 25 Aug 2010 07:25:32 +0000 (07:25 +0000)
include/stddef.h

index bfd6e2cee96657ddd5c9a57874364fa29988687a..a053c9eb50e81e3022ad15cf0390b5d02e760b5e 100644 (file)
@@ -6,7 +6,11 @@
 #include <sys/null.h>
 
 /* The following is not portable, but the compiler accepts it. */
+#ifdef __GNUC__
+#define offsetof(type, ident)  __builtin_offsetof (type, ident)
+#else
 #define offsetof(type, ident)  ((size_t) (unsigned long) &((type *)0)->ident)
+#endif
 
 #if _EM_PSIZE == _EM_WSIZE
 typedef int ptrdiff_t;         /* result of subtracting two pointers */