diff options
author | ed <ed@FreeBSD.org> | 2013-06-16 10:48:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2013-06-16 10:48:47 +0000 |
commit | 6ee0e40b486d34550e3a4704231af7ec666772f2 (patch) | |
tree | 435b9cdef7cccaa63649aae1a10805c5773635bd /sys/sys/cdefs.h | |
parent | 99f22b551f1de22d4f5967a2fc5307f25cc930dd (diff) | |
download | FreeBSD-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.h | 8 |
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 |