Skip to content

Commit b577038

Browse files
committed
Avoid TSRMLS_FETCH()'s (still lots of work left)
1 parent 0701d68 commit b577038

10 files changed

+41
-49
lines changed

Zend/zend.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,8 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals_p TSRMLS_DC)
333333
#endif
334334

335335
#ifdef ZTS
336-
static void zend_new_thread_end_handler(THREAD_T thread_id)
336+
static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
337337
{
338-
TSRMLS_FETCH();
339-
340338
zend_copy_ini_directives(TSRMLS_C);
341339
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
342340
}
@@ -420,7 +418,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
420418
#endif
421419

422420
if (start_builtin_functions) {
423-
zend_startup_builtin_functions();
421+
zend_startup_builtin_functions(TSRMLS_C);
424422
}
425423

426424
zend_ini_startup(TSRMLS_C);
@@ -522,18 +520,17 @@ void zend_activate(TSRMLS_D)
522520
}
523521

524522

525-
void zend_activate_modules()
523+
void zend_activate_modules(void)
526524
{
527-
zend_hash_apply(&module_registry, (int (*)(void *)) module_registry_request_startup);
525+
zend_hash_apply(&module_registry, (apply_func_t) module_registry_request_startup);
528526
}
529527

530-
void zend_deactivate_modules()
528+
void zend_deactivate_modules(TSRMLS_D)
531529
{
532-
TSRMLS_FETCH();
533530
EG(opline_ptr) = NULL; /* we're no longer executing anything */
534531

535532
zend_try {
536-
zend_hash_apply(&module_registry, (int (*)(void *)) module_registry_cleanup);
533+
zend_hash_apply(&module_registry, (apply_func_t) module_registry_cleanup);
537534
} zend_end_try();
538535
}
539536

@@ -780,12 +777,11 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, int file_count, ...)
780777

781778
#define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
782779

783-
ZEND_API char *zend_make_compiled_string_description(char *name)
780+
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC)
784781
{
785782
char *cur_filename;
786783
int cur_lineno;
787784
char *compiled_string_description;
788-
TSRMLS_FETCH();
789785

790786
if (zend_is_compiling()) {
791787
cur_filename = zend_get_compiled_filename(TSRMLS_C);

Zend/zend_API.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,15 +1025,14 @@ ZEND_API int zend_startup_module(zend_module_entry *module)
10251025

10261026

10271027
/* registers all functions in *library_functions in the function hash */
1028-
int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type)
1028+
int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC)
10291029
{
10301030
zend_function_entry *ptr = functions;
10311031
zend_function function;
10321032
zend_internal_function *internal_function = (zend_internal_function *)&function;
10331033
int count=0,unload=0;
10341034
HashTable *target_function_table = function_table;
10351035
int error_type;
1036-
TSRMLS_FETCH();
10371036

10381037
if (type==MODULE_PERSISTENT) {
10391038
error_type = E_CORE_WARNING;
@@ -1052,7 +1051,7 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
10521051
internal_function->function_name = ptr->fname;
10531052
if (!internal_function->handler) {
10541053
zend_error(error_type, "Null function defined as active function");
1055-
zend_unregister_functions(functions, count, target_function_table);
1054+
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
10561055
return FAILURE;
10571056
}
10581057
if (zend_hash_add(target_function_table, ptr->fname, strlen(ptr->fname)+1, &function, sizeof(zend_function), NULL) == FAILURE) {
@@ -1069,7 +1068,7 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
10691068
}
10701069
ptr++;
10711070
}
1072-
zend_unregister_functions(functions, count, target_function_table);
1071+
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
10731072
return FAILURE;
10741073
}
10751074
return SUCCESS;
@@ -1078,12 +1077,11 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
10781077
/* count=-1 means erase all functions, otherwise,
10791078
* erase the first count functions
10801079
*/
1081-
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table)
1080+
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC)
10821081
{
10831082
zend_function_entry *ptr = functions;
10841083
int i=0;
10851084
HashTable *target_function_table = function_table;
1086-
TSRMLS_FETCH();
10871085

10881086
if (!target_function_table) {
10891087
target_function_table = CG(function_table);
@@ -1104,10 +1102,12 @@ void zend_unregister_functions(zend_function_entry *functions, int count, HashTa
11041102

11051103
ZEND_API int zend_register_module(zend_module_entry *module)
11061104
{
1105+
TSRMLS_FETCH();
1106+
11071107
#if 0
11081108
zend_printf("%s: Registering module %d\n",module->name, module->module_number);
11091109
#endif
1110-
if (module->functions && zend_register_functions(module->functions, NULL, module->type)==FAILURE) {
1110+
if (module->functions && zend_register_functions(module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
11111111
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load",module->name);
11121112
return FAILURE;
11131113
}
@@ -1118,6 +1118,8 @@ ZEND_API int zend_register_module(zend_module_entry *module)
11181118

11191119
void module_destructor(zend_module_entry *module)
11201120
{
1121+
TSRMLS_FETCH();
1122+
11211123
if (module->type == MODULE_TEMPORARY) {
11221124
zend_clean_module_rsrc_dtors(module->module_number);
11231125
clean_module_constants(module->module_number);
@@ -1133,7 +1135,7 @@ void module_destructor(zend_module_entry *module)
11331135
}
11341136
module->module_started=0;
11351137
if (module->functions) {
1136-
zend_unregister_functions(module->functions, -1, NULL);
1138+
zend_unregister_functions(module->functions, -1, NULL TSRMLS_CC);
11371139
}
11381140

11391141
#if HAVE_LIBDL
@@ -1196,30 +1198,28 @@ int zend_next_free_module(void)
11961198
* If both parent_ce and parent_name are NULL it does a regular class registration
11971199
* If parent_name is specified but not found NULL is returned
11981200
*/
1199-
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name)
1201+
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC)
12001202
{
12011203
zend_class_entry *register_class;
1202-
TSRMLS_FETCH();
12031204

12041205
if (!parent_ce && parent_name) {
12051206
if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &parent_ce)==FAILURE) {
12061207
return NULL;
12071208
}
12081209
}
12091210

1210-
register_class = zend_register_internal_class(class_entry);
1211+
register_class = zend_register_internal_class(class_entry TSRMLS_CC);
12111212

12121213
if (parent_ce) {
12131214
zend_do_inheritance(register_class, parent_ce);
12141215
}
12151216
return register_class;
12161217
}
12171218

1218-
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry)
1219+
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC)
12191220
{
12201221
zend_class_entry *register_class;
12211222
char *lowercase_name = zend_strndup(class_entry->name, class_entry->name_length);
1222-
TSRMLS_FETCH();
12231223

12241224
zend_str_tolower(lowercase_name, class_entry->name_length);
12251225

@@ -1233,7 +1233,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_
12331233

12341234

12351235
if (class_entry->builtin_functions) {
1236-
zend_register_functions(class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT);
1236+
zend_register_functions(class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC);
12371237
}
12381238

12391239
zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, class_entry, sizeof(zend_class_entry), (void **) &register_class);
@@ -1298,7 +1298,7 @@ ZEND_API int zend_disable_function(char *function_name, uint function_name_lengt
12981298
return FAILURE;
12991299
}
13001300
disabled_function[0].fname = function_name;
1301-
return zend_register_functions(disabled_function, CG(function_table), MODULE_PERSISTENT);
1301+
return zend_register_functions(disabled_function, CG(function_table), MODULE_PERSISTENT TSRMLS_CC);
13021302
}
13031303

