summaryrefslogtreecommitdiffstats
path: root/sys/sys/cdefs.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2014-09-03 09:35:38 +0000
committered <ed@FreeBSD.org>2014-09-03 09:35:38 +0000
commitdffba5b7eb5d7c0142bcdd24b417ed4d86754fde (patch)
tree129180b85ca5a890a049968a537a008b2d555cf1 /sys/sys/cdefs.h
parentf6ccc75aa84df055b49d14ac631bd080921d765e (diff)
downloadFreeBSD-src-dffba5b7eb5d7c0142bcdd24b417ed4d86754fde.zip
FreeBSD-src-dffba5b7eb5d7c0142bcdd24b417ed4d86754fde.tar.gz
Leave the C11 keywords alone when we have a recent version of GCC.
As GCC also gained support for the C11 keywords over time, we can patch up <sys/cdefs.h> to not define these anymore. This has the advantage that error messages for static assertions are printed natively and that _Alignas() will work with even a type outside of C11 mode. All C11 keywords are supported with GCC 4.7 and higher, with the exception of _Thread_local and _Generic. These are only supported as of GCC 4.9.
Diffstat (limited to 'sys/sys/cdefs.h')
-rw-r--r--sys/sys/cdefs.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 7af7e38..3d1aba4 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -254,7 +254,7 @@
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
-#if !__has_extension(c_alignas)
+#if !__has_extension(c_alignas) && !__GNUC_PREREQ__(4, 7)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
__has_extension(cxx_alignas)
#define _Alignas(x) alignas(x)
@@ -264,11 +264,13 @@
#endif
#endif
+#if !__GNUC_PREREQ__(4, 7)
#if defined(__cplusplus) && __cplusplus >= 201103L
#define _Alignof(x) alignof(x)
#else
#define _Alignof(x) __alignof(x)
#endif
+#endif
#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
/*
@@ -278,13 +280,15 @@
#define _Atomic(T) struct { T volatile __val; }
#endif
+#if !__GNUC_PREREQ__(4, 7)
#if defined(__cplusplus) && __cplusplus >= 201103L
#define _Noreturn [[noreturn]]
#else
#define _Noreturn __dead2
#endif
+#endif
-#if !__has_extension(c_static_assert)
+#if !__has_extension(c_static_assert) && !__GNUC_PREREQ__(4, 7)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
__has_extension(cxx_static_assert)
#define _Static_assert(x, y) static_assert(x, y)
@@ -297,7 +301,7 @@
#endif
#endif
-#if !__has_extension(c_thread_local)
+#if !__has_extension(c_thread_local) && !__GNUC_PREREQ__(4, 9)
/*
* XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
* without actually supporting the thread_local keyword. Don't check for
@@ -322,7 +326,8 @@
* distinguish multiple cases.
*/
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
+ __has_extension(c_generic_selections) || __GNUC_PREREQ__(4, 9)
#define __generic(expr, t, yes, no) \
_Generic(expr, t: yes, default: no)
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
OpenPOWER on IntegriCloud