Skip to content

Commit 49ac664

Browse files
authored
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 phpGH-8764, or one can avoid using C11 atomics altogether, instead using C17 atomics if available, which is what this change does. Fixes phpGH-8881
1 parent 7f6e98c commit 49ac664

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Zend/zend_atomic.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || (__GNUC__ > (x)))
2424

2525
/* Builtins are used to avoid library linkage */
26-
#if __has_feature(c_atomic)
27-
#define HAVE_C11_ATOMICS 1
26+
#if __has_feature(c_atomic) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L
27+
#define HAVE_C17_ATOMICS 1
2828
#elif ZEND_GCC_PREREQ(4, 7)
2929
#define HAVE_GNUC_ATOMICS 1
3030
#elif defined(__GNUC__)
@@ -43,7 +43,7 @@
4343
typedef struct zend_atomic_bool_s {
4444
volatile char value;
4545
} zend_atomic_bool;
46-
#elif defined(HAVE_C11_ATOMICS)
46+
#elif defined(HAVE_C17_ATOMICS)
4747
typedef struct zend_atomic_bool_s {
4848
_Atomic(bool) value;
4949
} zend_atomic_bool;
@@ -80,7 +80,7 @@ static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj,
8080
(void)InterlockedExchange8(&obj->value, desired);
8181
}
8282

83-
#elif defined(HAVE_C11_ATOMICS)
83+
#elif defined(HAVE_C17_ATOMICS)
8484

8585
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) __c11_atomic_init(&(obj)->value, (desired))
8686

0 commit comments

Comments
 (0)