From 1d12c28e8406031751d235d6bf10ec9c4415dd96 Mon Sep 17 00:00:00 2001 From: jsg <> Date: Tue, 22 Sep 2009 21:40:02 +0000 Subject: [PATCH] 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@ --- src/include/stddef.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/include/stddef.h b/src/include/stddef.h index a2ec869e..9eb1875e 100644 --- a/src/include/stddef.h +++ b/src/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_ */