diff options
author | Michael Brown <mcb30@ipxe.org> | 2010-11-28 17:26:27 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-11-28 17:28:52 +0000 |
commit | 795793b3a4751936db4dc331aeb5f5549cfb3987 (patch) | |
tree | 9577642ef8bcc565c3e0f66847007dfad31de68a /src/include/stddef.h | |
parent | aa1c59ccfffb1bd0f859cb9b91a4026a7c648b0a (diff) | |
download | ipxe-795793b3a4751936db4dc331aeb5f5549cfb3987.tar.gz |
[build] Use __builtin_offsetof() when available
Some newer versions of gcc (observed with a patched gcc 4.5.1) seem to
treat our offsetof() implementation as not being a compile-time
constant. Fix by using __builtin_offsetof() when available. (As with
the original offsetof() macro, this code is copied from the Linux
kernel's stddef.h.)
Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/stddef.h')
-rw-r--r-- | src/include/stddef.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/stddef.h b/src/include/stddef.h index 2a02a8985..8e69545c2 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -10,7 +10,11 @@ FILE_LICENCE ( GPL2_ONLY ); #define NULL ((void *)0) #undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif #undef container_of #define container_of(ptr, type, member) ({ \ |