diff options
| author | Faraz Vahedi <kfv@kfv.io> | 2026-05-01 14:34:44 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2026-06-20 00:23:28 +0000 |
| commit | 28cecfe27964fdb67497800f5dcd5d3e1033727f (patch) | |
| tree | 4d3a47ec769055463fdad8c0f98e5cf5275dde24 | |
| parent | 85becdacf3b043849b240eb1b1b2cde63add0690 (diff) | |
libc: Restrict ATOMIC_VAR_INIT for C23 conformance
Omit `ATOMIC_VAR_INIT` when targeting C23, where it has been removed.
Retain it for earlier C standards and for C++ (as it still remains in
C++23, albeit marked as deprecated since C17 and C++20.)
Also separate `atomic_init` definitions from `ATOMIC_VAR_INIT` to
avoid coupling with a deprecated initialisation mechanism.
No functional change intended for `atomic_init`; this is purely a
conformance and cleanup adjustment.
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
| -rw-r--r-- | sys/sys/stdatomic.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index c3f9b217519c..2d565ce991be 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -86,11 +86,17 @@ * 7.17.2 Initialization. */ +#if __ISO_C_VISIBLE < 2023 || defined(__cplusplus) #if defined(__CLANG_ATOMICS) #define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __c11_atomic_init(obj, value) #else #define ATOMIC_VAR_INIT(value) { .__val = (value) } +#endif +#endif + +#if defined(__CLANG_ATOMICS) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#else #define atomic_init(obj, value) ((void)((obj)->__val = (value))) #endif |
