Skip to content

Commit 4187439

Browse files
committed
More TSRMLS_FETCH work
1 parent 797a079 commit 4187439

17 files changed

+56
-87
lines changed

Zend/zend.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,10 @@ ZEND_API void zend_error(int type, const char *format, ...)
606606
case E_USER_ERROR:
607607
case E_USER_WARNING:
608608
case E_USER_NOTICE:
609-
if (zend_is_compiling()) {
609+
if (zend_is_compiling(TSRMLS_C)) {
610610
error_filename = zend_get_compiled_filename(TSRMLS_C);
611611
error_lineno = zend_get_compiled_lineno(TSRMLS_C);
612-
} else if (zend_is_executing()) {
612+
} else if (zend_is_executing(TSRMLS_C)) {
613613
error_filename = zend_get_executed_filename(TSRMLS_C);
614614
error_lineno = zend_get_executed_lineno(TSRMLS_C);
615615
} else {
@@ -688,7 +688,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
688688

689689
orig_user_error_handler = EG(user_error_handler);
690690
EG(user_error_handler) = NULL;
691-
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL)==SUCCESS) {
691+
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC)==SUCCESS) {
692692
zval_ptr_dtor(&retval);
693693
} else {
694694
/* The user error handler failed, use built-in error handler */
@@ -783,10 +783,10 @@ ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC)
783783
int cur_lineno;
784784
char *compiled_string_description;
785785

786-
if (zend_is_compiling()) {
786+
if (zend_is_compiling(TSRMLS_C)) {
787787
cur_filename = zend_get_compiled_filename(TSRMLS_C);
788788
cur_lineno = zend_get_compiled_lineno(TSRMLS_C);
789-
} else if (zend_is_executing()) {
789+
} else if (zend_is_executing(TSRMLS_C)) {
790790
cur_filename = zend_get_executed_filename(TSRMLS_C);
791791
cur_lineno = zend_get_executed_lineno(TSRMLS_C);
792792
} else {

Zend/zend_API.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr
158158
}
159159

160160

161-
ZEND_API void wrong_param_count()
161+
ZEND_API void zend_wrong_param_count(TSRMLS_D)
162162
{
163-
zend_error(E_WARNING,"Wrong parameter count for %s()",get_active_function_name());
163+
zend_error(E_WARNING, "Wrong parameter count for %s()", get_active_function_name(TSRMLS_C));
164164
}
165165

166166

@@ -429,7 +429,7 @@ static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec)
429429
return NULL;
430430
}
431431

432-
static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet)
432+
static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet TSRMLS_DC)
433433
{
434434
char *expected_type = NULL;
435435
char buf[1024];
@@ -438,7 +438,7 @@ static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int
438438
if (expected_type) {
439439
if (!quiet) {
440440
sprintf(buf, "%s() expects argument %d to be %s, %s given",
441-
get_active_function_name(), arg_num, expected_type,
441+
get_active_function_name(TSRMLS_C), arg_num, expected_type,
442442
zend_zval_type_name(*arg));
443443
zend_error(E_WARNING, buf);
444444
}
@@ -482,7 +482,7 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
482482

483483
default:
484484
if (!quiet) {
485-
zend_error(E_WARNING, "%s(): bad type specifier while parsing arguments", get_active_function_name());
485+
zend_error(E_WARNING, "%s(): bad type specifier while parsing arguments", get_active_function_name(TSRMLS_C));
486486
}
487487
return FAILURE;
488488
}
@@ -495,7 +495,7 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
495495
if (num_args < min_num_args || num_args > max_num_args) {
496496
if (!quiet) {
497497
sprintf(buf, "%s() requires %s %d argument%s, %d given",
498-
get_active_function_name(),
498+
get_active_function_name(TSRMLS_C),
499499
min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
500500
num_args < min_num_args ? min_num_args : max_num_args,
501501
(num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
@@ -510,7 +510,7 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
510510

511511
if (num_args > arg_count) {
512512
zend_error(E_WARNING, "%s(): could not obtain arguments for parsing",
513-
get_active_function_name());
513+
get_active_function_name(TSRMLS_C));
514514
return FAILURE;
515515
}
516516

@@ -520,7 +520,7 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
520520
if (*type_spec == '|') {
521521
type_spec++;
522522
}
523-
if (zend_parse_arg(i+1, arg, va, &type_spec, quiet) == FAILURE) {
523+
if (zend_parse_arg(i+1, arg, va, &type_spec, quiet TSRMLS_CC) == FAILURE) {
524524
return FAILURE;
525525
}
526526
i++;
@@ -1101,7 +1101,7 @@ void module_destructor(zend_module_entry *module)
11011101

11021102
if (module->type == MODULE_TEMPORARY) {
11031103
zend_clean_module_rsrc_dtors(module->module_number);
1104-
clean_module_constants(module->module_number);
1104+
clean_module_constants(module->module_number TSRMLS_CC);
11051105
if (module->request_shutdown_func)
11061106
module->request_shutdown_func(module->type, module->module_number TSRMLS_CC);
11071107
}
@@ -1261,7 +1261,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
12611261

12621262
static ZEND_FUNCTION(display_disabled_function)
12631263
{
1264-
zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name());
1264+
zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C));
12651265
}
12661266

12671267

Zend/zend_API.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
132132
ZEND_API zend_module_entry *zend_get_module(int module_number);
133133
ZEND_API int zend_disable_function(char *function_name, uint function_name_length);
134134

135-
ZEND_API void wrong_param_count(void);
135+
ZEND_API void zend_wrong_param_count(TSRMLS_D);
136136
ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name);
137137

138138
#define getThis() (this_ptr)
@@ -141,8 +141,8 @@ ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char
141141
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
142142
#define ARG_COUNT(dummy) (ht)
143143
#define ZEND_NUM_ARGS() (ht)
144-
#define ZEND_WRONG_PARAM_COUNT() { wrong_param_count(); return; }
145-
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { wrong_param_count(); return ret; }
144+
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; }
145+
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; }
146146

