summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcoppa <dcoppa@openbsd.org>2014-10-22 06:55:10 +0000
committerdcoppa <dcoppa@openbsd.org>2014-10-22 06:55:10 +0000
commitdc7aaac559d52d7b2543477fa97f1cf7b3ce462d (patch)
treea65f5a1345a782b2f9140c417b34d3cf299d563c
parentRemove some unused/unneeded code. (diff)
downloadwireguard-openbsd-dc7aaac559d52d7b2543477fa97f1cf7b3ce462d.tar.xz
wireguard-openbsd-dc7aaac559d52d7b2543477fa97f1cf7b3ce462d.zip
Sync offsetof() definition with what we have in <stddef.h> for
userland. Fix a warning from gcc-4.9: ../../../../ufs/ufs/dir.h:113:33: warning: variably modified 'dh_firstfree' at file scope ok kettenis@
-rw-r--r--sys/sys/param.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 27de803333e..b6ef3a890e9 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.107 2014/07/15 21:59:17 deraadt Exp $ */
+/* $OpenBSD: param.h,v 1.108 2014/10/22 06:55:10 dcoppa Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -218,8 +218,12 @@
/* Macros for calculating the offset of a field */
#if !defined(offsetof) && defined(_KERNEL)
+#if __GNUC_PREREQ__(4, 0)
+#define offsetof(s, e) __builtin_offsetof(s, e)
+#else
#define offsetof(s, e) ((size_t)&((s *)0)->e)
#endif
+#endif /* !defined(offsetof) && defined(_KERNEL) */
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))