summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2005-12-14 18:28:40 +0000
committermillert <millert@openbsd.org>2005-12-14 18:28:40 +0000
commita6e0e30991400dcfb7e143a0568cd4534ddd5e66 (patch)
treeb4ddc0c1a4cc4a810ba44b5558a4bc6d48cc5b88
parentsync (diff)
downloadwireguard-openbsd-a6e0e30991400dcfb7e143a0568cd4534ddd5e66.tar.xz
wireguard-openbsd-a6e0e30991400dcfb7e143a0568cd4534ddd5e66.zip
Add a __statement macro to use with gcc statement expressions instead
of using __extension__ directly. This lets us define away the whole thing when lint is in use.
-rw-r--r--sys/arch/sparc/include/stdarg.h10
-rw-r--r--sys/sys/cdefs.h10
-rw-r--r--sys/sys/endian.h14
3 files changed, 19 insertions, 15 deletions
diff --git a/sys/arch/sparc/include/stdarg.h b/sys/arch/sparc/include/stdarg.h
index 62e0aa3ccf6..69777779726 100644
--- a/sys/arch/sparc/include/stdarg.h
+++ b/sys/arch/sparc/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdarg.h,v 1.6 2003/06/02 23:27:54 millert Exp $ */
+/* $OpenBSD: stdarg.h,v 1.7 2005/12/14 18:28:40 millert Exp $ */
/* $NetBSD: stdarg.h,v 1.10 1996/12/27 20:55:28 pk Exp $ */
/*
@@ -44,10 +44,10 @@
#ifndef _SPARC_STDARG_H_
#define _SPARC_STDARG_H_
+#include <sys/cdefs.h>
#include <machine/ansi.h>
#ifdef __lint__
-#define __extension__(x) (0)
#define __builtin_classify_type(t) (0)
#endif
@@ -79,12 +79,8 @@ typedef _BSD_VA_LIST_ va_list;
* Note: We don't declare __d with type `type', since in C++ the type might
* have a constructor.
*/
-#if __GNUC__ == 1
-#define __extension__
-#endif
-
#define __va_8byte(ap, type) \
- __extension__ ({ \
+ __statement({ \
union { char __d[sizeof(type)]; int __i[2]; } __va_u; \
__va_u.__i[0] = ((int *)(void *)(ap))[0]; \
__va_u.__i[1] = ((int *)(void *)(ap))[1]; \
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index dea4191c93c..91471887b96 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cdefs.h,v 1.20 2005/11/19 19:05:02 millert Exp $ */
+/* $OpenBSD: cdefs.h,v 1.21 2005/12/14 18:28:40 millert Exp $ */
/* $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ */
/*
@@ -179,6 +179,14 @@
#define __extension__
#endif
+#if __GNUC_PREREQ__(2, 8)
+#define __statement(x) __extension__(x)
+#elif defined(lint)
+#define __statement(x) (0)
+#else
+#define __statement(x) (x)
+#endif
+
/*
* "The nice thing about standards is that there are so many to choose from."
* There are a number of "feature test macros" specified by (different)
diff --git a/sys/sys/endian.h b/sys/sys/endian.h
index b6fa3a4f9d9..5b3efae7554 100644
--- a/sys/sys/endian.h
+++ b/sys/sys/endian.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: endian.h,v 1.15 2005/12/13 00:35:23 millert Exp $ */
+/* $OpenBSD: endian.h,v 1.16 2005/12/14 18:28:40 millert Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -51,14 +51,14 @@
#ifdef __GNUC__
-#define __swap16gen(x) __extension__({ \
+#define __swap16gen(x) __statement({ \
u_int16_t __swap16gen_x = (x); \
\
(u_int16_t)((__swap16gen_x & 0xff) << 8 | \
(__swap16gen_x & 0xff00) >> 8); \
})
-#define __swap32gen(x) __extension__({ \
+#define __swap32gen(x) __statement({ \
u_int32_t __swap32gen_x = (x); \
\
(u_int32_t)((__swap32gen_x & 0xff) << 24 | \
@@ -67,7 +67,7 @@
(__swap32gen_x & 0xff000000) >> 24); \
})
-#define __swap64gen(x) __extension__({ \
+#define __swap64gen(x) __statement({ \
u_int64_t __swap64gen_x = (x); \
\
(u_int64_t)((__swap64gen_x & 0xff) << 56 | \
@@ -112,21 +112,21 @@
#ifdef MD_SWAP
#if __GNUC__
-#define __swap16(x) __extension__({ \
+#define __swap16(x) __statement({ \
u_int16_t __swap16_x = (x); \
\
__builtin_constant_p(x) ? __swap16gen(__swap16_x) : \
__swap16md(__swap16_x); \
})
-#define __swap32(x) __extension__({ \
+#define __swap32(x) __statement({ \
u_int32_t __swap32_x = (x); \
\
__builtin_constant_p(x) ? __swap32gen(__swap32_x) : \
__swap32md(__swap32_x); \
})
-#define __swap64(x) __extension__({ \
+#define __swap64(x) __statement({ \
u_int64_t __swap64_x = (x); \
\
__builtin_constant_p(x) ? __swap64gen(__swap64_x) : \