147147
#ifndef ZEND_WIN32
148148
#define DLEXPORT
@@ -231,8 +231,8 @@ ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *valu
231231
#define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
232232
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value)
233233

234-
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[]);
235-
ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table);
234+
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC);
235+
ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC);
236236

237237
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
238238
int is_ref, int num_symbol_tables, ...);

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ ZEND_FUNCTION(defined)
444444
}
445445

446446
convert_to_string_ex(var);
447-
if (zend_get_constant((*var)->value.str.val, (*var)->value.str.len, &c)) {
447+
if (zend_get_constant((*var)->value.str.val, (*var)->value.str.len, &c TSRMLS_CC)) {
448448
zval_dtor(&c);
449449
RETURN_LONG(1);
450450
} else {

Zend/zend_compile.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ void shutdown_compiler(TSRMLS_D)
108108
}
109109

110110

111-
ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename)
111+
ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename TSRMLS_DC)
112112
{
113113
char **pp, *p;
114114
int length = strlen(new_compiled_filename);
115-
TSRMLS_FETCH();
116115

117116
if (zend_hash_find(&CG(filenames_table), new_compiled_filename, length+1, (void **) &pp)==SUCCESS) {
118117
CG(compiled_filename) = *pp;
@@ -125,10 +124,8 @@ ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename)
125124
}
126125

127126

128-
ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename)
127+
ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC)
129128
{
130-
TSRMLS_FETCH();
131-
132129
CG(compiled_filename) = original_compiled_filename;
133130
}
134131

@@ -145,10 +142,8 @@ ZEND_API int zend_get_compiled_lineno(TSRMLS_D)
145142
}
146143

147144

148-
ZEND_API zend_bool zend_is_compiling()
145+
ZEND_API zend_bool zend_is_compiling(TSRMLS_D)
149146
{
150-
TSRMLS_FETCH();
151-
152147
return CG(in_compilation);
153148
}
154149

Zend/zend_compile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ int lex_scan(zval *zendlval TSRMLS_DC);
212212
void startup_scanner(TSRMLS_D);
213213
void shutdown_scanner(TSRMLS_D);
214214

215-
ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename);
216-
ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename);
215+
ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename TSRMLS_DC);
216+
ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC);
217217
ZEND_API char *zend_get_compiled_filename(TSRMLS_D);
218218
ZEND_API int zend_get_compiled_lineno(TSRMLS_D);
219219

@@ -387,7 +387,7 @@ int print_class(zend_class_entry *class_entry);
387387
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);
390-
ZEND_API zend_bool zend_is_compiling(void);
390+
ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
391391
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
392392

393393
int zendlex(znode *zendlval TSRMLS_DC);

Zend/zend_constants.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ static int clean_module_constant(zend_constant *c, int *module_number)
7171
}
7272

7373