13041304
zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name)

Zend/zend_API.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@
4242
#define ZEND_RINIT(module) zend_rinit_##module
4343
#define ZEND_RSHUTDOWN(module) zend_rshutdown_##module
4444
#define ZEND_MINFO(module) zend_info_##module
45-
#define ZEND_GINIT(module) zend_ginit_##module
46-
#define ZEND_GSHUTDOWN(module) zend_gshutdown_##module
4745

4846
#define ZEND_MINIT_FUNCTION(module) int ZEND_MINIT(module)(INIT_FUNC_ARGS)
4947
#define ZEND_MSHUTDOWN_FUNCTION(module) int ZEND_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
5048
#define ZEND_RINIT_FUNCTION(module) int ZEND_RINIT(module)(INIT_FUNC_ARGS)
5149
#define ZEND_RSHUTDOWN_FUNCTION(module) int ZEND_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
5250
#define ZEND_MINFO_FUNCTION(module) void ZEND_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
53-
#define ZEND_GINIT_FUNCTION(module) int ZEND_GINIT(module)(GINIT_FUNC_ARGS)
54-
#define ZEND_GSHUTDOWN_FUNCTION(module) int ZEND_GSHUTDOWN(module)(void)
5551

5652
#define ZEND_GET_MODULE(name) \
5753
ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }
@@ -124,12 +120,12 @@ ZEND_API int zend_parse_parameters_ex(int flags, int num_args, char *type_spec,
124120

125121
ZEND_API int ParameterPassedByReference(int ht, uint n);
126122

127-
int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type);
128-
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
123+
int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);
124+
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC);
129125
ZEND_API int zend_register_module(zend_module_entry *module_entry);
130126

131-
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
132-
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name);
127+
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
128+
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
133129

134130
ZEND_API zend_module_entry *zend_get_module(int module_number);
135131
ZEND_API int zend_disable_function(char *function_name, uint function_name_length);

Zend/zend_builtin_functions.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ static zend_function_entry builtin_functions[] = {
122122
};
123123

124124

125-
int zend_startup_builtin_functions()
125+
int zend_startup_builtin_functions(TSRMLS_D)
126126
{
127-
return zend_register_functions(builtin_functions, NULL, MODULE_PERSISTENT);
127+
return zend_register_functions(builtin_functions, NULL, MODULE_PERSISTENT TSRMLS_CC);
128128
}
129129

130130

@@ -947,7 +947,7 @@ ZEND_FUNCTION(create_function)
947947
eval_code = (char *) emalloc(eval_code_length);
948948
sprintf(eval_code, "function " LAMBDA_TEMP_FUNCNAME "(%s){%s}", Z_STRVAL_PP(z_function_args), Z_STRVAL_PP(z_function_code));
949949

