Skip to content

Commit b994aea

Browse files
committed
prefer C11 atomics over ZEND_WIN32 locking mechanism (mfence instructions on every zend_atomic_*_load_ex)
# Conflicts: # win32/build/confutils.js
1 parent 3619caa commit b994aea

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

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_SYNC_ATOMICS)) && !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);

win32/build/confutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3363,7 +3363,7 @@ function toolset_setup_common_cflags()
33633363

33643364
ADD_FLAG("CFLAGS", "/Zc:wchar_t");
33653365
} else if (CLANG_TOOLSET) {
3366-
ADD_FLAG("CFLAGS", "-Wno-deprecated-declarations");
3366+
ADD_FLAG("CFLAGS", "-Wno-deprecated-declarations -Wno-microsoft-enum-forward-reference");
33673367
if (TARGET_ARCH == 'x86') {
33683368
ADD_FLAG('CFLAGS', '-m32');
33693369
} else {

0 commit comments

Comments
 (0)