@@ -63,61 +63,61 @@ BEGIN_EXTERN_C()
6363
6464#define ZEND_ATOMIC_BOOL_INIT (obj , desired ) ((obj)->value = (desired))
6565
66- inline ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired ) {
66+ zend_always_inline bool zend_atomic_bool_exchange_ex (zend_atomic_bool * obj , bool desired ) {
6767 return InterlockedExchange8 (& obj -> value , desired );
6868}
6969
7070/* On this platform it is non-const due to Iterlocked API*/
71- inline ZEND_API bool zend_atomic_bool_load (zend_atomic_bool * obj ) {
71+ zend_always_inline bool zend_atomic_bool_load_ex (zend_atomic_bool * obj ) {
7272 /* Or'ing with false won't change the value. */
7373 return InterlockedOr8 (& obj -> value , false);
7474}
7575
76- inline ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired ) {
76+ zend_always_inline void zend_atomic_bool_store_ex (zend_atomic_bool * obj , bool desired ) {
7777 (void )InterlockedExchange8 (& obj -> value , desired );
7878}
7979
8080#elif HAVE_C11_ATOMICS
8181
8282#define ZEND_ATOMIC_BOOL_INIT (obj , desired ) __c11_atomic_init(&(obj)->value, (desired))
8383
84- inline ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired ) {
84+ zend_always_inline bool zend_atomic_bool_exchange_ex (zend_atomic_bool * obj , bool desired ) {
8585 return __c11_atomic_exchange (& obj -> value , desired , __ATOMIC_SEQ_CST );
8686}
8787
88- inline ZEND_API bool zend_atomic_bool_load (const zend_atomic_bool * obj ) {
88+ zend_always_inline bool zend_atomic_bool_load_ex (const zend_atomic_bool * obj ) {
8989 return __c11_atomic_load (& obj -> value , __ATOMIC_SEQ_CST );
9090}
9191
92- inline ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired ) {
92+ zend_always_inline void zend_atomic_bool_store_ex (zend_atomic_bool * obj , bool desired ) {
9393 __c11_atomic_store (& obj -> value , desired , __ATOMIC_SEQ_CST );
9494}
9595
9696#elif HAVE_GNUC_ATOMICS
9797
9898#define ZEND_ATOMIC_BOOL_INIT (obj , desired ) ((obj)->value = (desired))
9999
100- inline ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired ) {
100+ zend_always_inline bool zend_atomic_bool_exchange_ex (zend_atomic_bool * obj , bool desired ) {
101101 bool prev = false;
102102 __atomic_exchange (& obj -> value , & desired , & prev , __ATOMIC_SEQ_CST );
103103 return prev ;
104104}
105105
106- inline ZEND_API bool zend_atomic_bool_load (const zend_atomic_bool * obj ) {
106+ zend_always_inline bool zend_atomic_bool_load_ex (const zend_atomic_bool * obj ) {
107107 bool prev = false;
108108 __atomic_load (& obj -> value , & prev , __ATOMIC_SEQ_CST );
109109 return prev ;
110110}
111111
112- inline ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired ) {
112+ zend_always_inline void zend_atomic_bool_store_ex (zend_atomic_bool * obj , bool desired ) {
113113 __atomic_store (& obj -> value , & desired , __ATOMIC_SEQ_CST );
114114}
115115
116116#elif HAVE_SYNC_ATOMICS
117117
118118#define ZEND_ATOMIC_BOOL_INIT (obj , desired ) ((obj)->value = (desired))
119119
120- inline ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired ) {
120+ zend_always_inline bool zend_atomic_bool_exchange_ex (zend_atomic_bool * obj , bool desired ) {
121121 bool prev = __sync_lock_test_and_set (& obj -> value , desired );
122122
123123 /* __sync_lock_test_and_set only does an acquire barrier, so sync
@@ -127,12 +127,12 @@ inline ZEND_API bool zend_atomic_bool_exchange(zend_atomic_bool *obj, bool desir
127127 return prev ;
128128}
129129
130- inline ZEND_API bool zend_atomic_bool_load (zend_atomic_bool * obj ) {
130+ zend_always_inline bool zend_atomic_bool_load_ex (zend_atomic_bool * obj ) {
131131 /* Or'ing false won't change the value */
132132 return __sync_fetch_and_or (& obj -> value , false);
133133}
134134
135- inline ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired ) {
135+ zend_always_inline void zend_atomic_bool_store_ex (zend_atomic_bool * obj , bool desired ) {
136136 __sync_synchronize ();
137137 obj -> value = desired ;
138138 __sync_synchronize ();
@@ -150,22 +150,33 @@ inline ZEND_API void zend_atomic_bool_store(zend_atomic_bool *obj, bool desired)
150150 * At the time of this writing, all platforms in CI avoided this fallback.
151151 */
152152
153- inline ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired ) {
153+ zend_always_inline void zend_atomic_bool_store_ex (zend_atomic_bool * obj , bool desired ) {
154154 obj -> value = desired ;
155155}
156156
157- inline ZEND_API bool zend_atomic_bool_load (const zend_atomic_bool * obj ) {
157+ zend_always_inline bool zend_atomic_bool_load_ex (const zend_atomic_bool * obj ) {
158158 return obj -> value ;
159159}
160160
161- inline ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired ) {
161+ zend_always_inline bool zend_atomic_bool_exchange_ex (zend_atomic_bool * obj , bool desired ) {
162162 bool prev = obj -> value ;
163163 obj -> value = true;
164164 return prev ;
165165}
166166
167167#endif
168168
169+ ZEND_API void zend_atomic_bool_init (zend_atomic_bool * obj , bool desired );
170+ ZEND_API bool zend_atomic_bool_exchange (zend_atomic_bool * obj , bool desired );
171+ ZEND_API void zend_atomic_bool_store (zend_atomic_bool * obj , bool desired );
172+
173+ #if ZEND_WIN32 || HAVE_SYNC_ATOMICS
174+ /* On these platforms it is non-const due to underlying APIs. */
175+ ZEND_API bool zend_atomic_bool_load (zend_atomic_bool * obj );
176+ #else
177+ ZEND_API bool zend_atomic_bool_load (const zend_atomic_bool * obj );
178+ #endif
179+
169180END_EXTERN_C ()
170181
171182#endif
0 commit comments