From cdfc5862954b460594f5653c0b52999b71c04f53 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sun, 16 Jun 2013 10:48:47 +0000 Subject: [PATCH] Move _Atomic() into . 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". --- sys/sys/cdefs.h | 8 ++++++++ sys/sys/stdatomic.h | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index e6a43194c806..81acb6b243b9 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 diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index 9aceb792046e..8d7a20b6f1d4 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -43,10 +43,6 @@ #error "stdatomic.h does not support your compiler" #endif -#if !defined(__CLANG_ATOMICS) -#define _Atomic(T) struct { volatile T __val; } -#endif - /* * 7.17.1 Atomic lock-free macros. */