@@ -135,7 +135,11 @@ static void preload_shutdown(void);
135
135
static void preload_activate (void );
136
136
static void preload_restart (void );
137
137
138
- #ifdef ZEND_WIN32
138
+ #ifdef HAVE_STDATOMIC_H
139
+ # define INCREMENT (v ) (++ZCSG(v))
140
+ # define DECREMENT (v ) (--ZCSG(v))
141
+ # define LOCKVAL (v ) atomic_load(&ZCSG(v))
142
+ #elif defined(ZEND_WIN32 )
139
143
# define INCREMENT (v ) InterlockedIncrement64(&ZCSG(v))
140
144
# define DECREMENT (v ) InterlockedDecrement64(&ZCSG(v))
141
145
# define LOCKVAL (v ) (ZCSG(v))
@@ -273,7 +277,7 @@ static ZEND_INI_MH(accel_include_path_on_modify)
273
277
274
278
static inline void accel_restart_enter (void )
275
279
{
276
- #ifdef ZEND_WIN32
280
+ #ifdef INCREMENT
277
281
INCREMENT (restart_in );
278
282
#else
279
283
struct flock restart_in_progress ;
@@ -292,7 +296,7 @@ static inline void accel_restart_enter(void)
292
296
293
297
static inline void accel_restart_leave (void )
294
298
{
295
- #ifdef ZEND_WIN32
299
+ #ifdef DECREMENT
296
300
ZCSG (restart_in_progress ) = false;
297
301
DECREMENT (restart_in );
298
302
#else
@@ -313,7 +317,9 @@ static inline void accel_restart_leave(void)
313
317
static inline int accel_restart_is_active (void )
314
318
{
315
319
if (ZCSG (restart_in_progress )) {
316
- #ifndef ZEND_WIN32
320
+ #ifdef LOCKVAL
321
+ return LOCKVAL (restart_in ) != 0 ;
322
+ #else
317
323
struct flock restart_check ;
318
324
319
325
restart_check .l_type = F_WRLCK ;
@@ -331,8 +337,6 @@ static inline int accel_restart_is_active(void)
331
337
} else {
332
338
return 1 ;
333
339
}
334
- #else
335
- return LOCKVAL (restart_in ) != 0 ;
336
340
#endif
337
341
}
338
342
return 0 ;
@@ -341,7 +345,7 @@ static inline int accel_restart_is_active(void)
341
345
/* Creates a read lock for SHM access */
342
346
static inline zend_result accel_activate_add (void )
343
347
{
344
- #ifdef ZEND_WIN32
348
+ #ifdef INCREMENT
345
349
SHM_UNPROTECT ();
346
350
INCREMENT (mem_usage );
347
351
SHM_PROTECT ();
@@ -364,7 +368,7 @@ static inline zend_result accel_activate_add(void)
364
368
/* Releases a lock for SHM access */
365
369
static inline void accel_deactivate_sub (void )
366
370
{
367
- #ifdef ZEND_WIN32
371
+ #ifdef DECREMENT
368
372
if (ZCG (counted )) {
369
373
SHM_UNPROTECT ();
370
374
DECREMENT (mem_usage );
@@ -387,7 +391,7 @@ static inline void accel_deactivate_sub(void)
387
391
388
392
static inline void accel_unlock_all (void )
389
393
{
390
- #ifdef ZEND_WIN32
394
+ #ifdef DECREMENT
391
395
accel_deactivate_sub ();
392
396
#else
393
397
struct flock mem_usage_unlock_all ;
@@ -828,7 +832,7 @@ static void accel_use_shm_interned_strings(void)
828
832
HANDLE_UNBLOCK_INTERRUPTIONS ();
829
833
}
830
834
831
- #ifndef ZEND_WIN32
835
+ #ifndef LOCKVAL
832
836
static inline void kill_all_lockers (struct flock * mem_usage_check )
833
837
{
834
838
int tries ;
@@ -895,7 +899,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
895
899
896
900
static inline int accel_is_inactive (void )
897
901
{
898
- #ifdef ZEND_WIN32
902
+ #ifdef LOCKVAL
899
903
if (LOCKVAL (mem_usage ) == 0 ) {
900
904
return SUCCESS ;
901
905
}
0 commit comments