From 49ac664d85574ee34a98d4cdde1e7b5f0f553709 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Thu, 10 Aug 2023 02:22:02 -0500 Subject: [PATCH] Don't try to use C11 atomics, which are not const C11 did not have the const qualifier on atomic_load; C17 does. One can either use C11 atomics by casting away the constness, which was proposed and rejected in GH-8764, or one can avoid using C11 atomics altogether, instead using C17 atomics if available, which is what this change does. Fixes GH-8881 --- Zend/zend_atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Zend/zend_atomic.h b/Zend/zend_atomic.h index 617cde0ec5640..ee3b34f6f85be 100644 --- a/Zend/zend_atomic.h +++ b/Zend/zend_atomic.h @@ -23,8 +23,8 @@ ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || (__GNUC__ > (x))) /* Builtins are used to avoid library linkage */ -#if __has_feature(c_atomic) -#define HAVE_C11_ATOMICS 1 +#if __has_feature(c_atomic) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L +#define HAVE_C17_ATOMICS 1 #elif ZEND_GCC_PREREQ(4, 7) #define HAVE_GNUC_ATOMICS 1 #elif defined(__GNUC__) @@ -43,7 +43,7 @@ typedef struct zend_atomic_bool_s { volatile char value; } zend_atomic_bool; -#elif defined(HAVE_C11_ATOMICS) +#elif defined(HAVE_C17_ATOMICS) typedef struct zend_atomic_bool_s { _Atomic(bool) value; } zend_atomic_bool; @@ -80,7 +80,7 @@ static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, (void)InterlockedExchange8(&obj->value, desired); } -#elif defined(HAVE_C11_ATOMICS) +#elif defined(HAVE_C17_ATOMICS) #define ZEND_ATOMIC_BOOL_INIT(obj, desired) __c11_atomic_init(&(obj)->value, (desired))