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. */