From dc385f473ed6c78a48d593e631b9375aeb9088af Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 6 Jul 2025 15:39:00 +0100 Subject: [PATCH 1/3] ext/pcntl: Use bool type for some module globals This clarifies intention and uses less bytes in the struct --- ext/pcntl/pcntl.c | 8 ++++---- ext/pcntl/php_pcntl.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 6558ef8dcdd04..e11de304b1b79 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -1355,7 +1355,7 @@ static void pcntl_signal_handler(int signo) PCNTL_G(head) = psig; } PCNTL_G(tail) = psig; - PCNTL_G(pending_signals) = 1; + PCNTL_G(pending_signals) = true; if (PCNTL_G(async_signals)) { zend_atomic_bool_store_ex(&EG(vm_interrupt), true); } @@ -1386,7 +1386,7 @@ void pcntl_signal_dispatch(void) zend_fiber_switch_block(); /* Prevent reentrant handler calls */ - PCNTL_G(processing_signal_queue) = 1; + PCNTL_G(processing_signal_queue) = true; queue = PCNTL_G(head); PCNTL_G(head) = NULL; /* simple stores are atomic */ @@ -1418,10 +1418,10 @@ void pcntl_signal_dispatch(void) queue = next; } - PCNTL_G(pending_signals) = 0; + PCNTL_G(pending_signals) = false; /* Re-enable queue */ - PCNTL_G(processing_signal_queue) = 0; + PCNTL_G(processing_signal_queue) = false; /* Re-enable fiber switching */ zend_fiber_switch_unblock(); diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h index f09ccadcd3cdb..e190767a6dd60 100644 --- a/ext/pcntl/php_pcntl.h +++ b/ext/pcntl/php_pcntl.h @@ -43,10 +43,10 @@ struct php_pcntl_pending_signal { ZEND_BEGIN_MODULE_GLOBALS(pcntl) HashTable php_signal_table; - int processing_signal_queue; + bool processing_signal_queue; struct php_pcntl_pending_signal *head, *tail, *spares; int last_error; - volatile char pending_signals; + volatile bool pending_signals; bool async_signals; unsigned num_signals; ZEND_END_MODULE_GLOBALS(pcntl) From 3430d3678cf2fc13e7b42fb97e6e476ce1833bcc Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 6 Jul 2025 15:42:59 +0100 Subject: [PATCH 2/3] ext/pcntl: Use uint8_t type for num_signals module global --- ext/pcntl/php_pcntl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h index e190767a6dd60..a16b3e0f47e7a 100644 --- a/ext/pcntl/php_pcntl.h +++ b/ext/pcntl/php_pcntl.h @@ -48,7 +48,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl) int last_error; volatile bool pending_signals; bool async_signals; - unsigned num_signals; + uint8_t num_signals; ZEND_END_MODULE_GLOBALS(pcntl) #if defined(ZTS) && defined(COMPILE_DL_PCNTL) From 34eb43b083c37e293c72767d87d360bc723ee679 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 6 Jul 2025 15:44:08 +0100 Subject: [PATCH 3/3] ext/pcntl: Pack module globals struct This saves 8 bytes --- ext/pcntl/php_pcntl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h index a16b3e0f47e7a..f2cc0d59195f4 100644 --- a/ext/pcntl/php_pcntl.h +++ b/ext/pcntl/php_pcntl.h @@ -44,11 +44,11 @@ struct php_pcntl_pending_signal { ZEND_BEGIN_MODULE_GLOBALS(pcntl) HashTable php_signal_table; bool processing_signal_queue; - struct php_pcntl_pending_signal *head, *tail, *spares; - int last_error; volatile bool pending_signals; bool async_signals; uint8_t num_signals; + int last_error; + struct php_pcntl_pending_signal *head, *tail, *spares; ZEND_END_MODULE_GLOBALS(pcntl) #if defined(ZTS) && defined(COMPILE_DL_PCNTL)