summaryrefslogtreecommitdiffstats
path: root/sys/sys/cdefs.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2013-06-16 10:48:47 +0000
committered <ed@FreeBSD.org>2013-06-16 10:48:47 +0000
commit6ee0e40b486d34550e3a4704231af7ec666772f2 (patch)
tree435b9cdef7cccaa63649aae1a10805c5773635bd /sys/sys/cdefs.h
parent99f22b551f1de22d4f5967a2fc5307f25cc930dd (diff)
downloadFreeBSD-src-6ee0e40b486d34550e3a4704231af7ec666772f2.zip
FreeBSD-src-6ee0e40b486d34550e3a4704231af7ec666772f2.tar.gz
Move _Atomic() into <sys/cdefs.h>.
That way _Atomic() is defined next to all the other C11 keywords for which we provide compatibility for pre-C11 compilers. While there, fix the definition to place "volatile" at the end. Otherwise pointer types will become "volatile T *" instead of "T * volatile".
Diffstat (limited to 'sys/sys/cdefs.h')
-rw-r--r--sys/sys/cdefs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index e6a4319..81acb6b 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -268,6 +268,14 @@
#define _Alignof(x) __alignof(x)
#endif
+#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
+/*
+ * No native support for _Atomic(). Place object in structure to prevent
+ * most forms of direct non-atomic access.
+ */
+#define _Atomic(T) struct { T volatile __val; }
+#endif
+
#if defined(__cplusplus) && __cplusplus >= 201103L
#define _Noreturn [[noreturn]]
#else
OpenPOWER on IntegriCloud