Skip to content

Commit

Permalink
Fix build on PHP-8.2 (compatibility with zend_atomic) (#4767)
Browse files Browse the repository at this point in the history
  • Loading branch information
twose authored Jul 21, 2022
1 parent b590416 commit 4c7520d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ext-src/php_swoole_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ php_socket *php_swoole_convert_to_socket(int sock);

zend_bool php_swoole_signal_isset_handler(int signo);

#if PHP_VERSION_ID < 80200
# define zend_atomic_bool zend_bool
# define zend_atomic_bool_store(atomic, desired) (*atomic = desired)
#endif

#define sw_zend7_object zend_object
#define SW_Z7_OBJ_P(object) object
#define SW_Z8_OBJ_P(zobj) Z_OBJ_P(zobj)
Expand Down
4 changes: 2 additions & 2 deletions ext-src/swoole_coroutine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool PHPCoroutine::interrupt_thread_running = false;

extern void php_swoole_load_library();

static zend_bool *zend_vm_interrupt = nullptr;
static zend_atomic_bool *zend_vm_interrupt = nullptr;
static user_opcode_handler_t ori_exit_handler = nullptr;
static user_opcode_handler_t ori_begin_silence_handler = nullptr;
static user_opcode_handler_t ori_end_silence_handler = nullptr;
Expand Down Expand Up @@ -399,7 +399,7 @@ void PHPCoroutine::interrupt_thread_start() {
interrupt_thread = std::thread([]() {
swoole_signal_block_all();
while (interrupt_thread_running) {
*zend_vm_interrupt = 1;
zend_atomic_bool_store(zend_vm_interrupt, 1);
std::this_thread::sleep_for(std::chrono::milliseconds(MAX_EXEC_MSEC / 2));
}
});
Expand Down

0 comments on commit 4c7520d

Please sign in to comment.