summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2009-09-22 21:40:03 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2009-09-22 21:40:03 +0000
commit516ffc77ed11b859ee38796488a8b3bb726d11a8 (patch)
treeddde9798c3ead9b5dcaf0039d13a618bc2c79d50
parent1913787ec112f00d5af912a4028963368bb87363 (diff)
Use __builtin_offsetof for offsetof definition on gcc >= 4
This is required as gcc grows ever more pedantic with old age and cavorts with standards bodies that like to create paradoxes. ok kettenis@ miod@ millert@ espie@
-rw-r--r--include/stddef.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/stddef.h b/include/stddef.h
index a2ec869e267..9eb1875eb04 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stddef.h,v 1.9 2006/01/06 18:53:04 millert Exp $ */
+/* $OpenBSD: stddef.h,v 1.10 2009/09/22 21:40:02 jsg Exp $ */
/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */
/*-
@@ -72,6 +72,10 @@ typedef __mbstate_t mbstate_t;
#endif
#endif
+#if __GNUC_PREREQ__(4, 0)
+#define offsetof(type, member) __builtin_offsetof(type, member)
+#else
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
+#endif
#endif /* _STDDEF_H_ */