Skip to content

Commit 50ad458

Browse files
authored
Prefer C11 atomics over ZEND_WIN32 locking mechanism (#21620)
1 parent ea9f5da commit 50ad458

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Zend/zend_atomic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ZEND_API void zend_atomic_int_store(zend_atomic_int *obj, int desired) {
5757
zend_atomic_int_store_ex(obj, desired);
5858
}
5959

60-
#if defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)
60+
#if (defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)) && !defined(HAVE_C11_ATOMICS)
6161
/* On these platforms it is non-const due to underlying APIs. */
6262
ZEND_API bool zend_atomic_bool_load(zend_atomic_bool *obj) {
6363
return zend_atomic_bool_load_ex(obj);

Zend/zend_atomic.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* and alignment purposes.
4040
*/
4141

42-
#if defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)
42+
#if (defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)) && !defined(HAVE_C11_ATOMICS)
4343
typedef struct zend_atomic_bool_s {
4444
volatile char value;
4545
} zend_atomic_bool;
@@ -68,7 +68,7 @@ typedef struct zend_atomic_int_s {
6868

6969
BEGIN_EXTERN_C()
7070

71-
#ifdef ZEND_WIN32
71+
#if defined(ZEND_WIN32) && !defined(HAVE_C11_ATOMICS)
7272

7373
#ifndef InterlockedExchange8
7474
#define InterlockedExchange8 _InterlockedExchange8
@@ -123,7 +123,7 @@ static zend_always_inline bool zend_atomic_int_compare_exchange_ex(zend_atomic_i
123123
}
124124
}
125125

126-
/* On this platform it is non-const due to Iterlocked API*/
126+
/* On this platform it is non-const due to Interlocked API */
127127
static zend_always_inline bool zend_atomic_bool_load_ex(zend_atomic_bool *obj) {
128128
/* Or'ing with false won't change the value. */
129129
return InterlockedOr8(&obj->value, false);
@@ -376,7 +376,7 @@ ZEND_API bool zend_atomic_int_compare_exchange(zend_atomic_int *obj, int *expect
376376
ZEND_API void zend_atomic_bool_store(zend_atomic_bool *obj, bool desired);
377377
ZEND_API void zend_atomic_int_store(zend_atomic_int *obj, int desired);
378378

379-
#if defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)
379+
#if (defined(ZEND_WIN32) && !defined(HAVE_C11_ATOMICS)) || defined(HAVE_SYNC_ATOMICS)
380380
/* On these platforms it is non-const due to underlying APIs. */
381381
ZEND_API bool zend_atomic_bool_load(zend_atomic_bool *obj);
382382
ZEND_API int zend_atomic_int_load(zend_atomic_int *obj);

0 commit comments

Comments
 (0)