From: Ben Gras Date: Wed, 25 Aug 2010 07:25:32 +0000 (+0000) Subject: - alternative definition of offsetof for gcc using builtin X-Git-Tag: v3.1.8~50 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch11.html?a=commitdiff_plain;h=1d0e0e217d2f5e46875b7ff7033bab1839cf231d;p=minix.git - alternative definition of offsetof for gcc using builtin --- diff --git a/include/stddef.h b/include/stddef.h index bfd6e2cee..a053c9eb5 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -6,7 +6,11 @@ #include /* 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 */