74-
void clean_module_constants(int module_number)
74+
void clean_module_constants(int module_number TSRMLS_DC)
7575
{
76-
TSRMLS_FETCH();
77-
7876
zend_hash_apply_with_argument(EG(zend_constants), (int (*)(void *,void *)) clean_module_constant, (void *) &module_number);
7977
}
8078

@@ -156,10 +154,8 @@ int zend_shutdown_constants(TSRMLS_D)
156154
}
157155

158156

159-
void clean_non_persistent_constants(void)
157+
void clean_non_persistent_constants(TSRMLS_D)
160158
{
161-
TSRMLS_FETCH();
162-
163159
zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant);
164160
}
165161

@@ -213,12 +209,11 @@ ZEND_API void zend_register_string_constant(char *name, uint name_len, char *str
213209
}
214210

215211

216-
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result)
212+
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC)
217213
{
218214
zend_constant *c;
219215
char *lookup_name = estrndup(name,name_len);
220216
int retval;
221-
TSRMLS_FETCH();
222217

223218
zend_str_tolower(lookup_name, name_len);
224219

Zend/zend_constants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ typedef struct _zend_constant {
4444
#define REGISTER_MAIN_STRING_CONSTANT(name,str,flags) zend_register_string_constant((name),sizeof(name),(str),(flags),0 TSRMLS_CC)
4545
#define REGISTER_MAIN_STRINGL_CONSTANT(name,str,len,flags) zend_register_stringl_constant((name),sizeof(name),(str),(len),(flags),0 TSRMLS_CC)
4646

47-
void clean_module_constants(int module_number);
47+
void clean_module_constants(int module_number TSRMLS_DC);
4848
void free_zend_constant(zend_constant *c);
4949
int zend_startup_constants(TSRMLS_D);
5050
int zend_shutdown_constants(TSRMLS_D);
5151
void zend_register_standard_constants(TSRMLS_D);
52-
void clean_non_persistent_constants(void);
53-
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result);
52+
void clean_non_persistent_constants(TSRMLS_D);
53+
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC);
5454
ZEND_API void zend_register_long_constant(char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC);
5555
ZEND_API void zend_register_double_constant(char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC);
5656
ZEND_API void zend_register_string_constant(char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC);

Zend/zend_execute.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ binary_assign_op_addr: {
17691769
zval **param;
17701770

17711771
if (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param TSRMLS_CC)==FAILURE) {
1772-
zend_error(E_WARNING, "Missing argument %d for %s()\n", opline->op1.u.constant.value.lval, get_active_function_name());
1772+
zend_error(E_WARNING, "Missing argument %d for %s()\n", opline->op1.u.constant.value.lval, get_active_function_name(TSRMLS_C));
17731773
if (opline->result.op_type == IS_VAR) {
17741774
PZVAL_UNLOCK(*Ts[opline->result.u.var].var.ptr_ptr);
17751775
}
@@ -1921,7 +1921,7 @@ binary_assign_op_addr: {
19211921
}
19221922
NEXT_OPCODE();
19231923
case ZEND_FETCH_CONSTANT:
1924-
if (!zend_get_constant(opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, &Ts[opline->result.u.var].tmp_var)) {
1924+
if (!zend_get_constant(opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, &Ts[opline->result.u.var].tmp_var TSRMLS_CC)) {
19251925
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
19261926
opline->op1.u.constant.value.str.val,
19271927
opline->op1.u.constant.value.str.val);
@@ -2036,7 +2036,6 @@ binary_assign_op_addr: {
20362036
int return_value_used;
20372037
zval *inc_filename = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
20382038
zval tmp_inc_filename;
2039-
TSRMLS_FETCH();
20402039

20412040
if (inc_filename->type!=IS_STRING) {
20422041
tmp_inc_filename = *inc_filename;

Zend/zend_execute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ void execute_new_code(TSRMLS_D);
132132

133133

134134
/* services */
135-
ZEND_API char *get_active_function_name(void);
135+
ZEND_API char *get_active_function_name(TSRMLS_D);
136136
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
137137
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
138-
ZEND_API zend_bool zend_is_executing(void);
138+
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
139139

140140
ZEND_API void zend_set_timeout(long seconds);
141-
ZEND_API void zend_unset_timeout(void);
141+
ZEND_API void zend_unset_timeout(TSRMLS_D);
142142
ZEND_API void zend_timeout(int dummy);
143143

144144
#ifdef ZEND_WIN32

0 commit comments

Comments
 (0)