950-
eval_name = zend_make_compiled_string_description("runtime-created function");
950+
eval_name = zend_make_compiled_string_description("runtime-created function" TSRMLS_CC);
951951
retval = zend_eval_string(eval_code, NULL, eval_name TSRMLS_CC);
952952
efree(eval_code);
953953
efree(eval_name);

Zend/zend_builtin_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
#ifndef ZEND_BUILTIN_FUNCTIONS_H
2222
#define ZEND_BUILTIN_FUNCTIONS_H
2323

24-
int zend_startup_builtin_functions(void);
24+
int zend_startup_builtin_functions(TSRMLS_D);
2525

2626
#endif /* ZEND_BUILTIN_FUNCTIONS_H */

Zend/zend_compile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handl
205205
void zend_activate(TSRMLS_D);
206206
void zend_deactivate(TSRMLS_D);
207207
void zend_activate_modules(void);
208-
void zend_deactivate_modules(void);
208+
void zend_deactivate_modules(TSRMLS_D);
209209

210210

211211
int lex_scan(zval *zendlval TSRMLS_DC);
@@ -388,7 +388,7 @@ void print_op_array(zend_op_array *op_array, int optimizations);
388388
int pass_two(zend_op_array *op_array);
389389
zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
390390
ZEND_API zend_bool zend_is_compiling(void);
391-
ZEND_API char *zend_make_compiled_string_description(char *name);
391+
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
392392

393393
int zendlex(znode *zendlval TSRMLS_DC);
394394

Zend/zend_constants.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void clean_non_persistent_constants(void)
160160
{
161161
TSRMLS_FETCH();
162162

163-
zend_hash_apply(EG(zend_constants), (int (*)(void *)) clean_non_persistent_constant);
163+
zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant);
164164
}
165165

166166

Zend/zend_execute.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,19 +937,19 @@ static void call_overloaded_function(temp_variable *T, int arg_count, zval *retu
937937
#if ZEND_INTENSIVE_DEBUGGING
938938

939939
#define CHECK_SYMBOL_TABLES() \
940-
zend_hash_apply(&EG(symbol_table), (int (*)()) zend_check_symbol); \
940+
zend_hash_apply(&EG(symbol_table), (apply_func_t) zend_check_symbol); \
941941
if (&EG(symbol_table)!=EG(active_symbol_table)) { \
942-
zend_hash_apply(EG(active_symbol_table), (int (*)()) zend_check_symbol); \
942+
zend_hash_apply(EG(active_symbol_table), (apply_func_t) zend_check_symbol); \
943943
}
944944

945945
static int zend_check_symbol(zval **pz)
946946
{
947947
if ((*pz)->type>9) {
948948
fprintf(stderr, "Warning! %x has invalid type!\n", *pz);
949949
} else if ((*pz)->type==IS_ARRAY) {
950-
zend_hash_apply((*pz)->value.ht, (int (*)()) zend_check_symbol);
950+
zend_hash_apply((*pz)->value.ht, (apply_func_t) zend_check_symbol);
951951
} else if ((*pz)->type==IS_OBJECT) {
952-
zend_hash_apply((*pz)->value.obj.properties, (int (*)()) zend_check_symbol);
952+
zend_hash_apply((*pz)->value.obj.properties, (apply_func_t) zend_check_symbol);
953953
}
954954

955955
return 0;
@@ -2086,7 +2086,7 @@ binary_assign_op_addr: {
20862086
new_op_array = compile_filename(opline->op2.u.constant.value.lval, inc_filename TSRMLS_CC);
20872087
break;
20882088
case ZEND_EVAL: {
2089-
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
2089+
char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
20902090

20912091
new_op_array = compile_string(inc_filename, eval_desc TSRMLS_CC);
20922092
efree(eval_desc);

Zend/zend_execute_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ void shutdown_executor(TSRMLS_D)
173173
zend_ptr_stack_destroy(&EG(argument_stack));
174174

175175
/* Destroy all op arrays */
176-
zend_hash_apply(EG(function_table), (int (*)(void *)) is_not_internal_function);
177-
zend_hash_apply(EG(class_table), (int (*)(void *)) is_not_internal_class);
176+
zend_hash_apply(EG(function_table), (apply_func_t) is_not_internal_function);
177+
zend_hash_apply(EG(class_table), (apply_func_t) is_not_internal_class);
178178
} zend_end_try();
179179

180180
zend_destroy_rsrc_list(TSRMLS_C); /* must be destroyed after the main symbol table and

Zend/zend_opcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int pass_two(zend_op_array *op_array)
302302
int print_class(zend_class_entry *class_entry)
303303
{
304304
printf("Class %s:\n", class_entry->name);
305-
zend_hash_apply(&class_entry->function_table, (int (*)(void *)) pass_two);
305+
zend_hash_apply(&class_entry->function_table, (apply_func_t) pass_two);
306306
printf("End of class %s.\n\n", class_entry->name);
307307
return 0;
308308
}

0 commit comments

Comments
 (0)