Skip to content

Commit aed4b08

Browse files
committed
Eliminate the TSRMLS_FETCH() calls in the ticks functions and hook
1 parent c835981 commit aed4b08

File tree

8 files changed

+13
-19
lines changed

8 files changed

+13
-19
lines changed

Zend/zend.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC)
5656
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
5757
ZEND_API void (*zend_block_interruptions)(void);
5858
ZEND_API void (*zend_unblock_interruptions)(void);
59-
ZEND_API void (*zend_ticks_function)(int ticks);
59+
ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
6060
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
6161
int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
6262
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);

Zend/zend.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ typedef struct _zend_utility_functions {
550550
void (*block_interruptions)(void);
551551
void (*unblock_interruptions)(void);
552552
int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
553-
void (*ticks_function)(int ticks);
553+
void (*ticks_function)(int ticks TSRMLS_DC);
554554
void (*on_timeout)(int seconds TSRMLS_DC);
555555
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
556556
int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
@@ -698,7 +698,7 @@ extern ZEND_API zend_write_func_t zend_write;
698698
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
699699
extern ZEND_API void (*zend_block_interruptions)(void);
700700
extern ZEND_API void (*zend_unblock_interruptions)(void);
701-
extern ZEND_API void (*zend_ticks_function)(int ticks);
701+
extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
702702
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
703703
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
704704
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);

Zend/zend_vm_def.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4911,7 +4911,7 @@ ZEND_VM_HANDLER(105, ZEND_TICKS, ANY, ANY)
49114911
if (++EG(ticks_count)>=opline->extended_value) {
49124912
EG(ticks_count)=0;
49134913
if (zend_ticks_function) {
4914-
zend_ticks_function(opline->extended_value);
4914+
zend_ticks_function(opline->extended_value TSRMLS_CC);
49154915
}
49164916
}
49174917
CHECK_EXCEPTION();

Zend/zend_vm_execute.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static int ZEND_FASTCALL ZEND_TICKS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
954954
if (++EG(ticks_count)>=opline->extended_value) {
955955
EG(ticks_count)=0;
956956
if (zend_ticks_function) {
957-
zend_ticks_function(opline->extended_value);
957+
zend_ticks_function(opline->extended_value TSRMLS_CC);
958958
}
959959
}
960960
CHECK_EXCEPTION();

ext/pcntl/pcntl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ PHP_MINIT_FUNCTION(pcntl)
499499
{
500500
php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU);
501501
php_pcntl_register_errno_constants(INIT_FUNC_ARGS_PASSTHRU);
502-
php_add_tick_function(pcntl_signal_dispatch);
502+
php_add_tick_function(pcntl_signal_dispatch TSRMLS_CC);
503503

504504
return SUCCESS;
505505
}

ext/standard/basic_functions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5751,7 +5751,7 @@ PHP_FUNCTION(register_tick_function)
57515751
zend_llist_init(BG(user_tick_functions),
57525752
sizeof(user_tick_function_entry),
57535753
(llist_dtor_func_t) user_tick_function_dtor, 0);
5754-
php_add_tick_function(run_user_tick_functions);
5754+
php_add_tick_function(run_user_tick_functions TSRMLS_CC);
57555755
}
57565756

57575757
for (i = 0; i < tick_fe.arg_count; i++) {

main/php_ticks.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,13 @@ static int php_compare_tick_functions(void *elem1, void *elem2)
4646
return (func1 == func2);
4747
}
4848

49-
PHPAPI void php_add_tick_function(void (*func)(int))
49+
PHPAPI void php_add_tick_function(void (*func)(int) TSRMLS_DC)
5050
{
51-
TSRMLS_FETCH();
52-
5351
zend_llist_add_element(&PG(tick_functions), (void *)&func);
5452
}
5553

56-
PHPAPI void php_remove_tick_function(void (*func)(int))
54+
PHPAPI void php_remove_tick_function(void (*func)(int) TSRMLS_DC)
5755
{
58-
TSRMLS_FETCH();
59-
6056
zend_llist_del_element(&PG(tick_functions), (void *)func,
6157
(int(*)(void*, void*))php_compare_tick_functions);
6258
}
@@ -69,10 +65,8 @@ static void php_tick_iterator(void *data, void *arg TSRMLS_DC)
6965
func(*((int *)arg));
7066
}
7167

72-
void php_run_ticks(int count)
68+
void php_run_ticks(int count TSRMLS_DC)
7369
{
74-
TSRMLS_FETCH();
75-
7670
zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count TSRMLS_CC);
7771
}
7872

main/php_ticks.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
int php_startup_ticks(TSRMLS_D);
2525
void php_deactivate_ticks(TSRMLS_D);
2626
void php_shutdown_ticks(TSRMLS_D);
27-
void php_run_ticks(int count);
27+
void php_run_ticks(int count TSRMLS_DC);
2828

2929
BEGIN_EXTERN_C()
30-
PHPAPI void php_add_tick_function(void (*func)(int));
31-
PHPAPI void php_remove_tick_function(void (*func)(int));
30+
PHPAPI void php_add_tick_function(void (*func)(int) TSRMLS_DC);
31+
PHPAPI void php_remove_tick_function(void (*func)(int) TSRMLS_DC);
3232
END_EXTERN_C()
3333

3434
#endif

0 commit comments

Comments
 (0)