first shot remove TSRMLS_* things

This commit is contained in:
Anatol Belski 2014-12-13 23:06:14 +01:00
parent bb66f385d0
commit bdeb220f48
786 changed files with 27049 additions and 27411 deletions

View file

@ -40,7 +40,7 @@ static ts_rsrc_id win32_globals_id;
static tsrm_win32_globals win32_globals; static tsrm_win32_globals win32_globals;
#endif #endif
static void tsrm_win32_ctor(tsrm_win32_globals *globals TSRMLS_DC) static void tsrm_win32_ctor(tsrm_win32_globals *globals)
{ {
#ifdef ZTS #ifdef ZTS
TSRMLS_CACHE_UPDATE; TSRMLS_CACHE_UPDATE;
@ -62,7 +62,7 @@ TSRMLS_CACHE_UPDATE;
globals->impersonation_token_sid = NULL; globals->impersonation_token_sid = NULL;
} }
static void tsrm_win32_dtor(tsrm_win32_globals *globals TSRMLS_DC) static void tsrm_win32_dtor(tsrm_win32_globals *globals)
{ {
shm_pair *ptr; shm_pair *ptr;
@ -95,18 +95,18 @@ TSRM_API void tsrm_win32_startup(void)
#ifdef ZTS #ifdef ZTS
ts_allocate_id(&win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_ctor)tsrm_win32_dtor); ts_allocate_id(&win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_ctor)tsrm_win32_dtor);
#else #else
tsrm_win32_ctor(&win32_globals TSRMLS_CC); tsrm_win32_ctor(&win32_globals);
#endif #endif
} }
TSRM_API void tsrm_win32_shutdown(void) TSRM_API void tsrm_win32_shutdown(void)
{ {
#ifndef ZTS #ifndef ZTS
tsrm_win32_dtor(&win32_globals TSRMLS_CC); tsrm_win32_dtor(&win32_globals);
#endif #endif
} }
char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC) char * tsrm_win32_get_path_sid_key(const char *pathname)
{ {
PSID pSid = TWG(impersonation_token_sid); PSID pSid = TWG(impersonation_token_sid);
TCHAR *ptcSid = NULL; TCHAR *ptcSid = NULL;
@ -194,7 +194,7 @@ Finished:
return NULL; return NULL;
} }
TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC) TSRM_API int tsrm_win32_access(const char *pathname, int mode)
{ {
time_t t; time_t t;
HANDLE thread_token = NULL; HANDLE thread_token = NULL;
@ -217,7 +217,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
} else { } else {
if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) { if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) {
real_path = (char *)malloc(MAX_PATH); real_path = (char *)malloc(MAX_PATH);
if(tsrm_realpath(pathname, real_path TSRMLS_CC) == NULL) { if(tsrm_realpath(pathname, real_path) == NULL) {
goto Finished; goto Finished;
} }
pathname = real_path; pathname = real_path;
@ -281,14 +281,14 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
if (CWDG(realpath_cache_size_limit)) { if (CWDG(realpath_cache_size_limit)) {
t = time(0); t = time(0);
bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t TSRMLS_CC); bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t);
if(bucket == NULL && real_path == NULL) { if(bucket == NULL && real_path == NULL) {
/* We used the pathname directly. Call tsrm_realpath */ /* We used the pathname directly. Call tsrm_realpath */
/* so that entry is created in realpath cache */ /* so that entry is created in realpath cache */
real_path = (char *)malloc(MAX_PATH); real_path = (char *)malloc(MAX_PATH);
if(tsrm_realpath(pathname, real_path TSRMLS_CC) != NULL) { if(tsrm_realpath(pathname, real_path) != NULL) {
pathname = real_path; pathname = real_path;
bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t TSRMLS_CC); bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t);
} }
} }
} }
@ -383,7 +383,7 @@ Finished:
} }
static process_pair *process_get(FILE *stream TSRMLS_DC) static process_pair *process_get(FILE *stream)
{ {
process_pair *ptr; process_pair *ptr;
process_pair *newptr; process_pair *newptr;
@ -413,7 +413,6 @@ static shm_pair *shm_get(int key, void *addr)
{ {
shm_pair *ptr; shm_pair *ptr;
shm_pair *newptr; shm_pair *newptr;
TSRMLS_FETCH();
for (ptr = TWG(shm); ptr < (TWG(shm) + TWG(shm_size)); ptr++) { for (ptr = TWG(shm); ptr < (TWG(shm) + TWG(shm_size)); ptr++) {
if (!ptr->descriptor) { if (!ptr->descriptor) {
@ -451,12 +450,11 @@ static HANDLE dupHandle(HANDLE fh, BOOL inherit) {
TSRM_API FILE *popen(const char *command, const char *type) TSRM_API FILE *popen(const char *command, const char *type)
{ {
TSRMLS_FETCH();
return popen_ex(command, type, NULL, NULL TSRMLS_CC); return popen_ex(command, type, NULL, NULL);
} }
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env TSRMLS_DC) TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env)
{ {
FILE *stream = NULL; FILE *stream = NULL;
int fno, type_len, read, mode; int fno, type_len, read, mode;
@ -553,7 +551,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
} }
CloseHandle(process.hThread); CloseHandle(process.hThread);
proc = process_get(NULL TSRMLS_CC); proc = process_get(NULL);
if (read) { if (read) {
fno = _open_osfhandle((tsrm_intptr_t)in, _O_RDONLY | mode); fno = _open_osfhandle((tsrm_intptr_t)in, _O_RDONLY | mode);
@ -573,9 +571,8 @@ TSRM_API int pclose(FILE *stream)
{ {
DWORD termstat = 0; DWORD termstat = 0;
process_pair *process; process_pair *process;
TSRMLS_FETCH();
if ((process = process_get(stream TSRMLS_CC)) == NULL) { if ((process = process_get(stream)) == NULL) {
return 0; return 0;
} }

View file

@ -94,15 +94,15 @@ TSRMLS_CACHE_EXTERN;
#define SHM_RND FILE_MAP_WRITE #define SHM_RND FILE_MAP_WRITE
#define SHM_REMAP FILE_MAP_COPY #define SHM_REMAP FILE_MAP_COPY
char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC); char * tsrm_win32_get_path_sid_key(const char *pathname );
TSRM_API void tsrm_win32_startup(void); TSRM_API void tsrm_win32_startup(void);
TSRM_API void tsrm_win32_shutdown(void); TSRM_API void tsrm_win32_shutdown(void);
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env TSRMLS_DC); TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
TSRM_API FILE *popen(const char *command, const char *type); TSRM_API FILE *popen(const char *command, const char *type);
TSRM_API int pclose(FILE *stream); TSRM_API int pclose(FILE *stream);
TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC); TSRM_API int tsrm_win32_access(const char *pathname, int mode);
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf); TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
TSRM_API int shmget(int key, int size, int flags); TSRM_API int shmget(int key, int size, int flags);

View file

@ -48,20 +48,20 @@
ZEND_API zend_class_entry *zend_standard_class_def = NULL; ZEND_API zend_class_entry *zend_standard_class_def = NULL;
ZEND_API size_t (*zend_printf)(const char *format, ...); ZEND_API size_t (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write; ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC); ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
ZEND_API void (*zend_block_interruptions)(void); ZEND_API void (*zend_block_interruptions)(void);
ZEND_API void (*zend_unblock_interruptions)(void); ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC); ZEND_API void (*zend_ticks_function)(int ticks);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap); size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap); zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC); ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC); ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len);
void (*zend_on_timeout)(int seconds TSRMLS_DC); void (*zend_on_timeout)(int seconds);
static void (*zend_message_dispatcher_p)(zend_long message, const void *data TSRMLS_DC); static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
static zval *(*zend_get_configuration_directive_p)(zend_string *name); static zval *(*zend_get_configuration_directive_p)(zend_string *name);
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */ static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
@ -77,10 +77,10 @@ static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */ static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
{ {
OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
if (GC_G(gc_enabled)) { if (GC_G(gc_enabled)) {
gc_init(TSRMLS_C); gc_init();
} }
return SUCCESS; return SUCCESS;
@ -92,10 +92,10 @@ static ZEND_INI_MH(OnUpdateScriptEncoding) /* {{{ */
if (!CG(multibyte)) { if (!CG(multibyte)) {
return FAILURE; return FAILURE;
} }
if (!zend_multibyte_get_functions(TSRMLS_C)) { if (!zend_multibyte_get_functions()) {
return SUCCESS; return SUCCESS;
} }
return zend_multibyte_set_script_encoding_by_string(new_value->val, new_value->len TSRMLS_CC); return zend_multibyte_set_script_encoding_by_string(new_value->val, new_value->len);
} }
/* }}} */ /* }}} */
@ -131,7 +131,7 @@ static uint zend_version_info_length;
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2014 Zend Technologies\n" #define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2014 Zend Technologies\n"
#define PRINT_ZVAL_INDENT 4 #define PRINT_ZVAL_INDENT 4
static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, zend_bool is_object TSRMLS_DC) /* {{{ */ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
{ {
zval *tmp; zval *tmp;
zend_string *string_key; zend_string *string_key;
@ -179,7 +179,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
ZEND_PUTS_EX(key); ZEND_PUTS_EX(key);
} }
ZEND_PUTS_EX("] => "); ZEND_PUTS_EX("] => ");
zend_print_zval_r_ex(write_func, tmp, indent+PRINT_ZVAL_INDENT TSRMLS_CC); zend_print_zval_r_ex(write_func, tmp, indent+PRINT_ZVAL_INDENT);
ZEND_PUTS_EX("\n"); ZEND_PUTS_EX("\n");
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
indent -= PRINT_ZVAL_INDENT; indent -= PRINT_ZVAL_INDENT;
@ -190,7 +190,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
} }
/* }}} */ /* }}} */
static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */ static void print_flat_hash(HashTable *ht) /* {{{ */
{ {
zval *tmp; zval *tmp;
zend_string *string_key; zend_string *string_key;
@ -208,29 +208,29 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
zend_printf(ZEND_ULONG_FMT, num_key); zend_printf(ZEND_ULONG_FMT, num_key);
} }
ZEND_PUTS("] => "); ZEND_PUTS("] => ");
zend_print_flat_zval_r(tmp TSRMLS_CC); zend_print_flat_zval_r(tmp);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
} }
/* }}} */ /* }}} */
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy TSRMLS_DC) /* {{{ */ ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
{ {
if (Z_TYPE_P(expr) == IS_STRING) { if (Z_TYPE_P(expr) == IS_STRING) {
return 0; return 0;
} else { } else {
ZVAL_STR(expr_copy, _zval_get_string_func(expr TSRMLS_CC)); ZVAL_STR(expr_copy, _zval_get_string_func(expr));
return 1; return 1;
} }
} }
/* }}} */ /* }}} */
ZEND_API size_t zend_print_zval(zval *expr, int indent TSRMLS_DC) /* {{{ */ ZEND_API size_t zend_print_zval(zval *expr, int indent) /* {{{ */
{ {
return zend_print_zval_ex(zend_write, expr, indent TSRMLS_CC); return zend_print_zval_ex(zend_write, expr, indent);
} }
/* }}} */ /* }}} */
ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */ ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
{ {
zend_string *str = zval_get_string(expr); zend_string *str = zval_get_string(expr);
size_t len = str->len; size_t len = str->len;
@ -244,7 +244,7 @@ ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int
} }
/* }}} */ /* }}} */
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
{ {
switch (Z_TYPE_P(expr)) { switch (Z_TYPE_P(expr)) {
case IS_ARRAY: case IS_ARRAY:
@ -255,7 +255,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
Z_ARRVAL_P(expr)->u.v.nApplyCount--; Z_ARRVAL_P(expr)->u.v.nApplyCount--;
return; return;
} }
print_flat_hash(Z_ARRVAL_P(expr) TSRMLS_CC); print_flat_hash(Z_ARRVAL_P(expr));
ZEND_PUTS(")"); ZEND_PUTS(")");
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) { if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
Z_ARRVAL_P(expr)->u.v.nApplyCount--; Z_ARRVAL_P(expr)->u.v.nApplyCount--;
@ -264,7 +264,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
case IS_OBJECT: case IS_OBJECT:
{ {
HashTable *properties = NULL; HashTable *properties = NULL;
zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr) TSRMLS_CC); zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
zend_printf("%s Object (", class_name->val); zend_printf("%s Object (", class_name->val);
zend_string_release(class_name); zend_string_release(class_name);
@ -277,26 +277,26 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
properties->u.v.nApplyCount--; properties->u.v.nApplyCount--;
return; return;
} }
print_flat_hash(properties TSRMLS_CC); print_flat_hash(properties);
properties->u.v.nApplyCount--; properties->u.v.nApplyCount--;
} }
ZEND_PUTS(")"); ZEND_PUTS(")");
break; break;
} }
default: default:
zend_print_variable(expr TSRMLS_CC); zend_print_variable(expr);
break; break;
} }
} }
/* }}} */ /* }}} */
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC) /* {{{ */ ZEND_API void zend_print_zval_r(zval *expr, int indent) /* {{{ */
{ {
zend_print_zval_r_ex(zend_write, expr, indent TSRMLS_CC); zend_print_zval_r_ex(zend_write, expr, indent);
} }
/* }}} */ /* }}} */
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
{ {
ZVAL_DEREF(expr); ZVAL_DEREF(expr);
switch (Z_TYPE_P(expr)) { switch (Z_TYPE_P(expr)) {
@ -308,7 +308,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
Z_ARRVAL_P(expr)->u.v.nApplyCount--; Z_ARRVAL_P(expr)->u.v.nApplyCount--;
return; return;
} }
print_hash(write_func, Z_ARRVAL_P(expr), indent, 0 TSRMLS_CC); print_hash(write_func, Z_ARRVAL_P(expr), indent, 0);
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) { if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
Z_ARRVAL_P(expr)->u.v.nApplyCount--; Z_ARRVAL_P(expr)->u.v.nApplyCount--;
} }
@ -318,7 +318,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
HashTable *properties; HashTable *properties;
int is_temp; int is_temp;
zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr) TSRMLS_CC); zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
ZEND_PUTS_EX(class_name->val); ZEND_PUTS_EX(class_name->val);
zend_string_release(class_name); zend_string_release(class_name);
@ -331,7 +331,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
properties->u.v.nApplyCount--; properties->u.v.nApplyCount--;
return; return;
} }
print_hash(write_func, properties, indent, 1 TSRMLS_CC); print_hash(write_func, properties, indent, 1);
properties->u.v.nApplyCount--; properties->u.v.nApplyCount--;
if (is_temp) { if (is_temp) {
zend_hash_destroy(properties); zend_hash_destroy(properties);
@ -340,13 +340,13 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
break; break;
} }
default: default:
zend_print_zval_ex(write_func, expr, indent TSRMLS_CC); zend_print_zval_ex(write_func, expr, indent);
break; break;
} }
} }
/* }}} */ /* }}} */
static FILE *zend_fopen_wrapper(const char *filename, char **opened_path TSRMLS_DC) /* {{{ */ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path) /* {{{ */
{ {
if (opened_path) { if (opened_path) {
*opened_path = estrdup(filename); *opened_path = estrdup(filename);
@ -363,7 +363,7 @@ static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
# define compiler_options_default ZEND_COMPILE_DEFAULT # define compiler_options_default ZEND_COMPILE_DEFAULT
#endif #endif
static void zend_set_default_compile_time_values(TSRMLS_D) /* {{{ */ static void zend_set_default_compile_time_values(void) /* {{{ */
{ {
/* default compile-time values */ /* default compile-time values */
CG(short_tags) = short_tags_default; CG(short_tags) = short_tags_default;
@ -371,7 +371,7 @@ static void zend_set_default_compile_time_values(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
static void zend_init_exception_op(TSRMLS_D) /* {{{ */ static void zend_init_exception_op(void) /* {{{ */
{ {
memset(EG(exception_op), 0, sizeof(EG(exception_op))); memset(EG(exception_op), 0, sizeof(EG(exception_op)));
EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION; EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION;
@ -401,7 +401,7 @@ static void function_copy_ctor(zval *zv)
function_add_ref(Z_FUNC_P(zv)); function_add_ref(Z_FUNC_P(zv));
} }
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{{ */
{ {
compiler_globals->compiled_filename = NULL; compiler_globals->compiled_filename = NULL;
@ -413,7 +413,7 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0); zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref); zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref);
zend_set_default_compile_time_values(TSRMLS_C); zend_set_default_compile_time_values();
compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0); zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
@ -428,14 +428,14 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
compiler_globals->script_encoding_list = NULL; compiler_globals->script_encoding_list = NULL;
#ifdef ZTS #ifdef ZTS
zend_interned_empty_string_init(&compiler_globals->empty_string TSRMLS_CC); zend_interned_empty_string_init(&compiler_globals->empty_string);
memset(compiler_globals->one_char_string, 0, sizeof(compiler_globals->one_char_string)); memset(compiler_globals->one_char_string, 0, sizeof(compiler_globals->one_char_string));
#endif #endif
} }
/* }}} */ /* }}} */
static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{{ */
{ {
if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) { if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) {
zend_hash_destroy(compiler_globals->function_table); zend_hash_destroy(compiler_globals->function_table);
@ -458,18 +458,18 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS
compiler_globals->last_static_member = 0; compiler_globals->last_static_member = 0;
#ifdef ZTS #ifdef ZTS
zend_interned_empty_string_free(&compiler_globals->empty_string TSRMLS_CC); zend_interned_empty_string_free(&compiler_globals->empty_string);
#endif #endif
} }
/* }}} */ /* }}} */
static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC) /* {{{ */ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
{ {
ZEND_TSRMLS_CACHE_UPDATE; ZEND_TSRMLS_CACHE_UPDATE;
zend_startup_constants(TSRMLS_C); zend_startup_constants();
zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE); zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
zend_init_rsrc_plist(TSRMLS_C); zend_init_rsrc_plist();
zend_init_exception_op(TSRMLS_C); zend_init_exception_op();
EG(lambda_count) = 0; EG(lambda_count) = 0;
ZVAL_UNDEF(&EG(user_error_handler)); ZVAL_UNDEF(&EG(user_error_handler));
ZVAL_UNDEF(&EG(user_exception_handler)); ZVAL_UNDEF(&EG(user_exception_handler));
@ -485,11 +485,11 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
} }
/* }}} */ /* }}} */
static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC) /* {{{ */ static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{{ */
{ {
zend_ini_shutdown(TSRMLS_C); zend_ini_shutdown();
if (&executor_globals->persistent_list != global_persistent_list) { if (&executor_globals->persistent_list != global_persistent_list) {
zend_destroy_rsrc_list(&executor_globals->persistent_list TSRMLS_CC); zend_destroy_rsrc_list(&executor_globals->persistent_list);
} }
if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) { if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) {
zend_hash_destroy(executor_globals->zend_constants); zend_hash_destroy(executor_globals->zend_constants);
@ -498,10 +498,10 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS
} }
/* }}} */ /* }}} */
static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC) /* {{{ */ static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */
{ {
if (zend_copy_ini_directives(TSRMLS_C) == SUCCESS) { if (zend_copy_ini_directives() == SUCCESS) {
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC); zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
} }
} }
/* }}} */ /* }}} */
@ -512,13 +512,13 @@ static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC) /* {{{ */
#include <floatingpoint.h> #include <floatingpoint.h>
#endif #endif
static void ini_scanner_globals_ctor(zend_ini_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */ static void ini_scanner_globals_ctor(zend_ini_scanner_globals *scanner_globals_p) /* {{{ */
{ {
memset(scanner_globals_p, 0, sizeof(*scanner_globals_p)); memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
} }
/* }}} */ /* }}} */
static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */ static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p) /* {{{ */
{ {
memset(scanner_globals_p, 0, sizeof(*scanner_globals_p)); memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
} }
@ -541,7 +541,7 @@ static void auto_global_dtor(zval *zv) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_bool php_auto_globals_create_globals(zend_string *name TSRMLS_DC) /* {{{ */ static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
{ {
zval globals; zval globals;
@ -552,7 +552,7 @@ static zend_bool php_auto_globals_create_globals(zend_string *name TSRMLS_DC) /*
} }
/* }}} */ /* }}} */
int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC) /* {{{ */ int zend_startup(zend_utility_functions *utility_functions, char **extensions) /* {{{ */
{ {
#ifdef ZTS #ifdef ZTS
zend_compiler_globals *compiler_globals; zend_compiler_globals *compiler_globals;
@ -566,7 +566,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS
ZEND_TSRMLS_CACHE_UPDATE; ZEND_TSRMLS_CACHE_UPDATE;
#endif #endif
start_memory_manager(TSRMLS_C); start_memory_manager();
virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */ virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */
@ -640,7 +640,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS
compiler_globals = ts_resource(compiler_globals_id); compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id); executor_globals = ts_resource(executor_globals_id);
compiler_globals_dtor(compiler_globals TSRMLS_CC); compiler_globals_dtor(compiler_globals);
compiler_globals->in_compilation = 0; compiler_globals->in_compilation = 0;
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
@ -652,24 +652,24 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS
zend_hash_destroy(executor_globals->zend_constants); zend_hash_destroy(executor_globals->zend_constants);
*executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE; *executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE;
#else #else
ini_scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC); ini_scanner_globals_ctor(&ini_scanner_globals);
php_scanner_globals_ctor(&language_scanner_globals TSRMLS_CC); php_scanner_globals_ctor(&language_scanner_globals);
zend_set_default_compile_time_values(TSRMLS_C); zend_set_default_compile_time_values();
ZVAL_UNDEF(&EG(user_error_handler)); ZVAL_UNDEF(&EG(user_error_handler));
ZVAL_UNDEF(&EG(user_exception_handler)); ZVAL_UNDEF(&EG(user_exception_handler));
#endif #endif
zend_interned_strings_init(TSRMLS_C); zend_interned_strings_init();
zend_startup_builtin_functions(TSRMLS_C); zend_startup_builtin_functions();
zend_register_standard_constants(TSRMLS_C); zend_register_standard_constants();
zend_register_auto_global(zend_string_init("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals TSRMLS_CC); zend_register_auto_global(zend_string_init("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals);
#ifndef ZTS #ifndef ZTS
zend_init_rsrc_plist(TSRMLS_C); zend_init_rsrc_plist();
zend_init_exception_op(TSRMLS_C); zend_init_exception_op();
#endif #endif
zend_ini_startup(TSRMLS_C); zend_ini_startup();
#ifdef ZTS #ifdef ZTS
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler); tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
@ -679,7 +679,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS
} }
/* }}} */ /* }}} */
void zend_register_standard_ini_entries(TSRMLS_D) /* {{{ */ void zend_register_standard_ini_entries(void) /* {{{ */
{ {
int module_number = 0; int module_number = 0;
@ -690,7 +690,7 @@ void zend_register_standard_ini_entries(TSRMLS_D) /* {{{ */
/* Unlink the global (r/o) copies of the class, function and constant tables, /* Unlink the global (r/o) copies of the class, function and constant tables,
* and use a fresh r/w copy for the startup thread * and use a fresh r/w copy for the startup thread
*/ */
void zend_post_startup(TSRMLS_D) /* {{{ */ void zend_post_startup(void) /* {{{ */
{ {
#ifdef ZTS #ifdef ZTS
zend_encoding **script_encoding_list; zend_encoding **script_encoding_list;
@ -705,34 +705,34 @@ void zend_post_startup(TSRMLS_D) /* {{{ */
short_tags_default = CG(short_tags); short_tags_default = CG(short_tags);
compiler_options_default = CG(compiler_options); compiler_options_default = CG(compiler_options);
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); zend_destroy_rsrc_list(&EG(persistent_list));
free(compiler_globals->function_table); free(compiler_globals->function_table);
free(compiler_globals->class_table); free(compiler_globals->class_table);
if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) { if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) {
compiler_globals_ctor(compiler_globals TSRMLS_CC); compiler_globals_ctor(compiler_globals);
compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list; compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list;
} else { } else {
compiler_globals_ctor(compiler_globals TSRMLS_CC); compiler_globals_ctor(compiler_globals);
} }
free(EG(zend_constants)); free(EG(zend_constants));
virtual_cwd_deactivate(TSRMLS_C); virtual_cwd_deactivate();
executor_globals_ctor(executor_globals TSRMLS_CC); executor_globals_ctor(executor_globals);
global_persistent_list = &EG(persistent_list); global_persistent_list = &EG(persistent_list);
zend_copy_ini_directives(TSRMLS_C); zend_copy_ini_directives();
#else #else
virtual_cwd_deactivate(TSRMLS_C); virtual_cwd_deactivate();
#endif #endif
} }
/* }}} */ /* }}} */
void zend_shutdown(TSRMLS_D) /* {{{ */ void zend_shutdown(void) /* {{{ */
{ {
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
zend_signal_shutdown(TSRMLS_C); zend_signal_shutdown();
#endif #endif
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); zend_destroy_rsrc_list(&EG(persistent_list));
if (EG(active)) if (EG(active))
{ {
/* /*
@ -749,18 +749,18 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_CLASS_TABLE, ce) { ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_CLASS_TABLE, ce) {
if (ce->type == ZEND_USER_CLASS) { if (ce->type == ZEND_USER_CLASS) {
zend_cleanup_user_class_data(ce TSRMLS_CC); zend_cleanup_user_class_data(ce);
} else { } else {
break; break;
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
zend_cleanup_internal_classes(TSRMLS_C); zend_cleanup_internal_classes();
zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full TSRMLS_CC); zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full);
zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full TSRMLS_CC); zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full);
} }
zend_destroy_modules(); zend_destroy_modules();
virtual_cwd_deactivate(TSRMLS_C); virtual_cwd_deactivate();
virtual_cwd_shutdown(); virtual_cwd_shutdown();
zend_hash_destroy(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
@ -769,7 +769,7 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE); zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
free(GLOBAL_AUTO_GLOBALS_TABLE); free(GLOBAL_AUTO_GLOBALS_TABLE);
zend_shutdown_extensions(TSRMLS_C); zend_shutdown_extensions();
free(zend_version_info); free(zend_version_info);
free(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE);
@ -787,7 +787,7 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
#endif #endif
zend_destroy_rsrc_list_dtors(); zend_destroy_rsrc_list_dtors();
zend_interned_strings_dtor(TSRMLS_C); zend_interned_strings_dtor();
} }
/* }}} */ /* }}} */
@ -808,7 +808,6 @@ void zenderror(const char *error) /* {{{ */
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
{ {
TSRMLS_FETCH();
if (!EG(bailout)) { if (!EG(bailout)) {
zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno); zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
@ -851,47 +850,47 @@ ZEND_API char *get_zend_version(void) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_activate(TSRMLS_D) /* {{{ */ ZEND_API void zend_activate(void) /* {{{ */
{ {
#ifdef ZTS #ifdef ZTS
virtual_cwd_activate(TSRMLS_C); virtual_cwd_activate();
#endif #endif
gc_reset(TSRMLS_C); gc_reset();
init_compiler(TSRMLS_C); init_compiler();
init_executor(TSRMLS_C); init_executor();
startup_scanner(TSRMLS_C); startup_scanner();
} }
/* }}} */ /* }}} */
void zend_call_destructors(TSRMLS_D) /* {{{ */ void zend_call_destructors(void) /* {{{ */
{ {
zend_try { zend_try {
shutdown_destructors(TSRMLS_C); shutdown_destructors();
} zend_end_try(); } zend_end_try();
} }
/* }}} */ /* }}} */
ZEND_API void zend_deactivate(TSRMLS_D) /* {{{ */ ZEND_API void zend_deactivate(void) /* {{{ */
{ {
/* we're no longer executing anything */ /* we're no longer executing anything */
EG(current_execute_data) = NULL; EG(current_execute_data) = NULL;
zend_try { zend_try {
shutdown_scanner(TSRMLS_C); shutdown_scanner();
} zend_end_try(); } zend_end_try();
/* shutdown_executor() takes care of its own bailout handling */ /* shutdown_executor() takes care of its own bailout handling */
shutdown_executor(TSRMLS_C); shutdown_executor();
zend_try { zend_try {
shutdown_compiler(TSRMLS_C); shutdown_compiler();
} zend_end_try(); } zend_end_try();
zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC); zend_destroy_rsrc_list(&EG(regular_list));
#if ZEND_DEBUG #if ZEND_DEBUG
if (GC_G(gc_enabled) && !CG(unclean_shutdown)) { if (GC_G(gc_enabled) && !CG(unclean_shutdown)) {
gc_collect_cycles(TSRMLS_C); gc_collect_cycles();
} }
#endif #endif
@ -910,16 +909,16 @@ ZEND_API void zend_deactivate(TSRMLS_D) /* {{{ */
#endif #endif
zend_try { zend_try {
zend_ini_deactivate(TSRMLS_C); zend_ini_deactivate();
} zend_end_try(); } zend_end_try();
} }
/* }}} */ /* }}} */
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(zend_long message, const void *data TSRMLS_DC) /* {{{ */ ZEND_API void zend_message_dispatcher(zend_long message, const void *data) /* {{{ */
{ {
if (zend_message_dispatcher_p) { if (zend_message_dispatcher_p) {
zend_message_dispatcher_p(message, data TSRMLS_CC); zend_message_dispatcher_p(message, data);
} }
} }
/* }}} */ /* }}} */
@ -975,7 +974,6 @@ static void zend_error_va_list(int type, const char *format, va_list args)
zend_stack delayed_oplines_stack; zend_stack delayed_oplines_stack;
zend_stack context_stack; zend_stack context_stack;
zend_array *symbol_table; zend_array *symbol_table;
TSRMLS_FETCH();
/* Report about uncaught exception in case of fatal errors */ /* Report about uncaught exception in case of fatal errors */
if (EG(exception)) { if (EG(exception)) {
@ -998,7 +996,7 @@ static void zend_error_va_list(int type, const char *format, va_list args)
EG(opline_before_exception)) { EG(opline_before_exception)) {
opline = EG(opline_before_exception); opline = EG(opline_before_exception);
} }
zend_exception_error(EG(exception), E_WARNING TSRMLS_CC); zend_exception_error(EG(exception), E_WARNING);
EG(exception) = NULL; EG(exception) = NULL;
if (opline) { if (opline) {
ex->opline = opline; ex->opline = opline;
@ -1029,16 +1027,16 @@ static void zend_error_va_list(int type, const char *format, va_list args)
case E_USER_NOTICE: case E_USER_NOTICE:
case E_USER_DEPRECATED: case E_USER_DEPRECATED:
case E_RECOVERABLE_ERROR: case E_RECOVERABLE_ERROR:
if (zend_is_compiling(TSRMLS_C)) { if (zend_is_compiling()) {
error_filename = zend_get_compiled_filename(TSRMLS_C)->val; error_filename = zend_get_compiled_filename()->val;
error_lineno = zend_get_compiled_lineno(TSRMLS_C); error_lineno = zend_get_compiled_lineno();
} else if (zend_is_executing(TSRMLS_C)) { } else if (zend_is_executing()) {
error_filename = zend_get_executed_filename(TSRMLS_C); error_filename = zend_get_executed_filename();
if (error_filename[0] == '[') { /* [no active file] */ if (error_filename[0] == '[') { /* [no active file] */
error_filename = NULL; error_filename = NULL;
error_lineno = 0; error_lineno = 0;
} else { } else {
error_lineno = zend_get_executed_lineno(TSRMLS_C); error_lineno = zend_get_executed_lineno();
} }
} else { } else {
error_filename = NULL; error_filename = NULL;
@ -1115,7 +1113,7 @@ static void zend_error_va_list(int type, const char *format, va_list args)
ZVAL_LONG(&params[3], error_lineno); ZVAL_LONG(&params[3], error_lineno);
symbol_table = zend_rebuild_symbol_table(TSRMLS_C); symbol_table = zend_rebuild_symbol_table();
/* during shutdown the symbol table table can be still null */ /* during shutdown the symbol table table can be still null */
if (!symbol_table) { if (!symbol_table) {
@ -1144,7 +1142,7 @@ static void zend_error_va_list(int type, const char *format, va_list args)
} }
ZVAL_UNDEF(&retval); ZVAL_UNDEF(&retval);
if (call_user_function_ex(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC) == SUCCESS) { if (call_user_function_ex(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params, 1, NULL) == SUCCESS) {
if (Z_TYPE(retval) != IS_UNDEF) { if (Z_TYPE(retval) != IS_UNDEF) {
if (Z_TYPE(retval) == IS_FALSE) { if (Z_TYPE(retval) == IS_FALSE) {
zend_error_cb(type, error_filename, error_lineno, format, args); zend_error_cb(type, error_filename, error_lineno, format, args);
@ -1244,7 +1242,7 @@ ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *form
} }
/* }}} */ /* }}} */
ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_count, ...) /* {{{ */ ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
{ {
va_list files; va_list files;
int i; int i;
@ -1258,14 +1256,14 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
continue; continue;
} }
op_array = zend_compile_file(file_handle, type TSRMLS_CC); op_array = zend_compile_file(file_handle, type);
if (file_handle->opened_path) { if (file_handle->opened_path) {
zend_hash_str_add_empty_element(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path)); zend_hash_str_add_empty_element(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path));
} }
zend_destroy_file_handle(file_handle TSRMLS_CC); zend_destroy_file_handle(file_handle);
if (op_array) { if (op_array) {
zend_execute(op_array, retval TSRMLS_CC); zend_execute(op_array, retval);
zend_exception_restore(TSRMLS_C); zend_exception_restore();
if (EG(exception)) { if (EG(exception)) {
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
zval orig_user_exception_handler; zval orig_user_exception_handler;
@ -1276,7 +1274,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
ZVAL_OBJ(&params[0], old_exception); ZVAL_OBJ(&params[0], old_exception);
ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler)); ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
ZVAL_UNDEF(&retval2); ZVAL_UNDEF(&retval2);
if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params, 1, NULL TSRMLS_CC) == SUCCESS) { if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params, 1, NULL) == SUCCESS) {
zval_ptr_dtor(&retval2); zval_ptr_dtor(&retval2);
if (EG(exception)) { if (EG(exception)) {
OBJ_RELEASE(EG(exception)); OBJ_RELEASE(EG(exception));
@ -1285,13 +1283,13 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
OBJ_RELEASE(old_exception); OBJ_RELEASE(old_exception);
} else { } else {
EG(exception) = old_exception; EG(exception) = old_exception;
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); zend_exception_error(EG(exception), E_ERROR);
} }
} else { } else {
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); zend_exception_error(EG(exception), E_ERROR);
} }
} }
destroy_op_array(op_array TSRMLS_CC); destroy_op_array(op_array);
efree_size(op_array, sizeof(zend_op_array)); efree_size(op_array, sizeof(zend_op_array));
} else if (type==ZEND_REQUIRE) { } else if (type==ZEND_REQUIRE) {
va_end(files); va_end(files);
@ -1306,18 +1304,18 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
#define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s" #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC) /* {{{ */ ZEND_API char *zend_make_compiled_string_description(const char *name) /* {{{ */
{ {
const char *cur_filename; const char *cur_filename;
int cur_lineno; int cur_lineno;
char *compiled_string_description; char *compiled_string_description;
if (zend_is_compiling(TSRMLS_C)) { if (zend_is_compiling()) {
cur_filename = zend_get_compiled_filename(TSRMLS_C)->val; cur_filename = zend_get_compiled_filename()->val;
cur_lineno = zend_get_compiled_lineno(TSRMLS_C); cur_lineno = zend_get_compiled_lineno();
} else if (zend_is_executing(TSRMLS_C)) { } else if (zend_is_executing()) {
cur_filename = zend_get_executed_filename(TSRMLS_C); cur_filename = zend_get_executed_filename();
cur_lineno = zend_get_executed_lineno(TSRMLS_C); cur_lineno = zend_get_executed_lineno();
} else { } else {
cur_filename = "Unknown"; cur_filename = "Unknown";
cur_lineno = 0; cur_lineno = 0;

View file

@ -158,14 +158,14 @@ struct _zend_class_entry {
zend_class_iterator_funcs iterator_funcs; zend_class_iterator_funcs iterator_funcs;
/* handlers */ /* handlers */
zend_object* (*create_object)(zend_class_entry *class_type TSRMLS_DC); zend_object* (*create_object)(zend_class_entry *class_type);
zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC); zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref);
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */ int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); /* a class implements this interface */
union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method TSRMLS_DC); union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method);
/* serializer callbacks */ /* serializer callbacks */
int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data TSRMLS_DC); int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data TSRMLS_DC); int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
uint32_t num_interfaces; uint32_t num_interfaces;
uint32_t num_traits; uint32_t num_traits;
@ -193,18 +193,18 @@ typedef struct _zend_utility_functions {
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0); void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
size_t (*write_function)(const char *str, size_t str_length); size_t (*write_function)(const char *str, size_t str_length);
FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC); FILE *(*fopen_function)(const char *filename, char **opened_path);
void (*message_handler)(zend_long message, const void *data TSRMLS_DC); void (*message_handler)(zend_long message, const void *data);
void (*block_interruptions)(void); void (*block_interruptions)(void);
void (*unblock_interruptions)(void); void (*unblock_interruptions)(void);
zval *(*get_configuration_directive)(zend_string *name); zval *(*get_configuration_directive)(zend_string *name);
void (*ticks_function)(int ticks TSRMLS_DC); void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds TSRMLS_DC); void (*on_timeout)(int seconds);
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); int (*stream_open_function)(const char *filename, zend_file_handle *handle);
size_t (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap); size_t (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap); zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap);
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC); char *(*getenv_function)(char *name, size_t name_len);
char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC); char *(*resolve_path_function)(const char *filename, int filename_len);
} zend_utility_functions; } zend_utility_functions;
typedef struct _zend_utility_values { typedef struct _zend_utility_values {
@ -234,29 +234,29 @@ typedef int (*zend_write_func_t)(const char *str, size_t str_length);
#define zend_first_try EG(bailout)=NULL; zend_try #define zend_first_try EG(bailout)=NULL; zend_try
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC); int zend_startup(zend_utility_functions *utility_functions, char **extensions);
void zend_shutdown(TSRMLS_D); void zend_shutdown(void);
void zend_register_standard_ini_entries(TSRMLS_D); void zend_register_standard_ini_entries(void);
void zend_post_startup(TSRMLS_D); void zend_post_startup(void);
void zend_set_utility_values(zend_utility_values *utility_values); void zend_set_utility_values(zend_utility_values *utility_values);
ZEND_API void _zend_bailout(char *filename, uint lineno); ZEND_API void _zend_bailout(char *filename, uint lineno);
ZEND_API char *get_zend_version(void); ZEND_API char *get_zend_version(void);
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy TSRMLS_DC); ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
ZEND_API size_t zend_print_zval(zval *expr, int indent TSRMLS_DC); ZEND_API size_t zend_print_zval(zval *expr, int indent);
ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC); ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC); ZEND_API void zend_print_zval_r(zval *expr, int indent);
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC); ZEND_API void zend_print_flat_zval_r(zval *expr);
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC); ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent);
ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API void zend_activate(TSRMLS_D); ZEND_API void zend_activate(void);
ZEND_API void zend_deactivate(TSRMLS_D); ZEND_API void zend_deactivate(void);
ZEND_API void zend_call_destructors(TSRMLS_D); ZEND_API void zend_call_destructors(void);
ZEND_API void zend_activate_modules(TSRMLS_D); ZEND_API void zend_activate_modules(void);
ZEND_API void zend_deactivate_modules(TSRMLS_D); ZEND_API void zend_deactivate_modules(void);
ZEND_API void zend_post_deactivate_modules(TSRMLS_D); ZEND_API void zend_post_deactivate_modules(void);
ZEND_API void free_estring(char **str_p); ZEND_API void free_estring(char **str_p);
ZEND_API void free_string_zval(zval *zv); ZEND_API void free_string_zval(zval *zv);
@ -272,17 +272,17 @@ END_EXTERN_C()
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
extern ZEND_API size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); extern ZEND_API size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_write_func_t zend_write; extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC); extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
extern ZEND_API void (*zend_block_interruptions)(void); extern ZEND_API void (*zend_block_interruptions)(void);
extern ZEND_API void (*zend_unblock_interruptions)(void); extern ZEND_API void (*zend_unblock_interruptions)(void);
extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC); extern ZEND_API void (*zend_ticks_function)(int ticks);
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); 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);
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC); extern ZEND_API void (*zend_on_timeout)(int seconds);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
extern size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap); extern size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap); extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC); extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC); extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len);
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
@ -299,7 +299,7 @@ END_EXTERN_C()
#define ZEND_UV(name) (zend_uv.name) #define ZEND_UV(name) (zend_uv.name)
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(zend_long message, const void *data TSRMLS_DC); ZEND_API void zend_message_dispatcher(zend_long message, const void *data);
ZEND_API zval *zend_get_configuration_directive(zend_string *name); ZEND_API zval *zend_get_configuration_directive(zend_string *name);
END_EXTERN_C() END_EXTERN_C()
@ -325,9 +325,9 @@ typedef struct {
zval user_handler; zval user_handler;
} zend_error_handling; } zend_error_handling;
ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC); ZEND_API void zend_save_error_handling(zend_error_handling *current);
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC); ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current);
ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC); ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0) #define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1) #define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)

File diff suppressed because it is too large Load diff

View file

@ -129,8 +129,8 @@ typedef struct _zend_fcall_info_cache {
#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) #define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) #define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
#define ZEND_MODULE_INFO_D(module) void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS) #define ZEND_MODULE_INFO_D(module) void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
#define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals TSRMLS_DC) #define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals)
#define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals TSRMLS_DC) #define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals)
#define ZEND_GET_MODULE(name) \ #define ZEND_GET_MODULE(name) \
BEGIN_EXTERN_C()\ BEGIN_EXTERN_C()\
@ -172,7 +172,7 @@ typedef struct _zend_fcall_info_cache {
{ \ { \
zend_string *cl_name; \ zend_string *cl_name; \
cl_name = zend_string_init(class_name, class_name_len, 1); \ cl_name = zend_string_init(class_name, class_name_len, 1); \
class_container.name = zend_new_interned_string(cl_name TSRMLS_CC); \ class_container.name = zend_new_interned_string(cl_name); \
INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
} }
@ -234,59 +234,59 @@ ZEND_API int zend_next_free_module(void);
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_get_parameters(int ht, int param_count, ...); ZEND_API int zend_get_parameters(int ht, int param_count, ...);
ZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...); ZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...);
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array TSRMLS_DC); ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
/* internal function to efficiently copy parameters when executing __call() */ /* internal function to efficiently copy parameters when executing __call() */
ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array TSRMLS_DC); ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
#define zend_get_parameters_array(ht, param_count, argument_array) \ #define zend_get_parameters_array(ht, param_count, argument_array) \
_zend_get_parameters_array_ex(param_count, argument_array TSRMLS_CC) _zend_get_parameters_array_ex(param_count, argument_array)
#define zend_get_parameters_array_ex(param_count, argument_array) \ #define zend_get_parameters_array_ex(param_count, argument_array) \
_zend_get_parameters_array_ex(param_count, argument_array TSRMLS_CC) _zend_get_parameters_array_ex(param_count, argument_array)
#define zend_parse_parameters_none() \ #define zend_parse_parameters_none() \
zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") zend_parse_parameters(ZEND_NUM_ARGS(), "")
/* Parameter parsing API -- andrei */ /* Parameter parsing API -- andrei */
#define ZEND_PARSE_PARAMS_QUIET (1<<1) #define ZEND_PARSE_PARAMS_QUIET (1<<1)
ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, const char *type_spec, ...); ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, const char *type_spec, ...); ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
ZEND_API char *zend_zval_type_name(const zval *arg); ZEND_API char *zend_zval_type_name(const zval *arg);
ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...);
ZEND_API int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval *arg, const char *spec, ...); ZEND_API int zend_parse_parameter(int flags, int arg_num, zval *arg, const char *spec, ...);
/* End of parameter parsing API -- andrei */ /* End of parameter parsing API -- andrei */
ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC); ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type);
ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC); ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table);
ZEND_API int zend_startup_module(zend_module_entry *module_entry TSRMLS_DC); ZEND_API int zend_startup_module(zend_module_entry *module_entry);
ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry TSRMLS_DC); ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry);
ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TSRMLS_DC); ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module);
ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC); ZEND_API int zend_startup_module_ex(zend_module_entry *module);
ZEND_API int zend_startup_modules(TSRMLS_D); ZEND_API int zend_startup_modules(void);
ZEND_API void zend_collect_module_handlers(TSRMLS_D); ZEND_API void zend_collect_module_handlers(void);
ZEND_API void zend_destroy_modules(void); ZEND_API void zend_destroy_modules(void);
ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type TSRMLS_DC); ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type);
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC); ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce TSRMLS_DC); ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry TSRMLS_DC); ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry);
ZEND_API void zend_class_implements(zend_class_entry *class_entry TSRMLS_DC, int num_interfaces, ...); ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...);
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce TSRMLS_DC); ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce);
#define zend_register_class_alias(name, ce) \ #define zend_register_class_alias(name, ce) \
zend_register_class_alias_ex(name, sizeof(name)-1, ce TSRMLS_CC) zend_register_class_alias_ex(name, sizeof(name)-1, ce)
#define zend_register_ns_class_alias(ns, name, ce) \ #define zend_register_ns_class_alias(ns, name, ce) \
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_CC) zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce)
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length TSRMLS_DC); ZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length TSRMLS_DC); ZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
ZEND_API void zend_wrong_param_count(TSRMLS_D); ZEND_API void zend_wrong_param_count(void);
#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0) #define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
#define IS_CALLABLE_CHECK_NO_ACCESS (1<<1) #define IS_CALLABLE_CHECK_NO_ACCESS (1<<1)
@ -295,49 +295,49 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D);
#define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC) #define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC)
ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error);
ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name TSRMLS_DC); ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name);
ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name TSRMLS_DC); ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name);
ZEND_API const char *zend_get_module_version(const char *module_name); ZEND_API const char *zend_get_module_version(const char *module_name);
ZEND_API int zend_get_module_started(const char *module_name); ZEND_API int zend_get_module_started(const char *module_name);
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC); ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment);
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type TSRMLS_DC); ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type);
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type);
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC); ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value);
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC); ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length);
ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value TSRMLS_DC); ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value);
ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value TSRMLS_DC); ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value);
ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value TSRMLS_DC); ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value);
ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC); ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length);
ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value TSRMLS_DC); ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value);
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC); ZEND_API void zend_update_class_constants(zend_class_entry *class_type);
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value TSRMLS_DC); ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value);
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length TSRMLS_DC); ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length);
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC); ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value TSRMLS_DC); ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value TSRMLS_DC); ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value);
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value TSRMLS_DC); ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value);
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value TSRMLS_DC); ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value);
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC); ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length);
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value TSRMLS_DC); ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length TSRMLS_DC); ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC); ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value TSRMLS_DC); ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value TSRMLS_DC); ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value);
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value TSRMLS_DC); ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC); ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length);
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent TSRMLS_DC); ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent TSRMLS_DC); ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
ZEND_API char *zend_get_type_by_const(int type); ZEND_API char *zend_get_type_by_const(int type);
@ -348,8 +348,8 @@ ZEND_API char *zend_get_type_by_const(int type);
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
#define ARG_COUNT(dummy) EX_NUM_ARGS() #define ARG_COUNT(dummy) EX_NUM_ARGS()
#define ZEND_NUM_ARGS() EX_NUM_ARGS() #define ZEND_NUM_ARGS() EX_NUM_ARGS()
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; } #define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(); return; }
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; } #define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(); return ret; }
#ifndef ZEND_WIN32 #ifndef ZEND_WIN32
#define DLEXPORT #define DLEXPORT
@ -357,18 +357,18 @@ ZEND_API char *zend_get_type_by_const(int type);
#define array_init(arg) _array_init((arg), 0 ZEND_FILE_LINE_CC) #define array_init(arg) _array_init((arg), 0 ZEND_FILE_LINE_CC)
#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC) #define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC)
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC TSRMLS_CC) #define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC)
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC TSRMLS_CC) #define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC TSRMLS_CC) #define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC)
ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC); ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC);
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC); ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC); ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC); ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC);
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties TSRMLS_DC); ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties);
ZEND_API void object_properties_load(zend_object *object, HashTable *properties TSRMLS_DC); ZEND_API void object_properties_load(zend_object *object, HashTable *properties);
ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC); ZEND_API void zend_merge_properties(zval *obj, HashTable *properties);
/* no longer supported */ /* no longer supported */
ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS)); ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
@ -431,31 +431,31 @@ ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str);
ZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str); ZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str);
ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length); ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC); ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value);
ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l TSRMLS_DC); ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l);
ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len TSRMLS_DC); ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len);
ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b TSRMLS_DC); ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b);
ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r TSRMLS_DC); ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d TSRMLS_DC); ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d);
ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str TSRMLS_DC); ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str TSRMLS_DC); ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length TSRMLS_DC); ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length);
ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value TSRMLS_DC); ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n TSRMLS_CC) #define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) TSRMLS_CC) #define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b TSRMLS_CC) #define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r TSRMLS_CC) #define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d TSRMLS_CC) #define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str TSRMLS_CC) #define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str TSRMLS_CC) #define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length TSRMLS_CC) #define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value TSRMLS_CC) #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[] TSRMLS_DC); ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]);
ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC); ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table);
ZEND_API extern const zend_fcall_info empty_fcall_info; ZEND_API extern const zend_fcall_info empty_fcall_info;
ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
@ -470,7 +470,7 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
* The callable_name argument may be NULL. * The callable_name argument may be NULL.
* Set check_flags to IS_CALLABLE_STRICT for every new usage! * Set check_flags to IS_CALLABLE_STRICT for every new usage!
*/ */
ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error TSRMLS_DC); ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error);
/** Clear arguments connected with zend_fcall_info *fci /** Clear arguments connected with zend_fcall_info *fci
* If free_mem is not zero then the params array gets free'd as well * If free_mem is not zero then the params array gets free'd as well
@ -489,43 +489,43 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count
/** Set or clear the arguments in the zend_call_info struct taking care of /** Set or clear the arguments in the zend_call_info struct taking care of
* refcount. If args is NULL and arguments are set then those are cleared. * refcount. If args is NULL and arguments are set then those are cleared.
*/ */
ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC); ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args);
ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args TSRMLS_DC); ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args);
/** Set arguments in the zend_fcall_info struct taking care of refcount. /** Set arguments in the zend_fcall_info struct taking care of refcount.
* If argc is 0 the arguments which are set will be cleared, else pass * If argc is 0 the arguments which are set will be cleared, else pass
* a variable amount of zval** arguments. * a variable amount of zval** arguments.
*/ */
ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci TSRMLS_DC, int argc, zval *argv); ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci, int argc, zval *argv);
/** Set arguments in the zend_fcall_info struct taking care of refcount. /** Set arguments in the zend_fcall_info struct taking care of refcount.
* If argc is 0 the arguments which are set will be cleared, else pass * If argc is 0 the arguments which are set will be cleared, else pass
* a variable amount of zval** arguments. * a variable amount of zval** arguments.
*/ */
ZEND_API int zend_fcall_info_argv(zend_fcall_info *fci TSRMLS_DC, int argc, va_list *argv); ZEND_API int zend_fcall_info_argv(zend_fcall_info *fci, int argc, va_list *argv);
/** Set arguments in the zend_fcall_info struct taking care of refcount. /** Set arguments in the zend_fcall_info struct taking care of refcount.
* If argc is 0 the arguments which are set will be cleared, else pass * If argc is 0 the arguments which are set will be cleared, else pass
* a variable amount of zval** arguments. * a variable amount of zval** arguments.
*/ */
ZEND_API int zend_fcall_info_argn(zend_fcall_info *fci TSRMLS_DC, int argc, ...); ZEND_API int zend_fcall_info_argn(zend_fcall_info *fci, int argc, ...);
/** Call a function using information created by zend_fcall_info_init()/args(). /** Call a function using information created by zend_fcall_info_init()/args().
* If args is given then those replace the argument info in fci is temporarily. * If args is given then those replace the argument info in fci is temporarily.
*/ */
ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args TSRMLS_DC); ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args);
ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC); ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...); ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...);
ZEND_API int zend_delete_global_variable(zend_string *name TSRMLS_DC); ZEND_API int zend_delete_global_variable(zend_string *name);
ZEND_API zend_array *zend_rebuild_symbol_table(TSRMLS_D); ZEND_API zend_array *zend_rebuild_symbol_table(void);
ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data);
ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS_DC); ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force);
ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force TSRMLS_DC); ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force);
ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name); ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f); ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
@ -645,7 +645,7 @@ END_EXTERN_C()
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; } #define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL))) #define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL) #define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
/* For compatibility */ /* For compatibility */
@ -654,8 +654,8 @@ END_EXTERN_C()
#define ZEND_RINIT ZEND_MODULE_ACTIVATE_N #define ZEND_RINIT ZEND_MODULE_ACTIVATE_N
#define ZEND_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N #define ZEND_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
#define ZEND_MINFO ZEND_MODULE_INFO_N #define ZEND_MINFO ZEND_MODULE_INFO_N
#define ZEND_GINIT(module) ((void (*)(void* TSRMLS_DC))(ZEND_MODULE_GLOBALS_CTOR_N(module))) #define ZEND_GINIT(module) ((void (*)(void*))(ZEND_MODULE_GLOBALS_CTOR_N(module)))
#define ZEND_GSHUTDOWN(module) ((void (*)(void* TSRMLS_DC))(ZEND_MODULE_GLOBALS_DTOR_N(module))) #define ZEND_GSHUTDOWN(module) ((void (*)(void*))(ZEND_MODULE_GLOBALS_DTOR_N(module)))
#define ZEND_MINIT_FUNCTION ZEND_MODULE_STARTUP_D #define ZEND_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
#define ZEND_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D #define ZEND_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
@ -694,12 +694,12 @@ typedef enum _zend_expected_type {
Z_EXPECTED_LAST Z_EXPECTED_LAST
} zend_expected_type; } zend_expected_type;
ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type TSRMLS_DC); ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type);
ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args TSRMLS_DC); ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args);
ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg TSRMLS_DC); ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg);
ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg TSRMLS_DC); ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg);
ZEND_API void zend_wrong_callback_error(int severity, int num, char *error TSRMLS_DC); ZEND_API void zend_wrong_callback_error(int severity, int num, char *error);
ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null TSRMLS_DC); ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null);
#define ZPP_ERROR_OK 0 #define ZPP_ERROR_OK 0
#define ZPP_ERROR_FAILURE 1 #define ZPP_ERROR_FAILURE 1
@ -733,7 +733,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
(UNEXPECTED(_num_args > _max_num_args) && \ (UNEXPECTED(_num_args > _max_num_args) && \
EXPECTED(_max_num_args >= 0))) { \ EXPECTED(_max_num_args >= 0))) { \
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
zend_wrong_paramers_count_error(_num_args, _min_num_args, _max_num_args TSRMLS_CC); \ zend_wrong_paramers_count_error(_num_args, _min_num_args, _max_num_args); \
} \ } \
error_code = ZPP_ERROR_FAILURE; \ error_code = ZPP_ERROR_FAILURE; \
break; \ break; \
@ -749,11 +749,11 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \ if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \ if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
zend_wrong_callback_error(E_WARNING, _i, _error TSRMLS_CC); \ zend_wrong_callback_error(E_WARNING, _i, _error); \
} else if (error_code == ZPP_ERROR_WRONG_CLASS) { \ } else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
zend_wrong_paramer_class_error(_i, _error, _arg TSRMLS_CC); \ zend_wrong_paramer_class_error(_i, _error, _arg); \
} else if (error_code == ZPP_ERROR_WRONG_ARG) { \ } else if (error_code == ZPP_ERROR_WRONG_ARG) { \
zend_wrong_paramer_type_error(_i, _expected_type, _arg TSRMLS_CC); \ zend_wrong_paramer_type_error(_i, _expected_type, _arg); \
} \ } \
} \ } \
failure; \ failure; \
@ -806,7 +806,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "b" */ /* old "b" */
#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \ #define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_bool(_arg, &dest, &is_null, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_bool(_arg, &dest, &is_null, check_null))) { \
_expected_type = Z_EXPECTED_BOOL; \ _expected_type = Z_EXPECTED_BOOL; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -818,7 +818,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "C" */ /* old "C" */
#define Z_PARAM_CLASS_EX(dest, check_null, separate) \ #define Z_PARAM_CLASS_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_class(_arg, &dest, _i, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_class(_arg, &dest, _i, check_null))) { \
error_code = ZPP_ERROR_FAILURE; \ error_code = ZPP_ERROR_FAILURE; \
break; \ break; \
} }
@ -841,7 +841,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "f" */ /* old "f" */
#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \ #define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_func(_arg, &dest_fci, &dest_fcc, check_null, &_error TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
if (!_error) { \ if (!_error) { \
_expected_type = Z_EXPECTED_FUNC; \ _expected_type = Z_EXPECTED_FUNC; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
@ -851,7 +851,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
break; \ break; \
} \ } \
} else if (UNEXPECTED(_error != NULL)) { \ } else if (UNEXPECTED(_error != NULL)) { \
zend_wrong_callback_error(E_STRICT, _i, _error TSRMLS_CC); \ zend_wrong_callback_error(E_STRICT, _i, _error); \
} }
#define Z_PARAM_FUNC(dest_fci, dest_fcc) \ #define Z_PARAM_FUNC(dest_fci, dest_fcc) \
@ -860,7 +860,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "h" */ /* old "h" */
#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \ #define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 0 TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 0))) { \
_expected_type = Z_EXPECTED_ARRAY; \ _expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -872,7 +872,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "H" */ /* old "H" */
#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \ #define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 1 TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 1))) { \
_expected_type = Z_EXPECTED_ARRAY; \ _expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -908,7 +908,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "o" */ /* old "o" */
#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \ #define Z_PARAM_OBJECT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_object(_arg, &dest, NULL, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_object(_arg, &dest, NULL, check_null))) { \
_expected_type = Z_EXPECTED_OBJECT; \ _expected_type = Z_EXPECTED_OBJECT; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -920,7 +920,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "O" */ /* old "O" */
#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \ #define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_object(_arg, &dest, _ce, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_object(_arg, &dest, _ce, check_null))) { \
if (_ce) { \ if (_ce) { \
_error = (_ce)->name->val; \ _error = (_ce)->name->val; \
error_code = ZPP_ERROR_WRONG_CLASS; \ error_code = ZPP_ERROR_WRONG_CLASS; \
@ -938,7 +938,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "p" */ /* old "p" */
#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \ #define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_path(_arg, &dest, &dest_len, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_path(_arg, &dest, &dest_len, check_null))) { \
_expected_type = Z_EXPECTED_PATH; \ _expected_type = Z_EXPECTED_PATH; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -950,7 +950,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "P" */ /* old "P" */
#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \ #define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_path_str(_arg, &dest, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_path_str(_arg, &dest, check_null))) { \
_expected_type = Z_EXPECTED_PATH; \ _expected_type = Z_EXPECTED_PATH; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -974,7 +974,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "s" */ /* old "s" */
#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \ #define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_string(_arg, &dest, &dest_len, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_string(_arg, &dest, &dest_len, check_null))) { \
_expected_type = Z_EXPECTED_STRING; \ _expected_type = Z_EXPECTED_STRING; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -986,7 +986,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "S" */ /* old "S" */
#define Z_PARAM_STR_EX(dest, check_null, separate) \ #define Z_PARAM_STR_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!_z_param_str(_arg, &dest, check_null TSRMLS_CC))) { \ if (UNEXPECTED(!_z_param_str(_arg, &dest, check_null))) { \
_expected_type = Z_EXPECTED_STRING; \ _expected_type = Z_EXPECTED_STRING; \
error_code = ZPP_ERROR_WRONG_ARG; \ error_code = ZPP_ERROR_WRONG_ARG; \
break; \ break; \
@ -1036,7 +1036,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* Private part of new parameter parsing API */ /* Private part of new parameter parsing API */
static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null TSRMLS_DC) static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
{ {
if (check_null) { if (check_null) {
*is_null = 0; *is_null = 0;
@ -1049,7 +1049,7 @@ static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_boo
} }
*dest = 0; *dest = 0;
} else if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) { } else if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
*dest = zend_is_true(arg TSRMLS_CC); *dest = zend_is_true(arg);
} else { } else {
return 0; return 0;
} }
@ -1145,7 +1145,7 @@ static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool
return 1; return 1;
} }
static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int check_null TSRMLS_DC) static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int check_null)
{ {
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
*dest = Z_STR_P(arg); *dest = Z_STR_P(arg);
@ -1161,17 +1161,17 @@ static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int ch
*dest = Z_STR_P(arg); *dest = Z_STR_P(arg);
} }
} else if (UNEXPECTED(Z_TYPE_P(arg) != IS_OBJECT) || } else if (UNEXPECTED(Z_TYPE_P(arg) != IS_OBJECT) ||
UNEXPECTED(parse_arg_object_to_str(arg, dest, IS_STRING TSRMLS_CC) != SUCCESS)) { UNEXPECTED(parse_arg_object_to_str(arg, dest, IS_STRING) != SUCCESS)) {
return 0; return 0;
} }
return 1; return 1;
} }
static zend_always_inline int _z_param_string(zval *arg, char **dest, size_t *dest_len, int check_null TSRMLS_DC) static zend_always_inline int _z_param_string(zval *arg, char **dest, size_t *dest_len, int check_null)
{ {
zend_string *str; zend_string *str;
if (!_z_param_str(arg, &str, check_null TSRMLS_CC)) { if (!_z_param_str(arg, &str, check_null)) {
return 0; return 0;
} }
if (check_null && UNEXPECTED(!str)) { if (check_null && UNEXPECTED(!str)) {
@ -1184,9 +1184,9 @@ static zend_always_inline int _z_param_string(zval *arg, char **dest, size_t *de
return 1; return 1;
} }
static zend_always_inline int _z_param_path_str(zval *arg, zend_string **dest, int check_null TSRMLS_DC) static zend_always_inline int _z_param_path_str(zval *arg, zend_string **dest, int check_null)
{ {
if (!_z_param_str(arg, dest, check_null TSRMLS_CC) || if (!_z_param_str(arg, dest, check_null) ||
(check_null && UNEXPECTED(!(*dest)->val[0])) || (check_null && UNEXPECTED(!(*dest)->val[0])) ||
UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len))) { UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len))) {
return 0; return 0;
@ -1194,11 +1194,11 @@ static zend_always_inline int _z_param_path_str(zval *arg, zend_string **dest, i
return 1; return 1;
} }
static zend_always_inline int _z_param_path(zval *arg, char **dest, size_t *dest_len, int check_null TSRMLS_DC) static zend_always_inline int _z_param_path(zval *arg, char **dest, size_t *dest_len, int check_null)
{ {
zend_string *str; zend_string *str;
if (!_z_param_path_str(arg, &str, check_null TSRMLS_CC)) { if (!_z_param_path_str(arg, &str, check_null)) {
return 0; return 0;
} }
if (check_null && UNEXPECTED(!str)) { if (check_null && UNEXPECTED(!str)) {
@ -1224,12 +1224,12 @@ static zend_always_inline int _z_param_array(zval *arg, zval **dest, int check_n
return 1; return 1;
} }
static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int check_null, int or_object TSRMLS_DC) static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
{ {
if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) {
*dest = Z_ARRVAL_P(arg); *dest = Z_ARRVAL_P(arg);
} else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { } else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
*dest = Z_OBJ_HT_P(arg)->get_properties(arg TSRMLS_CC); *dest = Z_OBJ_HT_P(arg)->get_properties(arg);
} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) { } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
*dest = NULL; *dest = NULL;
} else { } else {
@ -1238,10 +1238,10 @@ static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int
return 1; return 1;
} }
static zend_always_inline int _z_param_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null TSRMLS_DC) static zend_always_inline int _z_param_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
{ {
if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) && if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
(!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC) != 0))) { (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) {
*dest = arg; *dest = arg;
} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) { } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
*dest = NULL; *dest = NULL;
@ -1263,13 +1263,13 @@ static zend_always_inline int _z_param_resource(zval *arg, zval **dest, int chec
return 1; return 1;
} }
static zend_always_inline int _z_param_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error TSRMLS_DC) static zend_always_inline int _z_param_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
{ {
if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
dest_fci->size = 0; dest_fci->size = 0;
dest_fcc->initialized = 0; dest_fcc->initialized = 0;
*error = NULL; *error = NULL;
} else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error TSRMLS_CC) != SUCCESS)) { } else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error) != SUCCESS)) {
return 0; return 0;
} }
return 1; return 1;

View file

@ -368,7 +368,6 @@ static ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
#endif #endif
size_t size) size_t size)
{ {
TSRMLS_FETCH();
heap->overflow = 1; heap->overflow = 1;
zend_try { zend_try {
@ -1836,7 +1835,7 @@ static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, int i,
return count; return count;
} }
static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC) static void zend_mm_check_leaks(zend_mm_heap *heap)
{ {
zend_mm_huge_list *list; zend_mm_huge_list *list;
zend_mm_chunk *p; zend_mm_chunk *p;
@ -1859,12 +1858,12 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
leak.lineno = list->dbg.lineno; leak.lineno = list->dbg.lineno;
leak.orig_lineno = list->dbg.orig_lineno; leak.orig_lineno = list->dbg.orig_lineno;
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC); zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak);
//??? repeated = zend_mm_find_leaks_huge(segment, p); //??? repeated = zend_mm_find_leaks_huge(segment, p);
total += 1 + repeated; total += 1 + repeated;
if (repeated) { if (repeated) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
} }
list = list->next; list = list->next;
@ -1892,8 +1891,8 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
leak.lineno = dbg->lineno; leak.lineno = dbg->lineno;
leak.orig_lineno = dbg->orig_lineno; leak.orig_lineno = dbg->orig_lineno;
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC); zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak);
dbg->size = 0; dbg->size = 0;
dbg->filename = NULL; dbg->filename = NULL;
@ -1903,7 +1902,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
zend_mm_find_leaks(heap, p, i + bin_pages[bin_num], &leak); zend_mm_find_leaks(heap, p, i + bin_pages[bin_num], &leak);
total += 1 + repeated; total += 1 + repeated;
if (repeated) { if (repeated) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
} }
} }
dbg = (zend_mm_debug_info*)((char*)dbg + bin_data_size[bin_num]); dbg = (zend_mm_debug_info*)((char*)dbg + bin_data_size[bin_num]);
@ -1921,15 +1920,15 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
leak.lineno = dbg->lineno; leak.lineno = dbg->lineno;
leak.orig_lineno = dbg->orig_lineno; leak.orig_lineno = dbg->orig_lineno;
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC); zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak);
zend_mm_bitset_reset_range(p->free_map, i, pages_count); zend_mm_bitset_reset_range(p->free_map, i, pages_count);
repeated = zend_mm_find_leaks(heap, p, i + pages_count, &leak); repeated = zend_mm_find_leaks(heap, p, i + pages_count, &leak);
total += 1 + repeated; total += 1 + repeated;
if (repeated) { if (repeated) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
} }
i += pages_count; i += pages_count;
} }
@ -1940,12 +1939,12 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
p = p->next; p = p->next;
} while (p != heap->main_chunk); } while (p != heap->main_chunk);
if (total) { if (total) {
zend_message_dispatcher(ZMSG_MEMORY_LEAKS_GRAND_TOTAL, &total TSRMLS_CC); zend_message_dispatcher(ZMSG_MEMORY_LEAKS_GRAND_TOTAL, &total);
} }
} }
#endif #endif
void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent TSRMLS_DC) void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent)
{ {
zend_mm_chunk *p; zend_mm_chunk *p;
zend_mm_huge_list *list; zend_mm_huge_list *list;
@ -1958,7 +1957,7 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent TSRMLS_DC)
#if ZEND_DEBUG #if ZEND_DEBUG
if (!silent) { if (!silent) {
zend_mm_check_leaks(heap TSRMLS_CC); zend_mm_check_leaks(heap);
} }
#endif #endif
@ -2086,7 +2085,7 @@ static int alloc_globals_id;
static zend_alloc_globals alloc_globals; static zend_alloc_globals alloc_globals;
#endif #endif
ZEND_API int is_zend_mm(TSRMLS_D) ZEND_API int is_zend_mm(void)
{ {
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM
return !AG(mm_heap)->use_custom_heap; return !AG(mm_heap)->use_custom_heap;
@ -2126,7 +2125,6 @@ ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR, x, y)
ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{ {
TSRMLS_FETCH();
ZEND_MM_CUSTOM_ALLOCATOR(size); ZEND_MM_CUSTOM_ALLOCATOR(size);
return zend_mm_alloc_large(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); return zend_mm_alloc_large(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
@ -2134,7 +2132,6 @@ ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_F
ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size) ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size)
{ {
TSRMLS_FETCH();
ZEND_MM_CUSTOM_ALLOCATOR(size); ZEND_MM_CUSTOM_ALLOCATOR(size);
return zend_mm_alloc_huge(AG(mm_heap), size); return zend_mm_alloc_huge(AG(mm_heap), size);
@ -2172,7 +2169,6 @@ ZEND_MM_BINS_INFO(_ZEND_BIN_FREE, x, y)
ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size) ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
{ {
TSRMLS_FETCH();
ZEND_MM_CUSTOM_DEALLOCATOR(ptr); ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
{ {
@ -2190,7 +2186,6 @@ ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size)
{ {
TSRMLS_FETCH();
ZEND_MM_CUSTOM_DEALLOCATOR(ptr); ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
// TODO: use size??? // TODO: use size???
@ -2200,7 +2195,6 @@ ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size)
ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{ {
TSRMLS_FETCH();
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM
if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) {
@ -2212,7 +2206,6 @@ ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI
ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{ {
TSRMLS_FETCH();
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM
if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) {
@ -2225,7 +2218,6 @@ ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR
ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{ {
TSRMLS_FETCH();
if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) {
return AG(mm_heap)->_realloc(ptr, size); return AG(mm_heap)->_realloc(ptr, size);
@ -2279,7 +2271,6 @@ ZEND_API void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_D
{ {
void *p; void *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
@ -2298,7 +2289,6 @@ ZEND_API char* ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_
size_t length; size_t length;
char *p; char *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
@ -2318,7 +2308,6 @@ ZEND_API char* ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LI
{ {
char *p; char *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
@ -2339,7 +2328,6 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
{ {
char *p; char *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
@ -2358,7 +2346,7 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
} }
ZEND_API int zend_set_memory_limit(size_t memory_limit TSRMLS_DC) ZEND_API int zend_set_memory_limit(size_t memory_limit)
{ {
#if ZEND_MM_LIMIT #if ZEND_MM_LIMIT
AG(mm_heap)->limit = (memory_limit >= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE; AG(mm_heap)->limit = (memory_limit >= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE;
@ -2366,7 +2354,7 @@ ZEND_API int zend_set_memory_limit(size_t memory_limit TSRMLS_DC)
return SUCCESS; return SUCCESS;
} }
ZEND_API size_t zend_memory_usage(int real_usage TSRMLS_DC) ZEND_API size_t zend_memory_usage(int real_usage)
{ {
#if ZEND_MM_STAT #if ZEND_MM_STAT
if (real_usage) { if (real_usage) {
@ -2379,7 +2367,7 @@ ZEND_API size_t zend_memory_usage(int real_usage TSRMLS_DC)
return 0; return 0;
} }
ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC) ZEND_API size_t zend_memory_peak_usage(int real_usage)
{ {
#if ZEND_MM_STAT #if ZEND_MM_STAT
if (real_usage) { if (real_usage) {
@ -2391,12 +2379,12 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC)
return 0; return 0;
} }
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC) ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
{ {
zend_mm_shutdown(AG(mm_heap), full_shutdown, silent TSRMLS_CC); zend_mm_shutdown(AG(mm_heap), full_shutdown, silent);
} }
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC) static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
{ {
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM
char *tmp = getenv("USE_ZEND_ALLOC"); char *tmp = getenv("USE_ZEND_ALLOC");
@ -2416,13 +2404,13 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
} }
#ifdef ZTS #ifdef ZTS
static void alloc_globals_dtor(zend_alloc_globals *alloc_globals TSRMLS_DC) static void alloc_globals_dtor(zend_alloc_globals *alloc_globals)
{ {
shutdown_memory_manager(1, 1 TSRMLS_CC); shutdown_memory_manager(1, 1);
} }
#endif #endif
ZEND_API void start_memory_manager(TSRMLS_D) ZEND_API void start_memory_manager(void)
{ {
#ifdef ZTS #ifdef ZTS
ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor); ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
@ -2438,7 +2426,7 @@ ZEND_API void start_memory_manager(TSRMLS_D)
#endif #endif
} }
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap TSRMLS_DC) ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap)
{ {
zend_mm_heap *old_heap; zend_mm_heap *old_heap;

View file

@ -211,14 +211,14 @@ zend_always_inline static void * __zend_realloc(void *p, size_t len)
#define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size))) #define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size)))
#define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s)) #define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s))
ZEND_API int zend_set_memory_limit(size_t memory_limit TSRMLS_DC); ZEND_API int zend_set_memory_limit(size_t memory_limit);
ZEND_API void start_memory_manager(TSRMLS_D); ZEND_API void start_memory_manager(void);
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC); ZEND_API void shutdown_memory_manager(int silent, int full_shutdown);
ZEND_API int is_zend_mm(TSRMLS_D); ZEND_API int is_zend_mm(void);
ZEND_API size_t zend_memory_usage(int real_usage TSRMLS_DC); ZEND_API size_t zend_memory_usage(int real_usage);
ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC); ZEND_API size_t zend_memory_peak_usage(int real_usage);
/* fast cache for HashTables */ /* fast cache for HashTables */
#define ALLOC_HASHTABLE(ht) \ #define ALLOC_HASHTABLE(ht) \
@ -237,7 +237,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC);
typedef struct _zend_mm_heap zend_mm_heap; typedef struct _zend_mm_heap zend_mm_heap;
ZEND_API zend_mm_heap *zend_mm_startup(void); ZEND_API zend_mm_heap *zend_mm_startup(void);
ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC); ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent);
ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
@ -253,7 +253,7 @@ ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZE
#define zend_mm_realloc_rel(heap, p, size) _zend_mm_realloc((heap), (p), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) #define zend_mm_realloc_rel(heap, p, size) _zend_mm_realloc((heap), (p), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mm_block_size_rel(heap, p) _zend_mm_block_size((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define zend_mm_block_size_rel(heap, p) _zend_mm_block_size((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap TSRMLS_DC); ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap);
ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap, ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
void* (*_malloc)(size_t), void* (*_malloc)(size_t),

View file

@ -23,12 +23,12 @@
#include "zend_API.h" #include "zend_API.h"
#include "zend_operators.h" #include "zend_operators.h"
static inline void *zend_ast_alloc(size_t size TSRMLS_DC) { static inline void *zend_ast_alloc(size_t size) {
return zend_arena_alloc(&CG(ast_arena), size); return zend_arena_alloc(&CG(ast_arena), size);
} }
static inline void *zend_ast_realloc(void *old, size_t old_size, size_t new_size TSRMLS_DC) { static inline void *zend_ast_realloc(void *old, size_t old_size, size_t new_size) {
void *new = zend_ast_alloc(new_size TSRMLS_CC); void *new = zend_ast_alloc(new_size);
memcpy(new, old, old_size); memcpy(new, old, old_size);
return new; return new;
} }
@ -43,9 +43,8 @@ static inline size_t zend_ast_list_size(uint32_t children) {
ZEND_API zend_ast *zend_ast_create_znode(znode *node) { ZEND_API zend_ast *zend_ast_create_znode(znode *node) {
zend_ast_znode *ast; zend_ast_znode *ast;
TSRMLS_FETCH();
ast = zend_ast_alloc(sizeof(zend_ast_znode) TSRMLS_CC); ast = zend_ast_alloc(sizeof(zend_ast_znode));
ast->kind = ZEND_AST_ZNODE; ast->kind = ZEND_AST_ZNODE;
ast->attr = 0; ast->attr = 0;
ast->lineno = CG(zend_lineno); ast->lineno = CG(zend_lineno);
@ -55,9 +54,8 @@ ZEND_API zend_ast *zend_ast_create_znode(znode *node) {
ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) { ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) {
zend_ast_zval *ast; zend_ast_zval *ast;
TSRMLS_FETCH();
ast = zend_ast_alloc(sizeof(zend_ast_zval) TSRMLS_CC); ast = zend_ast_alloc(sizeof(zend_ast_zval));
ast->kind = ZEND_AST_ZVAL; ast->kind = ZEND_AST_ZVAL;
ast->attr = attr; ast->attr = attr;
ZVAL_COPY_VALUE(&ast->val, zv); ZVAL_COPY_VALUE(&ast->val, zv);
@ -70,9 +68,8 @@ ZEND_API zend_ast *zend_ast_create_decl(
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2 zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2
) { ) {
zend_ast_decl *ast; zend_ast_decl *ast;
TSRMLS_FETCH();
ast = zend_ast_alloc(sizeof(zend_ast_decl) TSRMLS_CC); ast = zend_ast_alloc(sizeof(zend_ast_decl));
ast->kind = kind; ast->kind = kind;
ast->attr = 0; ast->attr = 0;
ast->start_lineno = start_lineno; ast->start_lineno = start_lineno;
@ -91,9 +88,8 @@ ZEND_API zend_ast *zend_ast_create_decl(
static zend_ast *zend_ast_create_from_va_list(zend_ast_kind kind, zend_ast_attr attr, va_list va) { static zend_ast *zend_ast_create_from_va_list(zend_ast_kind kind, zend_ast_attr attr, va_list va) {
uint32_t i, children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT; uint32_t i, children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
zend_ast *ast; zend_ast *ast;
TSRMLS_FETCH();
ast = zend_ast_alloc(zend_ast_size(children) TSRMLS_CC); ast = zend_ast_alloc(zend_ast_size(children));
ast->kind = kind; ast->kind = kind;
ast->attr = attr; ast->attr = attr;
ast->lineno = (uint32_t) -1; ast->lineno = (uint32_t) -1;
@ -140,9 +136,8 @@ ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...) {
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...) { ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...) {
zend_ast *ast; zend_ast *ast;
zend_ast_list *list; zend_ast_list *list;
TSRMLS_FETCH();
ast = zend_ast_alloc(zend_ast_list_size(4) TSRMLS_CC); ast = zend_ast_alloc(zend_ast_list_size(4));
list = (zend_ast_list *) ast; list = (zend_ast_list *) ast;
list->kind = kind; list->kind = kind;
list->attr = 0; list->attr = 0;
@ -169,15 +164,14 @@ static inline zend_bool is_power_of_two(uint32_t n) {
ZEND_API zend_ast *zend_ast_list_add(zend_ast *ast, zend_ast *op) { ZEND_API zend_ast *zend_ast_list_add(zend_ast *ast, zend_ast *op) {
zend_ast_list *list = zend_ast_get_list(ast); zend_ast_list *list = zend_ast_get_list(ast);
if (list->children >= 4 && is_power_of_two(list->children)) { if (list->children >= 4 && is_power_of_two(list->children)) {
TSRMLS_FETCH(); list = zend_ast_realloc(list,
list = zend_ast_realloc(list, zend_ast_list_size(list->children), zend_ast_list_size(list->children * 2));
zend_ast_list_size(list->children), zend_ast_list_size(list->children * 2) TSRMLS_CC);
} }
list->child[list->children++] = op; list->child[list->children++] = op;
return (zend_ast *) list; return (zend_ast *) list;
} }
static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr TSRMLS_DC) static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr)
{ {
switch (Z_TYPE_P(offset)) { switch (Z_TYPE_P(offset)) {
case IS_UNDEF: case IS_UNDEF:
@ -208,7 +202,7 @@ static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr TS
} }
} }
ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope TSRMLS_DC) ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope)
{ {
zval op1, op2; zval op1, op2;
@ -216,9 +210,9 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
case ZEND_AST_BINARY_OP: case ZEND_AST_BINARY_OP:
{ {
binary_op_type op = get_binary_op(ast->attr); binary_op_type op = get_binary_op(ast->attr);
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
zend_ast_evaluate(&op2, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[1], scope);
op(result, &op1, &op2 TSRMLS_CC); op(result, &op1, &op2);
zval_dtor(&op1); zval_dtor(&op1);
zval_dtor(&op2); zval_dtor(&op2);
break; break;
@ -229,9 +223,9 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
/* op1 > op2 is the same as op2 < op1 */ /* op1 > op2 is the same as op2 < op1 */
binary_op_type op = ast->kind == ZEND_AST_GREATER binary_op_type op = ast->kind == ZEND_AST_GREATER
? is_smaller_function : is_smaller_or_equal_function; ? is_smaller_function : is_smaller_or_equal_function;
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
zend_ast_evaluate(&op2, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[1], scope);
op(result, &op2, &op1 TSRMLS_CC); op(result, &op2, &op1);
zval_dtor(&op1); zval_dtor(&op1);
zval_dtor(&op2); zval_dtor(&op2);
break; break;
@ -239,8 +233,8 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
case ZEND_AST_UNARY_OP: case ZEND_AST_UNARY_OP:
{ {
unary_op_type op = get_unary_op(ast->attr); unary_op_type op = get_unary_op(ast->attr);
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
op(result, &op1 TSRMLS_CC); op(result, &op1);
zval_dtor(&op1); zval_dtor(&op1);
break; break;
} }
@ -250,22 +244,22 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
if (scope) { if (scope) {
/* class constants may be updated in-place */ /* class constants may be updated in-place */
if (Z_OPT_CONSTANT_P(zv)) { if (Z_OPT_CONSTANT_P(zv)) {
zval_update_constant_ex(zv, 1, scope TSRMLS_CC); zval_update_constant_ex(zv, 1, scope);
} }
ZVAL_DUP(result, zv); ZVAL_DUP(result, zv);
} else { } else {
ZVAL_DUP(result, zv); ZVAL_DUP(result, zv);
if (Z_OPT_CONSTANT_P(result)) { if (Z_OPT_CONSTANT_P(result)) {
zval_update_constant_ex(result, 1, scope TSRMLS_CC); zval_update_constant_ex(result, 1, scope);
} }
} }
break; break;
} }
case ZEND_AST_AND: case ZEND_AST_AND:
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
if (zend_is_true(&op1 TSRMLS_CC)) { if (zend_is_true(&op1)) {
zend_ast_evaluate(&op2, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[1], scope);
ZVAL_BOOL(result, zend_is_true(&op2 TSRMLS_CC)); ZVAL_BOOL(result, zend_is_true(&op2));
zval_dtor(&op2); zval_dtor(&op2);
} else { } else {
ZVAL_BOOL(result, 0); ZVAL_BOOL(result, 0);
@ -273,40 +267,40 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
zval_dtor(&op1); zval_dtor(&op1);
break; break;
case ZEND_AST_OR: case ZEND_AST_OR:
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
if (zend_is_true(&op1 TSRMLS_CC)) { if (zend_is_true(&op1)) {
ZVAL_BOOL(result, 1); ZVAL_BOOL(result, 1);
} else { } else {
zend_ast_evaluate(&op2, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[1], scope);
ZVAL_BOOL(result, zend_is_true(&op2 TSRMLS_CC)); ZVAL_BOOL(result, zend_is_true(&op2));
zval_dtor(&op2); zval_dtor(&op2);
} }
zval_dtor(&op1); zval_dtor(&op1);
break; break;
case ZEND_AST_CONDITIONAL: case ZEND_AST_CONDITIONAL:
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
if (zend_is_true(&op1 TSRMLS_CC)) { if (zend_is_true(&op1)) {
if (!ast->child[1]) { if (!ast->child[1]) {
*result = op1; *result = op1;
} else { } else {
zend_ast_evaluate(result, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(result, ast->child[1], scope);
zval_dtor(&op1); zval_dtor(&op1);
} }
} else { } else {
zend_ast_evaluate(result, ast->child[2], scope TSRMLS_CC); zend_ast_evaluate(result, ast->child[2], scope);
zval_dtor(&op1); zval_dtor(&op1);
} }
break; break;
case ZEND_AST_UNARY_PLUS: case ZEND_AST_UNARY_PLUS:
ZVAL_LONG(&op1, 0); ZVAL_LONG(&op1, 0);
zend_ast_evaluate(&op2, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[0], scope);
add_function(result, &op1, &op2 TSRMLS_CC); add_function(result, &op1, &op2);
zval_dtor(&op2); zval_dtor(&op2);
break; break;
case ZEND_AST_UNARY_MINUS: case ZEND_AST_UNARY_MINUS:
ZVAL_LONG(&op1, 0); ZVAL_LONG(&op1, 0);
zend_ast_evaluate(&op2, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[0], scope);
sub_function(result, &op1, &op2 TSRMLS_CC); sub_function(result, &op1, &op2);
zval_dtor(&op2); zval_dtor(&op2);
break; break;
case ZEND_AST_ARRAY: case ZEND_AST_ARRAY:
@ -317,21 +311,21 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
for (i = 0; i < list->children; i++) { for (i = 0; i < list->children; i++) {
zend_ast *elem = list->child[i]; zend_ast *elem = list->child[i];
if (elem->child[1]) { if (elem->child[1]) {
zend_ast_evaluate(&op1, elem->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op1, elem->child[1], scope);
} else { } else {
ZVAL_UNDEF(&op1); ZVAL_UNDEF(&op1);
} }
zend_ast_evaluate(&op2, elem->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op2, elem->child[0], scope);
zend_ast_add_array_element(result, &op1, &op2 TSRMLS_CC); zend_ast_add_array_element(result, &op1, &op2);
} }
} }
break; break;
case ZEND_AST_DIM: case ZEND_AST_DIM:
zend_ast_evaluate(&op1, ast->child[0], scope TSRMLS_CC); zend_ast_evaluate(&op1, ast->child[0], scope);
zend_ast_evaluate(&op2, ast->child[1], scope TSRMLS_CC); zend_ast_evaluate(&op2, ast->child[1], scope);
{ {
zval tmp; zval tmp;
zend_fetch_dimension_by_zval(&tmp, &op1, &op2 TSRMLS_CC); zend_fetch_dimension_by_zval(&tmp, &op1, &op2);
ZVAL_ZVAL(result, &tmp, 1, 1); ZVAL_ZVAL(result, &tmp, 1, 1);
} }
zval_dtor(&op1); zval_dtor(&op1);
@ -429,17 +423,17 @@ ZEND_API void zend_ast_destroy_and_free(zend_ast *ast) {
zend_ast_destroy_ex(ast, 1); zend_ast_destroy_ex(ast, 1);
} }
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn TSRMLS_DC) { ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn) {
if (zend_ast_is_list(ast)) { if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast); zend_ast_list *list = zend_ast_get_list(ast);
uint32_t i; uint32_t i;
for (i = 0; i < list->children; ++i) { for (i = 0; i < list->children; ++i) {
fn(&list->child[i] TSRMLS_CC); fn(&list->child[i]);
} }
} else { } else {
uint32_t i, children = zend_ast_get_num_children(ast); uint32_t i, children = zend_ast_get_num_children(ast);
for (i = 0; i < children; ++i) { for (i = 0; i < children; ++i) {
fn(&ast->child[i] TSRMLS_CC); fn(&ast->child[i]);
} }
} }
} }

View file

@ -199,14 +199,14 @@ ZEND_API zend_ast *zend_ast_create_decl(
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...); ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...);
ZEND_API zend_ast *zend_ast_list_add(zend_ast *list, zend_ast *op); ZEND_API zend_ast *zend_ast_list_add(zend_ast *list, zend_ast *op);
ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope TSRMLS_DC); ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope);
ZEND_API zend_ast *zend_ast_copy(zend_ast *ast); ZEND_API zend_ast *zend_ast_copy(zend_ast *ast);
ZEND_API void zend_ast_destroy(zend_ast *ast); ZEND_API void zend_ast_destroy(zend_ast *ast);
ZEND_API void zend_ast_destroy_and_free(zend_ast *ast); ZEND_API void zend_ast_destroy_and_free(zend_ast *ast);
typedef void (*zend_ast_apply_func)(zend_ast **ast_ptr TSRMLS_DC); typedef void (*zend_ast_apply_func)(zend_ast **ast_ptr);
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn TSRMLS_DC); ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn);
static zend_always_inline zend_bool zend_ast_is_list(zend_ast *ast) { static zend_always_inline zend_bool zend_ast_is_list(zend_ast *ast) {
return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1; return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1;

View file

@ -321,9 +321,9 @@ ZEND_MINIT_FUNCTION(core) { /* {{{ */
zend_class_entry class_entry; zend_class_entry class_entry;
INIT_CLASS_ENTRY(class_entry, "stdClass", NULL); INIT_CLASS_ENTRY(class_entry, "stdClass", NULL);
zend_standard_class_def = zend_register_internal_class(&class_entry TSRMLS_CC); zend_standard_class_def = zend_register_internal_class(&class_entry);
zend_register_default_classes(TSRMLS_C); zend_register_default_classes();
return SUCCESS; return SUCCESS;
} }
@ -343,11 +343,11 @@ zend_module_entry zend_builtin_module = { /* {{{ */
}; };
/* }}} */ /* }}} */
int zend_startup_builtin_functions(TSRMLS_D) /* {{{ */ int zend_startup_builtin_functions(void) /* {{{ */
{ {
zend_builtin_module.module_number = 0; zend_builtin_module.module_number = 0;
zend_builtin_module.type = MODULE_PERSISTENT; zend_builtin_module.type = MODULE_PERSISTENT;
return (EG(current_module) = zend_register_module_ex(&zend_builtin_module TSRMLS_CC)) == NULL ? FAILURE : SUCCESS; return (EG(current_module) = zend_register_module_ex(&zend_builtin_module)) == NULL ? FAILURE : SUCCESS;
} }
/* }}} */ /* }}} */
@ -364,7 +364,7 @@ ZEND_FUNCTION(zend_version)
Returns number of freed zvals */ Returns number of freed zvals */
ZEND_FUNCTION(gc_collect_cycles) ZEND_FUNCTION(gc_collect_cycles)
{ {
RETURN_LONG(gc_collect_cycles(TSRMLS_C)); RETURN_LONG(gc_collect_cycles());
} }
/* }}} */ /* }}} */
@ -420,7 +420,7 @@ ZEND_FUNCTION(func_get_arg)
zend_long requested_offset; zend_long requested_offset;
zend_execute_data *ex; zend_execute_data *ex;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &requested_offset) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &requested_offset) == FAILURE) {
return; return;
} }
@ -526,7 +526,7 @@ ZEND_FUNCTION(strlen)
zend_string *s; zend_string *s;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &s) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &s) == FAILURE) {
return; return;
} }
#else #else
@ -545,7 +545,7 @@ ZEND_FUNCTION(strcmp)
{ {
zend_string *s1, *s2; zend_string *s1, *s2;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
return; return;
} }
@ -560,7 +560,7 @@ ZEND_FUNCTION(strncmp)
zend_string *s1, *s2; zend_string *s1, *s2;
zend_long len; zend_long len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s2, &len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
return; return;
} }
@ -579,7 +579,7 @@ ZEND_FUNCTION(strcasecmp)
{ {
zend_string *s1, *s2; zend_string *s1, *s2;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
return; return;
} }
@ -594,7 +594,7 @@ ZEND_FUNCTION(strncasecmp)
zend_string *s1, *s2; zend_string *s1, *s2;
zend_long len; zend_long len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s2, &len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
return; return;
} }
@ -616,7 +616,7 @@ ZEND_FUNCTION(each)
HashTable *target_hash; HashTable *target_hash;
zend_string *key; zend_string *key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &array) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &array) == FAILURE) {
return; return;
} }
@ -673,7 +673,7 @@ ZEND_FUNCTION(error_reporting)
zend_string *err; zend_string *err;
int old_error_reporting; int old_error_reporting;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &err) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &err) == FAILURE) {
return; return;
} }
@ -699,7 +699,7 @@ ZEND_FUNCTION(define)
zend_constant c; zend_constant c;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|b", &name, &val, &non_cs) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|b", &name, &val, &non_cs) == FAILURE) {
return; return;
} }
#else #else
@ -737,11 +737,11 @@ repeat:
if (Z_TYPE(val_free) == IS_UNDEF) { if (Z_TYPE(val_free) == IS_UNDEF) {
if (Z_OBJ_HT_P(val)->get) { if (Z_OBJ_HT_P(val)->get) {
zval rv; zval rv;
val = Z_OBJ_HT_P(val)->get(val, &rv TSRMLS_CC); val = Z_OBJ_HT_P(val)->get(val, &rv);
ZVAL_COPY_VALUE(&val_free, val); ZVAL_COPY_VALUE(&val_free, val);
goto repeat; goto repeat;
} else if (Z_OBJ_HT_P(val)->cast_object) { } else if (Z_OBJ_HT_P(val)->cast_object) {
if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING TSRMLS_CC) == SUCCESS) { if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) {
val = &val_free; val = &val_free;
break; break;
} }
@ -759,7 +759,7 @@ repeat:
c.flags = case_sensitive; /* non persistent */ c.flags = case_sensitive; /* non persistent */
c.name = zend_string_copy(name); c.name = zend_string_copy(name);
c.module_number = PHP_USER_CONSTANT; c.module_number = PHP_USER_CONSTANT;
if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) { if (zend_register_constant(&c) == SUCCESS) {
RETURN_TRUE; RETURN_TRUE;
} else { } else {
RETURN_FALSE; RETURN_FALSE;
@ -775,7 +775,7 @@ ZEND_FUNCTION(defined)
zend_string *name; zend_string *name;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
return; return;
} }
#else #else
@ -784,7 +784,7 @@ ZEND_FUNCTION(defined)
ZEND_PARSE_PARAMETERS_END(); ZEND_PARSE_PARAMETERS_END();
#endif #endif
if (zend_get_constant_ex(name, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) { if (zend_get_constant_ex(name, NULL, ZEND_FETCH_CLASS_SILENT)) {
RETURN_TRUE; RETURN_TRUE;
} else { } else {
RETURN_FALSE; RETURN_FALSE;
@ -798,7 +798,7 @@ ZEND_FUNCTION(get_class)
{ {
zval *obj = NULL; zval *obj = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o!", &obj) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &obj) == FAILURE) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -839,7 +839,7 @@ ZEND_FUNCTION(get_parent_class)
zval *arg; zval *arg;
zend_class_entry *ce = NULL; zend_class_entry *ce = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) {
return; return;
} }
@ -855,7 +855,7 @@ ZEND_FUNCTION(get_parent_class)
if (Z_TYPE_P(arg) == IS_OBJECT) { if (Z_TYPE_P(arg) == IS_OBJECT) {
ce = Z_OBJ_P(arg)->ce; ce = Z_OBJ_P(arg)->ce;
} else if (Z_TYPE_P(arg) == IS_STRING) { } else if (Z_TYPE_P(arg) == IS_STRING) {
ce = zend_lookup_class(Z_STR_P(arg) TSRMLS_CC); ce = zend_lookup_class(Z_STR_P(arg));
} }
if (ce && ce->parent) { if (ce && ce->parent) {
@ -876,7 +876,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
zend_bool retval; zend_bool retval;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zS|b", &obj, &class_name, &allow_string) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS|b", &obj, &class_name, &allow_string) == FAILURE) {
return; return;
} }
#else #else
@ -895,7 +895,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
*/ */
if (allow_string && Z_TYPE_P(obj) == IS_STRING) { if (allow_string && Z_TYPE_P(obj) == IS_STRING) {
instance_ce = zend_lookup_class(Z_STR_P(obj) TSRMLS_CC); instance_ce = zend_lookup_class(Z_STR_P(obj));
if (!instance_ce) { if (!instance_ce) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -905,14 +905,14 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
RETURN_FALSE; RETURN_FALSE;
} }
ce = zend_lookup_class_ex(class_name, NULL, 0 TSRMLS_CC); ce = zend_lookup_class_ex(class_name, NULL, 0);
if (!ce) { if (!ce) {
retval = 0; retval = 0;
} else { } else {
if (only_subclass && instance_ce == ce) { if (only_subclass && instance_ce == ce) {
retval = 0; retval = 0;
} else { } else {
retval = instanceof_function(instance_ce, ce TSRMLS_CC); retval = instanceof_function(instance_ce, ce);
} }
} }
@ -937,7 +937,7 @@ ZEND_FUNCTION(is_a)
/* }}} */ /* }}} */
/* {{{ add_class_vars */ /* {{{ add_class_vars */
static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC) static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value)
{ {
zend_property_info *prop_info; zend_property_info *prop_info;
zval *prop, prop_copy; zval *prop, prop_copy;
@ -973,7 +973,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
/* this is necessary to make it able to work with default array /* this is necessary to make it able to work with default array
* properties, returned to user */ * properties, returned to user */
if (Z_OPT_CONSTANT_P(prop)) { if (Z_OPT_CONSTANT_P(prop)) {
zval_update_constant(prop, 0 TSRMLS_CC); zval_update_constant(prop, 0);
} }
zend_hash_add_new(Z_ARRVAL_P(return_value), key, prop); zend_hash_add_new(Z_ARRVAL_P(return_value), key, prop);
@ -988,18 +988,18 @@ ZEND_FUNCTION(get_class_vars)
zend_string *class_name; zend_string *class_name;
zend_class_entry *ce; zend_class_entry *ce;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &class_name) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &class_name) == FAILURE) {
return; return;
} }
ce = zend_lookup_class(class_name TSRMLS_CC); ce = zend_lookup_class(class_name);
if (!ce) { if (!ce) {
RETURN_FALSE; RETURN_FALSE;
} else { } else {
array_init(return_value); array_init(return_value);
zend_update_class_constants(ce TSRMLS_CC); zend_update_class_constants(ce);
add_class_vars(ce, 0, return_value TSRMLS_CC); add_class_vars(ce, 0, return_value);
add_class_vars(ce, 1, return_value TSRMLS_CC); add_class_vars(ce, 1, return_value);
} }
} }
/* }}} */ /* }}} */
@ -1015,7 +1015,7 @@ ZEND_FUNCTION(get_object_vars)
zend_object *zobj; zend_object *zobj;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
return; return;
} }
#else #else
@ -1028,7 +1028,7 @@ ZEND_FUNCTION(get_object_vars)
RETURN_FALSE; RETURN_FALSE;
} }
properties = Z_OBJ_HT_P(obj)->get_properties(obj TSRMLS_CC); properties = Z_OBJ_HT_P(obj)->get_properties(obj);
if (properties == NULL) { if (properties == NULL) {
RETURN_FALSE; RETURN_FALSE;
@ -1040,7 +1040,7 @@ ZEND_FUNCTION(get_object_vars)
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) { ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
if (key) { if (key) {
if (zend_check_property_access(zobj, key TSRMLS_CC) == SUCCESS) { if (zend_check_property_access(zobj, key) == SUCCESS) {
/* Not separating references */ /* Not separating references */
if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
if (key->val[0] == 0) { if (key->val[0] == 0) {
@ -1076,14 +1076,14 @@ ZEND_FUNCTION(get_class_methods)
zend_function *mptr; zend_function *mptr;
zend_string *key; zend_string *key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &klass) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &klass) == FAILURE) {
return; return;
} }
if (Z_TYPE_P(klass) == IS_OBJECT) { if (Z_TYPE_P(klass) == IS_OBJECT) {
ce = Z_OBJCE_P(klass); ce = Z_OBJCE_P(klass);
} else if (Z_TYPE_P(klass) == IS_STRING) { } else if (Z_TYPE_P(klass) == IS_STRING) {
ce = zend_lookup_class(Z_STR_P(klass) TSRMLS_CC); ce = zend_lookup_class(Z_STR_P(klass));
} }
if (!ce) { if (!ce) {
@ -1136,7 +1136,7 @@ ZEND_FUNCTION(method_exists)
zend_class_entry * ce; zend_class_entry * ce;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zS", &klass, &method_name) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS", &klass, &method_name) == FAILURE) {
return; return;
} }
#else #else
@ -1148,7 +1148,7 @@ ZEND_FUNCTION(method_exists)
if (Z_TYPE_P(klass) == IS_OBJECT) { if (Z_TYPE_P(klass) == IS_OBJECT) {
ce = Z_OBJCE_P(klass); ce = Z_OBJCE_P(klass);
} else if (Z_TYPE_P(klass) == IS_STRING) { } else if (Z_TYPE_P(klass) == IS_STRING) {
if ((ce = zend_lookup_class(Z_STR_P(klass) TSRMLS_CC)) == NULL) { if ((ce = zend_lookup_class(Z_STR_P(klass))) == NULL) {
RETURN_FALSE; RETURN_FALSE;
} }
} else { } else {
@ -1165,7 +1165,7 @@ ZEND_FUNCTION(method_exists)
if (Z_TYPE_P(klass) == IS_OBJECT if (Z_TYPE_P(klass) == IS_OBJECT
&& Z_OBJ_HT_P(klass)->get_method != NULL && Z_OBJ_HT_P(klass)->get_method != NULL
&& (func = Z_OBJ_HT_P(klass)->get_method(&Z_OBJ_P(klass), method_name, NULL TSRMLS_CC)) != NULL && (func = Z_OBJ_HT_P(klass)->get_method(&Z_OBJ_P(klass), method_name, NULL)) != NULL
) { ) {
if (func->type == ZEND_INTERNAL_FUNCTION if (func->type == ZEND_INTERNAL_FUNCTION
&& (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0 && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0
@ -1198,7 +1198,7 @@ ZEND_FUNCTION(property_exists)
zend_property_info *property_info; zend_property_info *property_info;
zval property_z; zval property_z;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zS", &object, &property) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS", &object, &property) == FAILURE) {
return; return;
} }
@ -1207,7 +1207,7 @@ ZEND_FUNCTION(property_exists)
} }
if (Z_TYPE_P(object) == IS_STRING) { if (Z_TYPE_P(object) == IS_STRING) {
ce = zend_lookup_class(Z_STR_P(object) TSRMLS_CC); ce = zend_lookup_class(Z_STR_P(object));
if (!ce) { if (!ce) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -1227,7 +1227,7 @@ ZEND_FUNCTION(property_exists)
if (Z_TYPE_P(object) == IS_OBJECT && if (Z_TYPE_P(object) == IS_OBJECT &&
Z_OBJ_HANDLER_P(object, has_property) && Z_OBJ_HANDLER_P(object, has_property) &&
Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, NULL TSRMLS_CC)) { Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, NULL)) {
RETURN_TRUE; RETURN_TRUE;
} }
RETURN_FALSE; RETURN_FALSE;
@ -1244,7 +1244,7 @@ ZEND_FUNCTION(class_exists)
zend_bool autoload = 1; zend_bool autoload = 1;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &class_name, &autoload) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &class_name, &autoload) == FAILURE) {
return; return;
} }
#else #else
@ -1269,7 +1269,7 @@ ZEND_FUNCTION(class_exists)
RETURN_BOOL(ce && !((ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)); RETURN_BOOL(ce && !((ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS));
} }
ce = zend_lookup_class(class_name TSRMLS_CC); ce = zend_lookup_class(class_name);
if (ce) { if (ce) {
RETURN_BOOL((ce->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0); RETURN_BOOL((ce->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0);
} else { } else {
@ -1287,7 +1287,7 @@ ZEND_FUNCTION(interface_exists)
zend_bool autoload = 1; zend_bool autoload = 1;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &iface_name, &autoload) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &iface_name, &autoload) == FAILURE) {
return; return;
} }
#else #else
@ -1312,7 +1312,7 @@ ZEND_FUNCTION(interface_exists)
RETURN_BOOL(ce && ce->ce_flags & ZEND_ACC_INTERFACE); RETURN_BOOL(ce && ce->ce_flags & ZEND_ACC_INTERFACE);
} }
ce = zend_lookup_class(iface_name TSRMLS_CC); ce = zend_lookup_class(iface_name);
if (ce) { if (ce) {
RETURN_BOOL((ce->ce_flags & ZEND_ACC_INTERFACE) > 0); RETURN_BOOL((ce->ce_flags & ZEND_ACC_INTERFACE) > 0);
} else { } else {
@ -1330,7 +1330,7 @@ ZEND_FUNCTION(trait_exists)
zend_bool autoload = 1; zend_bool autoload = 1;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &trait_name, &autoload) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &trait_name, &autoload) == FAILURE) {
return; return;
} }
#else #else
@ -1355,7 +1355,7 @@ ZEND_FUNCTION(trait_exists)
RETURN_BOOL(ce && ((ce->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)); RETURN_BOOL(ce && ((ce->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS));
} }
ce = zend_lookup_class(trait_name TSRMLS_CC); ce = zend_lookup_class(trait_name);
if (ce) { if (ce) {
RETURN_BOOL((ce->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); RETURN_BOOL((ce->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
} else { } else {
@ -1374,7 +1374,7 @@ ZEND_FUNCTION(function_exists)
zend_string *lcname; zend_string *lcname;
#ifndef FAST_ZPP #ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
return; return;
} }
#else #else
@ -1414,15 +1414,15 @@ ZEND_FUNCTION(class_alias)
size_t alias_name_len; size_t alias_name_len;
zend_bool autoload = 1; zend_bool autoload = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|b", &class_name, &alias_name, &alias_name_len, &autoload) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ss|b", &class_name, &alias_name, &alias_name_len, &autoload) == FAILURE) {
return; return;
} }
ce = zend_lookup_class_ex(class_name, NULL, autoload TSRMLS_CC); ce = zend_lookup_class_ex(class_name, NULL, autoload);
if (ce) { if (ce) {
if (ce->type == ZEND_USER_CLASS) { if (ce->type == ZEND_USER_CLASS) {
if (zend_register_class_alias_ex(alias_name, alias_name_len, ce TSRMLS_CC) == SUCCESS) { if (zend_register_class_alias_ex(alias_name, alias_name_len, ce) == SUCCESS) {
RETURN_TRUE; RETURN_TRUE;
} else { } else {
zend_error(E_WARNING, "Cannot redeclare class %s", alias_name); zend_error(E_WARNING, "Cannot redeclare class %s", alias_name);
@ -1446,7 +1446,7 @@ ZEND_FUNCTION(leak)
{ {
zend_long leakbytes=3; zend_long leakbytes=3;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &leakbytes) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &leakbytes) == FAILURE) {
return; return;
} }
@ -1460,7 +1460,7 @@ ZEND_FUNCTION(leak_variable)
zval *zv; zval *zv;
zend_bool leak_data = 0; zend_bool leak_data = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &zv, &leak_data) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zv, &leak_data) == FAILURE) {
return; return;
} }
@ -1515,7 +1515,7 @@ ZEND_FUNCTION(trigger_error)
char *message; char *message;
size_t message_len; size_t message_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &message, &message_len, &error_type) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &message, &message_len, &error_type) == FAILURE) {
return; return;
} }
@ -1544,14 +1544,14 @@ ZEND_FUNCTION(set_error_handler)
zend_string *error_handler_name = NULL; zend_string *error_handler_name = NULL;
zend_long error_type = E_ALL; zend_long error_type = E_ALL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|l", &error_handler, &error_type) == FAILURE) {
return; return;
} }
if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */ if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name->val:"unknown"); get_active_function_name(), error_handler_name?error_handler_name->val:"unknown");
zend_string_release(error_handler_name); zend_string_release(error_handler_name);
return; return;
} }
@ -1608,14 +1608,14 @@ ZEND_FUNCTION(set_exception_handler)
zval *exception_handler; zval *exception_handler;
zend_string *exception_handler_name = NULL; zend_string *exception_handler_name = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception_handler) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &exception_handler) == FAILURE) {
return; return;
} }
if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */ if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
if (!zend_is_callable(exception_handler, 0, &exception_handler_name TSRMLS_CC)) { if (!zend_is_callable(exception_handler, 0, &exception_handler_name)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name->val:"unknown"); get_active_function_name(), exception_handler_name?exception_handler_name->val:"unknown");
zend_string_release(exception_handler_name); zend_string_release(exception_handler_name);
return; return;
} }
@ -1655,7 +1655,7 @@ ZEND_FUNCTION(restore_exception_handler)
} }
/* }}} */ /* }}} */
static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ static int copy_class_or_interface_name(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{ {
zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el); zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
zval *array = va_arg(args, zval *); zval *array = va_arg(args, zval *);
@ -1689,7 +1689,7 @@ ZEND_FUNCTION(get_declared_traits)
} }
array_init(return_value); array_init(return_value);
zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, copy_class_or_interface_name, 3, return_value, mask, comply); zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
} }
/* }}} */ /* }}} */
@ -1705,7 +1705,7 @@ ZEND_FUNCTION(get_declared_classes)
} }
array_init(return_value); array_init(return_value);
zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, copy_class_or_interface_name, 3, return_value, mask, comply); zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
} }
/* }}} */ /* }}} */
@ -1721,11 +1721,11 @@ ZEND_FUNCTION(get_declared_interfaces)
} }
array_init(return_value); array_init(return_value);
zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, copy_class_or_interface_name, 3, return_value, mask, comply); zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
} }
/* }}} */ /* }}} */
static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{ {
zend_function *func = Z_PTR_P(zv); zend_function *func = Z_PTR_P(zv);
zval *internal_ar = va_arg(args, zval *), zval *internal_ar = va_arg(args, zval *),
@ -1759,7 +1759,7 @@ ZEND_FUNCTION(get_defined_functions)
array_init(&user); array_init(&user);
array_init(return_value); array_init(return_value);
zend_hash_apply_with_arguments(EG(function_table) TSRMLS_CC, copy_function_name, 2, &internal, &user); zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 2, &internal, &user);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal); zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user); zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user);
@ -1770,7 +1770,7 @@ ZEND_FUNCTION(get_defined_functions)
Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */ Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
ZEND_FUNCTION(get_defined_vars) ZEND_FUNCTION(get_defined_vars)
{ {
zend_array *symbol_table = zend_rebuild_symbol_table(TSRMLS_C); zend_array *symbol_table = zend_rebuild_symbol_table();
ZVAL_NEW_ARR(return_value); ZVAL_NEW_ARR(return_value);
zend_array_dup(Z_ARRVAL_P(return_value), &symbol_table->ht); zend_array_dup(Z_ARRVAL_P(return_value), &symbol_table->ht);
@ -1788,7 +1788,7 @@ ZEND_FUNCTION(create_function)
int retval; int retval;
char *eval_name; char *eval_name;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &function_args, &function_args_len, &function_code, &function_code_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &function_args, &function_args_len, &function_code, &function_code_len) == FAILURE) {
return; return;
} }
@ -1813,8 +1813,8 @@ ZEND_FUNCTION(create_function)
eval_code[eval_code_length++] = '}'; eval_code[eval_code_length++] = '}';
eval_code[eval_code_length] = '\0'; eval_code[eval_code_length] = '\0';
eval_name = zend_make_compiled_string_description("runtime-created function" TSRMLS_CC); eval_name = zend_make_compiled_string_description("runtime-created function");
retval = zend_eval_stringl(eval_code, eval_code_length, NULL, eval_name TSRMLS_CC); retval = zend_eval_stringl(eval_code, eval_code_length, NULL, eval_name);
efree(eval_code); efree(eval_code);
efree(eval_name); efree(eval_name);
@ -1871,11 +1871,11 @@ ZEND_FUNCTION(get_resource_type)
const char *resource_type; const char *resource_type;
zval *z_resource_type; zval *z_resource_type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_resource_type) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &z_resource_type) == FAILURE) {
return; return;
} }
resource_type = zend_rsrc_list_get_rsrc_type(Z_RES_P(z_resource_type) TSRMLS_CC); resource_type = zend_rsrc_list_get_rsrc_type(Z_RES_P(z_resource_type));
if (resource_type) { if (resource_type) {
RETURN_STRING(resource_type); RETURN_STRING(resource_type);
} else { } else {
@ -1893,7 +1893,7 @@ ZEND_FUNCTION(get_resources)
zend_ulong index; zend_ulong index;
zval *val; zval *val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &type) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &type) == FAILURE) {
return; return;
} }
@ -1932,7 +1932,7 @@ ZEND_FUNCTION(get_resources)
} }
/* }}} */ /* }}} */
static int add_extension_info(zval *item, void *arg TSRMLS_DC) /* {{{ */ static int add_extension_info(zval *item, void *arg) /* {{{ */
{ {
zval *name_array = (zval *)arg; zval *name_array = (zval *)arg;
zend_module_entry *module = (zend_module_entry*)Z_PTR_P(item); zend_module_entry *module = (zend_module_entry*)Z_PTR_P(item);
@ -1941,7 +1941,7 @@ static int add_extension_info(zval *item, void *arg TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static int add_zendext_info(zend_extension *ext, void *arg TSRMLS_DC) /* {{{ */ static int add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
{ {
zval *name_array = (zval *)arg; zval *name_array = (zval *)arg;
add_next_index_string(name_array, ext->name); add_next_index_string(name_array, ext->name);
@ -1949,7 +1949,7 @@ static int add_zendext_info(zend_extension *ext, void *arg TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static int add_constant_info(zval *item, void *arg TSRMLS_DC) /* {{{ */ static int add_constant_info(zval *item, void *arg) /* {{{ */
{ {
zval *name_array = (zval *)arg; zval *name_array = (zval *)arg;
zend_constant *constant = (zend_constant*)Z_PTR_P(item); zend_constant *constant = (zend_constant*)Z_PTR_P(item);
@ -1972,16 +1972,16 @@ ZEND_FUNCTION(get_loaded_extensions)
{ {
zend_bool zendext = 0; zend_bool zendext = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &zendext) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &zendext) == FAILURE) {
return; return;
} }
array_init(return_value); array_init(return_value);
if (zendext) { if (zendext) {
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t)add_zendext_info, return_value TSRMLS_CC); zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t)add_zendext_info, return_value);
} else { } else {
zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value TSRMLS_CC); zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value);
} }
} }
/* }}} */ /* }}} */
@ -1992,7 +1992,7 @@ ZEND_FUNCTION(get_defined_constants)
{ {
zend_bool categorize = 0; zend_bool categorize = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &categorize) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &categorize) == FAILURE) {
return; return;
} }
@ -2043,12 +2043,12 @@ ZEND_FUNCTION(get_defined_constants)
efree(module_names); efree(module_names);
efree(modules); efree(modules);
} else { } else {
zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value TSRMLS_CC); zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value);
} }
} }
/* }}} */ /* }}} */
static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TSRMLS_DC) /* {{{ */ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /* {{{ */
{ {
uint32_t num_args = ZEND_CALL_NUM_ARGS(call); uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
@ -2084,7 +2084,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TS
} }
/* }}} */ /* }}} */
void debug_print_backtrace_args(zval *arg_array TSRMLS_DC) /* {{{ */ void debug_print_backtrace_args(zval *arg_array) /* {{{ */
{ {
zval *tmp; zval *tmp;
int i = 0; int i = 0;
@ -2093,7 +2093,7 @@ void debug_print_backtrace_args(zval *arg_array TSRMLS_DC) /* {{{ */
if (i++) { if (i++) {
ZEND_PUTS(", "); ZEND_PUTS(", ");
} }
zend_print_flat_zval_r(tmp TSRMLS_CC); zend_print_flat_zval_r(tmp);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
} }
/* }}} */ /* }}} */
@ -2115,7 +2115,7 @@ ZEND_FUNCTION(debug_print_backtrace)
zend_long options = 0; zend_long options = 0;
zend_long limit = 0; zend_long limit = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &options, &limit) == FAILURE) {
return; return;
} }
@ -2199,7 +2199,7 @@ ZEND_FUNCTION(debug_print_backtrace)
} }
if (func->type != ZEND_EVAL_CODE) { if (func->type != ZEND_EVAL_CODE) {
if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0) { if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0) {
debug_backtrace_get_args(call, &arg_array TSRMLS_CC); debug_backtrace_get_args(call, &arg_array);
} }
} }
} else { } else {
@ -2249,7 +2249,7 @@ ZEND_FUNCTION(debug_print_backtrace)
} }
zend_printf("%s(", function_name); zend_printf("%s(", function_name);
if (Z_TYPE(arg_array) != IS_UNDEF) { if (Z_TYPE(arg_array) != IS_UNDEF) {
debug_print_backtrace_args(&arg_array TSRMLS_CC); debug_print_backtrace_args(&arg_array);
zval_ptr_dtor(&arg_array); zval_ptr_dtor(&arg_array);
} }
if (filename) { if (filename) {
@ -2285,7 +2285,7 @@ ZEND_FUNCTION(debug_print_backtrace)
/* }}} */ /* }}} */
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC) /* {{{ */ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit) /* {{{ */
{ {
zend_execute_data *call, *ptr, *skip; zend_execute_data *call, *ptr, *skip;
zend_object *object; zend_object *object;
@ -2427,7 +2427,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
func->type != ZEND_EVAL_CODE) { func->type != ZEND_EVAL_CODE) {
zval args; zval args;
debug_backtrace_get_args(call, &args TSRMLS_CC); debug_backtrace_get_args(call, &args);
add_assoc_zval_ex(&stack_frame, "args", sizeof("args")-1, &args); add_assoc_zval_ex(&stack_frame, "args", sizeof("args")-1, &args);
} }
} else { } else {
@ -2497,11 +2497,11 @@ ZEND_FUNCTION(debug_backtrace)
zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT; zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
zend_long limit = 0; zend_long limit = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &options, &limit) == FAILURE) {
return; return;
} }
zend_fetch_debug_backtrace(return_value, 1, options, limit TSRMLS_CC); zend_fetch_debug_backtrace(return_value, 1, options, limit);
} }
/* }}} */ /* }}} */
@ -2513,7 +2513,7 @@ ZEND_FUNCTION(extension_loaded)
size_t extension_name_len; size_t extension_name_len;
zend_string *lcname; zend_string *lcname;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &extension_name, &extension_name_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &extension_name, &extension_name_len) == FAILURE) {
return; return;
} }
@ -2539,7 +2539,7 @@ ZEND_FUNCTION(get_extension_funcs)
zend_module_entry *module; zend_module_entry *module;
zend_function *zif; zend_function *zif;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &extension_name, &extension_name_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &extension_name, &extension_name_len) == FAILURE) {
return; return;
} }
if (strncasecmp(extension_name, "zend", sizeof("zend"))) { if (strncasecmp(extension_name, "zend", sizeof("zend"))) {

View file

@ -22,10 +22,10 @@
#ifndef ZEND_BUILTIN_FUNCTIONS_H #ifndef ZEND_BUILTIN_FUNCTIONS_H
#define ZEND_BUILTIN_FUNCTIONS_H #define ZEND_BUILTIN_FUNCTIONS_H
int zend_startup_builtin_functions(TSRMLS_D); int zend_startup_builtin_functions(void);
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC); ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit);
END_EXTERN_C() END_EXTERN_C()
#endif /* ZEND_BUILTIN_FUNCTIONS_H */ #endif /* ZEND_BUILTIN_FUNCTIONS_H */

View file

@ -55,7 +55,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */
efree(arguments); efree(arguments);
zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure"); zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure");
RETVAL_FALSE; RETVAL_FALSE;
} else if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) { } else if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) {
RETVAL_FALSE; RETVAL_FALSE;
} }
efree(arguments); efree(arguments);
@ -78,7 +78,7 @@ ZEND_METHOD(Closure, call)
int my_param_count = 0; int my_param_count = 0;
zend_function my_function; zend_function my_function;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o*", &newthis, &my_params, &my_param_count) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "o*", &newthis, &my_params, &my_param_count) == FAILURE) {
return; return;
} }
@ -93,14 +93,14 @@ ZEND_METHOD(Closure, call)
if (closure->func.type == ZEND_INTERNAL_FUNCTION) { if (closure->func.type == ZEND_INTERNAL_FUNCTION) {
/* verify that we aren't binding internal function to a wrong object */ /* verify that we aren't binding internal function to a wrong object */
if ((closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0 && if ((closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0 &&
!instanceof_function(Z_OBJCE_P(newthis), closure->func.common.scope TSRMLS_CC)) { !instanceof_function(Z_OBJCE_P(newthis), closure->func.common.scope)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s", closure->func.common.scope->name->val, closure->func.common.function_name->val, Z_OBJCE_P(newthis)->name->val); zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s", closure->func.common.scope->name->val, closure->func.common.function_name->val, Z_OBJCE_P(newthis)->name->val);
return; return;
} }
} }
/* This should never happen as closures will always be callable */ /* This should never happen as closures will always be callable */
if (zend_fcall_info_init(zclosure, 0, &fci, &fci_cache, NULL, NULL TSRMLS_CC) != SUCCESS) { if (zend_fcall_info_init(zclosure, 0, &fci, &fci_cache, NULL, NULL) != SUCCESS) {
ZEND_ASSERT(0); ZEND_ASSERT(0);
} }
@ -115,7 +115,7 @@ ZEND_METHOD(Closure, call)
my_function.common.scope = Z_OBJCE_P(newthis); my_function.common.scope = Z_OBJCE_P(newthis);
fci_cache.function_handler = &my_function; fci_cache.function_handler = &my_function;
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(closure_result) != IS_UNDEF) { if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(closure_result) != IS_UNDEF) {
ZVAL_COPY_VALUE(return_value, &closure_result); ZVAL_COPY_VALUE(return_value, &closure_result);
} }
} }
@ -129,7 +129,7 @@ ZEND_METHOD(Closure, bind)
zend_closure *closure; zend_closure *closure;
zend_class_entry *ce; zend_class_entry *ce;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo!|z", &zclosure, zend_ce_closure, &newthis, &scope_arg) == FAILURE) { if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oo!|z", &zclosure, zend_ce_closure, &newthis, &scope_arg) == FAILURE) {
RETURN_NULL(); RETURN_NULL();
} }
@ -148,7 +148,7 @@ ZEND_METHOD(Closure, bind)
zend_string *class_name = zval_get_string(scope_arg); zend_string *class_name = zval_get_string(scope_arg);
if (zend_string_equals_literal(class_name, "static")) { if (zend_string_equals_literal(class_name, "static")) {
ce = closure->func.common.scope; ce = closure->func.common.scope;
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1 TSRMLS_CC)) == NULL) { } else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
zend_error(E_WARNING, "Class '%s' not found", class_name->val); zend_error(E_WARNING, "Class '%s' not found", class_name->val);
zend_string_release(class_name); zend_string_release(class_name);
RETURN_NULL(); RETURN_NULL();
@ -159,24 +159,24 @@ ZEND_METHOD(Closure, bind)
ce = closure->func.common.scope; ce = closure->func.common.scope;
} }
zend_create_closure(return_value, &closure->func, ce, newthis TSRMLS_CC); zend_create_closure(return_value, &closure->func, ce, newthis);
} }
/* }}} */ /* }}} */
static zend_function *zend_closure_get_constructor(zend_object *object TSRMLS_DC) /* {{{ */ static zend_function *zend_closure_get_constructor(zend_object *object) /* {{{ */
{ {
zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed"); zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed");
return NULL; return NULL;
} }
/* }}} */ /* }}} */
static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ static int zend_closure_compare_objects(zval *o1, zval *o2) /* {{{ */
{ {
return (Z_OBJ_P(o1) != Z_OBJ_P(o2)); return (Z_OBJ_P(o1) != Z_OBJ_P(o2));
} }
/* }}} */ /* }}} */
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object TSRMLS_DC) /* {{{ */ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)object; zend_closure *closure = (zend_closure *)object;
zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function)); zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));
@ -193,21 +193,21 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object TSRML
} }
/* }}} */ /* }}} */
ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC) /* {{{ */ ZEND_API const zend_function *zend_get_closure_method_def(zval *obj) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); zend_closure *closure = (zend_closure *)Z_OBJ_P(obj);
return &closure->func; return &closure->func;
} }
/* }}} */ /* }}} */
ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC) /* {{{ */ ZEND_API zval* zend_get_closure_this_ptr(zval *obj) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); zend_closure *closure = (zend_closure *)Z_OBJ_P(obj);
return &closure->this_ptr; return &closure->this_ptr;
} }
/* }}} */ /* }}} */
static zend_function *zend_closure_get_method(zend_object **object, zend_string *method, const zval *key TSRMLS_DC) /* {{{ */ static zend_function *zend_closure_get_method(zend_object **object, zend_string *method, const zval *key) /* {{{ */
{ {
zend_string *lc_name; zend_string *lc_name;
@ -215,34 +215,34 @@ static zend_function *zend_closure_get_method(zend_object **object, zend_string
zend_str_tolower_copy(lc_name->val, method->val, method->len); zend_str_tolower_copy(lc_name->val, method->val, method->len);
if (zend_string_equals_literal(method, ZEND_INVOKE_FUNC_NAME)) { if (zend_string_equals_literal(method, ZEND_INVOKE_FUNC_NAME)) {
zend_string_free(lc_name); zend_string_free(lc_name);
return zend_get_closure_invoke_method(*object TSRMLS_CC); return zend_get_closure_invoke_method(*object);
} }
zend_string_free(lc_name); zend_string_free(lc_name);
return std_object_handlers.get_method(object, method, key TSRMLS_CC); return std_object_handlers.get_method(object, method, key);
} }
/* }}} */ /* }}} */
static zval *zend_closure_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) /* {{{ */ static zval *zend_closure_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */
{ {
ZEND_CLOSURE_PROPERTY_ERROR(); ZEND_CLOSURE_PROPERTY_ERROR();
return &EG(uninitialized_zval); return &EG(uninitialized_zval);
} }
/* }}} */ /* }}} */
static void zend_closure_write_property(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) /* {{{ */ static void zend_closure_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
{ {
ZEND_CLOSURE_PROPERTY_ERROR(); ZEND_CLOSURE_PROPERTY_ERROR();
} }
/* }}} */ /* }}} */
static zval *zend_closure_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot TSRMLS_DC) /* {{{ */ static zval *zend_closure_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
{ {
ZEND_CLOSURE_PROPERTY_ERROR(); ZEND_CLOSURE_PROPERTY_ERROR();
return NULL; return NULL;
} }
/* }}} */ /* }}} */
static int zend_closure_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot TSRMLS_DC) /* {{{ */ static int zend_closure_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */
{ {
if (has_set_exists != 2) { if (has_set_exists != 2) {
ZEND_CLOSURE_PROPERTY_ERROR(); ZEND_CLOSURE_PROPERTY_ERROR();
@ -251,17 +251,17 @@ static int zend_closure_has_property(zval *object, zval *member, int has_set_exi
} }
/* }}} */ /* }}} */
static void zend_closure_unset_property(zval *object, zval *member, void **cache_slot TSRMLS_DC) /* {{{ */ static void zend_closure_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */
{ {
ZEND_CLOSURE_PROPERTY_ERROR(); ZEND_CLOSURE_PROPERTY_ERROR();
} }
/* }}} */ /* }}} */
static void zend_closure_free_storage(zend_object *object TSRMLS_DC) /* {{{ */ static void zend_closure_free_storage(zend_object *object) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)object; zend_closure *closure = (zend_closure *)object;
zend_object_std_dtor(&closure->std TSRMLS_CC); zend_object_std_dtor(&closure->std);
if (closure->func.type == ZEND_USER_FUNCTION) { if (closure->func.type == ZEND_USER_FUNCTION) {
zend_execute_data *ex = EG(current_execute_data); zend_execute_data *ex = EG(current_execute_data);
@ -271,7 +271,7 @@ static void zend_closure_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
} }
ex = ex->prev_execute_data; ex = ex->prev_execute_data;
} }
destroy_op_array(&closure->func.op_array TSRMLS_CC); destroy_op_array(&closure->func.op_array);
} }
if (closure->debug_info != NULL) { if (closure->debug_info != NULL) {
@ -285,31 +285,31 @@ static void zend_closure_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_object *zend_closure_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ static zend_object *zend_closure_new(zend_class_entry *class_type) /* {{{ */
{ {
zend_closure *closure; zend_closure *closure;
closure = emalloc(sizeof(zend_closure)); closure = emalloc(sizeof(zend_closure));
memset(closure, 0, sizeof(zend_closure)); memset(closure, 0, sizeof(zend_closure));
zend_object_std_init(&closure->std, class_type TSRMLS_CC); zend_object_std_init(&closure->std, class_type);
closure->std.handlers = &closure_handlers; closure->std.handlers = &closure_handlers;
return (zend_object*)closure; return (zend_object*)closure;
} }
/* }}} */ /* }}} */
static zend_object *zend_closure_clone(zval *zobject TSRMLS_DC) /* {{{ */ static zend_object *zend_closure_clone(zval *zobject) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)Z_OBJ_P(zobject); zend_closure *closure = (zend_closure *)Z_OBJ_P(zobject);
zval result; zval result;
zend_create_closure(&result, &closure->func, closure->func.common.scope, &closure->this_ptr TSRMLS_CC); zend_create_closure(&result, &closure->func, closure->func.common.scope, &closure->this_ptr);
return Z_OBJ(result); return Z_OBJ(result);
} }
/* }}} */ /* }}} */
int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC) /* {{{ */ int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */
{ {
zend_closure *closure; zend_closure *closure;
@ -335,7 +335,7 @@ int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function
} }
/* }}} */ /* }}} */
static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)Z_OBJ_P(object); zend_closure *closure = (zend_closure *)Z_OBJ_P(object);
zval val; zval val;
@ -390,7 +390,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_
} }
/* }}} */ /* }}} */
static HashTable *zend_closure_get_gc(zval *obj, zval **table, int *n TSRMLS_DC) /* {{{ */ static HashTable *zend_closure_get_gc(zval *obj, zval **table, int *n) /* {{{ */
{ {
zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); zend_closure *closure = (zend_closure *)Z_OBJ_P(obj);
@ -439,12 +439,12 @@ static const zend_function_entry closure_functions[] = {
ZEND_FE_END ZEND_FE_END
}; };
void zend_register_closure_ce(TSRMLS_D) /* {{{ */ void zend_register_closure_ce(void) /* {{{ */
{ {
zend_class_entry ce; zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Closure", closure_functions); INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
zend_ce_closure = zend_register_internal_class(&ce TSRMLS_CC); zend_ce_closure = zend_register_internal_class(&ce);
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL; zend_ce_closure->ce_flags |= ZEND_ACC_FINAL;
zend_ce_closure->create_object = zend_closure_new; zend_ce_closure->create_object = zend_closure_new;
zend_ce_closure->serialize = zend_class_serialize_deny; zend_ce_closure->serialize = zend_class_serialize_deny;
@ -468,7 +468,7 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zval *this_ptr TSRMLS_DC) /* {{{ */ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zval *this_ptr) /* {{{ */
{ {
zend_closure *closure; zend_closure *closure;
@ -491,19 +491,19 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
ALLOC_HASHTABLE(closure->func.op_array.static_variables); ALLOC_HASHTABLE(closure->func.op_array.static_variables);
zend_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_apply_with_arguments(static_variables TSRMLS_CC, zval_copy_static_var, 1, closure->func.op_array.static_variables); zend_hash_apply_with_arguments(static_variables, zval_copy_static_var, 1, closure->func.op_array.static_variables);
} }
closure->func.op_array.run_time_cache = NULL; closure->func.op_array.run_time_cache = NULL;
(*closure->func.op_array.refcount)++; (*closure->func.op_array.refcount)++;
} else { } else {
/* verify that we aren't binding internal function to a wrong scope */ /* verify that we aren't binding internal function to a wrong scope */
if(func->common.scope != NULL) { if(func->common.scope != NULL) {
if(scope && !instanceof_function(scope, func->common.scope TSRMLS_CC)) { if(scope && !instanceof_function(scope, func->common.scope)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to scope class %s", func->common.scope->name->val, func->common.function_name->val, scope->name->val); zend_error(E_WARNING, "Cannot bind function %s::%s to scope class %s", func->common.scope->name->val, func->common.function_name->val, scope->name->val);
scope = NULL; scope = NULL;
} }
if(scope && this_ptr && (func->common.fn_flags & ZEND_ACC_STATIC) == 0 && if(scope && this_ptr && (func->common.fn_flags & ZEND_ACC_STATIC) == 0 &&
!instanceof_function(Z_OBJCE_P(this_ptr), closure->func.common.scope TSRMLS_CC)) { !instanceof_function(Z_OBJCE_P(this_ptr), closure->func.common.scope)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s", func->common.scope->name->val, func->common.function_name->val, Z_OBJCE_P(this_ptr)->name->val); zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s", func->common.scope->name->val, func->common.function_name->val, Z_OBJCE_P(this_ptr)->name->val);
scope = NULL; scope = NULL;
this_ptr = NULL; this_ptr = NULL;

View file

@ -24,14 +24,14 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
void zend_register_closure_ce(TSRMLS_D); void zend_register_closure_ce(void);
extern ZEND_API zend_class_entry *zend_ce_closure; extern ZEND_API zend_class_entry *zend_ce_closure;
ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zval *this_ptr TSRMLS_DC); ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zval *this_ptr);
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *obj TSRMLS_DC); ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *obj);
ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC); ZEND_API const zend_function *zend_get_closure_method_def(zval *obj);
ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC); ZEND_API zval* zend_get_closure_this_ptr(zval *obj);
END_EXTERN_C() END_EXTERN_C()

File diff suppressed because it is too large Load diff

View file

@ -113,12 +113,12 @@ typedef union _zend_parser_stack_elem {
zend_ulong num; zend_ulong num;
} zend_parser_stack_elem; } zend_parser_stack_elem;
void zend_compile_top_stmt(zend_ast *ast TSRMLS_DC); void zend_compile_top_stmt(zend_ast *ast);
void zend_compile_stmt(zend_ast *ast TSRMLS_DC); void zend_compile_stmt(zend_ast *ast);
void zend_compile_expr(znode *node, zend_ast *ast TSRMLS_DC); void zend_compile_expr(znode *node, zend_ast *ast);
void zend_compile_var(znode *node, zend_ast *ast, uint32_t type TSRMLS_DC); void zend_compile_var(znode *node, zend_ast *ast, uint32_t type);
void zend_eval_const_expr(zend_ast **ast_ptr TSRMLS_DC); void zend_eval_const_expr(zend_ast **ast_ptr);
void zend_const_expr_to_zval(zval *result, zend_ast *ast TSRMLS_DC); void zend_const_expr_to_zval(zval *result, zend_ast *ast);
#define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC #define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC
#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC #define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC
@ -597,65 +597,65 @@ struct _zend_execute_data {
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
void init_compiler(TSRMLS_D); void init_compiler(void);
void shutdown_compiler(TSRMLS_D); void shutdown_compiler(void);
void zend_init_compiler_data_structures(TSRMLS_D); void zend_init_compiler_data_structures(void);
void zend_init_compiler_context(TSRMLS_D); void zend_init_compiler_context(void);
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC); extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename);
ZEND_API int lex_scan(zval *zendlval TSRMLS_DC); ZEND_API int lex_scan(zval *zendlval);
void startup_scanner(TSRMLS_D); void startup_scanner(void);
void shutdown_scanner(TSRMLS_D); void shutdown_scanner(void);
ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename TSRMLS_DC); ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename);
ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename TSRMLS_DC); ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename);
ZEND_API zend_string *zend_get_compiled_filename(TSRMLS_D); ZEND_API zend_string *zend_get_compiled_filename(void);
ZEND_API int zend_get_compiled_lineno(TSRMLS_D); ZEND_API int zend_get_compiled_lineno(void);
ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D); ZEND_API size_t zend_get_scanned_file_offset(void);
ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var); ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var);
#ifdef ZTS #ifdef ZTS
const char *zend_get_zendtext(TSRMLS_D); const char *zend_get_zendtext(void);
int zend_get_zendleng(TSRMLS_D); int zend_get_zendleng(void);
#endif #endif
typedef int (*unary_op_type)(zval *, zval * TSRMLS_DC); typedef int (*unary_op_type)(zval *, zval *);
typedef int (*binary_op_type)(zval *, zval *, zval * TSRMLS_DC); typedef int (*binary_op_type)(zval *, zval *, zval *);
ZEND_API unary_op_type get_unary_op(int opcode); ZEND_API unary_op_type get_unary_op(int opcode);
ZEND_API binary_op_type get_binary_op(int opcode); ZEND_API binary_op_type get_binary_op(int opcode);
void zend_stop_lexing(TSRMLS_D); void zend_stop_lexing(void);
void zend_emit_final_return(zval *zv TSRMLS_DC); void zend_emit_final_return(zval *zv);
zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right); zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right);
uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag); uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag);
zend_ast *zend_ast_append_doc_comment(zend_ast *list TSRMLS_DC); zend_ast *zend_ast_append_doc_comment(zend_ast *list);
void zend_handle_encoding_declaration(zend_ast *ast TSRMLS_DC); void zend_handle_encoding_declaration(zend_ast *ast);
/* parser-driven code generators */ /* parser-driven code generators */
void zend_do_free(znode *op1 TSRMLS_DC); void zend_do_free(znode *op1);
ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time TSRMLS_DC); ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time);
ZEND_API zend_class_entry *do_bind_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC); ZEND_API zend_class_entry *do_bind_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time);
ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC); ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time);
ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC); ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array);
/* Functions for a null terminated pointer list, used for traits parsing and compilation */ /* Functions for a null terminated pointer list, used for traits parsing and compilation */
void zend_init_list(void *result, void *item TSRMLS_DC); void zend_init_list(void *result, void *item);
void zend_add_to_list(void *result, void *item TSRMLS_DC); void zend_add_to_list(void *result, void *item);
void zend_do_extended_info(TSRMLS_D); void zend_do_extended_info(void);
void zend_do_extended_fcall_begin(TSRMLS_D); void zend_do_extended_fcall_begin(void);
void zend_do_extended_fcall_end(TSRMLS_D); void zend_do_extended_fcall_end(void);
void zend_verify_namespace(TSRMLS_D); void zend_verify_namespace(void);
void zend_do_end_compilation(TSRMLS_D); void zend_do_end_compilation(void);
void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC); void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2);
void zend_release_labels(int temporary TSRMLS_DC); void zend_release_labels(int temporary);
ZEND_API void function_add_ref(zend_function *function); ZEND_API void function_add_ref(zend_function *function);
@ -663,22 +663,22 @@ ZEND_API void function_add_ref(zend_function *function);
/* helper functions in zend_language_scanner.l */ /* helper functions in zend_language_scanner.l */
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type);
ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC); ZEND_API zend_op_array *compile_string(zval *source_string, char *filename);
ZEND_API zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC); ZEND_API zend_op_array *compile_filename(int type, zval *filename);
ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_count, ...); ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...);
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC); ZEND_API int open_file_for_scanning(zend_file_handle *file_handle);
ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size TSRMLS_DC); ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size);
ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC); ZEND_API void destroy_op_array(zend_op_array *op_array);
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC); ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle);
ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC); ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce);
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC); ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce);
ZEND_API void zend_cleanup_internal_classes(TSRMLS_D); ZEND_API void zend_cleanup_internal_classes(void);
ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array); ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array);
ZEND_API int clean_non_persistent_function_full(zval *zv TSRMLS_DC); ZEND_API int clean_non_persistent_function_full(zval *zv);
ZEND_API int clean_non_persistent_class_full(zval *zv TSRMLS_DC); ZEND_API int clean_non_persistent_class_full(zval *zv);
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC); ZEND_API void destroy_zend_function(zend_function *function);
ZEND_API void zend_function_dtor(zval *zv); ZEND_API void zend_function_dtor(zval *zv);
ZEND_API void destroy_zend_class(zval *zv); ZEND_API void destroy_zend_class(zval *zv);
void zend_class_add_ref(zval *zv); void zend_class_add_ref(zval *zv);
@ -691,19 +691,19 @@ ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char
#define ZEND_FUNCTION_DTOR zend_function_dtor #define ZEND_FUNCTION_DTOR zend_function_dtor
#define ZEND_CLASS_DTOR destroy_zend_class #define ZEND_CLASS_DTOR destroy_zend_class
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC); zend_op *get_next_op(zend_op_array *op_array);
void init_op(zend_op *op TSRMLS_DC); void init_op(zend_op *op);
int get_next_op_number(zend_op_array *op_array); int get_next_op_number(zend_op_array *op_array);
int print_class(zend_class_entry *class_entry TSRMLS_DC); int print_class(zend_class_entry *class_entry);
void print_op_array(zend_op_array *op_array, int optimizations); void print_op_array(zend_op_array *op_array, int optimizations);
ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC); ZEND_API int pass_two(zend_op_array *op_array);
zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array); zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
ZEND_API zend_bool zend_is_compiling(TSRMLS_D); ZEND_API zend_bool zend_is_compiling(void);
ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC); ZEND_API char *zend_make_compiled_string_description(const char *name);
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers);
uint32_t zend_get_class_fetch_type(zend_string *name); uint32_t zend_get_class_fetch_type(zend_string *name);
typedef zend_bool (*zend_auto_global_callback)(zend_string *name TSRMLS_DC); typedef zend_bool (*zend_auto_global_callback)(zend_string *name);
typedef struct _zend_auto_global { typedef struct _zend_auto_global {
zend_string *name; zend_string *name;
zend_auto_global_callback auto_global_callback; zend_auto_global_callback auto_global_callback;
@ -711,14 +711,14 @@ typedef struct _zend_auto_global {
zend_bool armed; zend_bool armed;
} zend_auto_global; } zend_auto_global;
ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback TSRMLS_DC); ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback);
ZEND_API void zend_activate_auto_globals(TSRMLS_D); ZEND_API void zend_activate_auto_globals(void);
ZEND_API zend_bool zend_is_auto_global(zend_string *name TSRMLS_DC); ZEND_API zend_bool zend_is_auto_global(zend_string *name);
ZEND_API size_t zend_dirname(char *path, size_t len); ZEND_API size_t zend_dirname(char *path, size_t len);
int zendlex(zend_parser_stack_elem *elem TSRMLS_DC); int zendlex(zend_parser_stack_elem *elem);
int zend_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC); int zend_add_literal(zend_op_array *op_array, zval *zv);
/* BEGIN: OPCODES */ /* BEGIN: OPCODES */

View file

@ -68,21 +68,21 @@ void zend_copy_constants(HashTable *target, HashTable *source)
} }
static int clean_non_persistent_constant(zval *zv TSRMLS_DC) static int clean_non_persistent_constant(zval *zv)
{ {
zend_constant *c = Z_PTR_P(zv); zend_constant *c = Z_PTR_P(zv);
return (c->flags & CONST_PERSISTENT) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; return (c->flags & CONST_PERSISTENT) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
} }
static int clean_non_persistent_constant_full(zval *zv TSRMLS_DC) static int clean_non_persistent_constant_full(zval *zv)
{ {
zend_constant *c = Z_PTR_P(zv); zend_constant *c = Z_PTR_P(zv);
return (c->flags & CONST_PERSISTENT) ? 0 : 1; return (c->flags & CONST_PERSISTENT) ? 0 : 1;
} }
static int clean_module_constant(zval *el, void *arg TSRMLS_DC) static int clean_module_constant(zval *el, void *arg)
{ {
zend_constant *c = (zend_constant *)Z_PTR_P(el); zend_constant *c = (zend_constant *)Z_PTR_P(el);
int module_number = *(int *)arg; int module_number = *(int *)arg;
@ -95,13 +95,13 @@ static int clean_module_constant(zval *el, void *arg TSRMLS_DC)
} }
void clean_module_constants(int module_number TSRMLS_DC) void clean_module_constants(int module_number)
{ {
zend_hash_apply_with_argument(EG(zend_constants), clean_module_constant, (void *) &module_number TSRMLS_CC); zend_hash_apply_with_argument(EG(zend_constants), clean_module_constant, (void *) &module_number);
} }
int zend_startup_constants(TSRMLS_D) int zend_startup_constants(void)
{ {
EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable));
@ -111,7 +111,7 @@ int zend_startup_constants(TSRMLS_D)
void zend_register_standard_constants(TSRMLS_D) void zend_register_standard_constants(void)
{ {
REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS);
@ -144,7 +144,7 @@ void zend_register_standard_constants(TSRMLS_D)
} }
int zend_shutdown_constants(TSRMLS_D) int zend_shutdown_constants(void)
{ {
zend_hash_destroy(EG(zend_constants)); zend_hash_destroy(EG(zend_constants));
free(EG(zend_constants)); free(EG(zend_constants));
@ -152,16 +152,16 @@ int zend_shutdown_constants(TSRMLS_D)
} }
void clean_non_persistent_constants(TSRMLS_D) void clean_non_persistent_constants(void)
{ {
if (EG(full_tables_cleanup)) { if (EG(full_tables_cleanup)) {
zend_hash_apply(EG(zend_constants), clean_non_persistent_constant_full TSRMLS_CC); zend_hash_apply(EG(zend_constants), clean_non_persistent_constant_full);
} else { } else {
zend_hash_reverse_apply(EG(zend_constants), clean_non_persistent_constant TSRMLS_CC); zend_hash_reverse_apply(EG(zend_constants), clean_non_persistent_constant);
} }
} }
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number)
{ {
zend_constant c; zend_constant c;
@ -169,10 +169,10 @@ ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int
c.flags = flags; c.flags = flags;
c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT); c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number; c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC); zend_register_constant(&c);
} }
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number)
{ {
zend_constant c; zend_constant c;
@ -180,10 +180,10 @@ ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zen
c.flags = flags; c.flags = flags;
c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT); c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number; c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC); zend_register_constant(&c);
} }
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number)
{ {
zend_constant c; zend_constant c;
@ -191,11 +191,11 @@ ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zen
c.flags = flags; c.flags = flags;
c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT); c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number; c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC); zend_register_constant(&c);
} }
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number)
{ {
zend_constant c; zend_constant c;
@ -203,11 +203,11 @@ ZEND_API void zend_register_double_constant(const char *name, size_t name_len, d
c.flags = flags; c.flags = flags;
c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT); c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number; c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC); zend_register_constant(&c);
} }
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number)
{ {
zend_constant c; zend_constant c;
@ -215,16 +215,16 @@ ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len,
c.flags = flags; c.flags = flags;
c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT); c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number; c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC); zend_register_constant(&c);
} }
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number TSRMLS_DC) ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number)
{ {
zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number TSRMLS_CC); zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number);
} }
static zend_constant *zend_get_special_constant(const char *name, size_t name_len TSRMLS_DC) static zend_constant *zend_get_special_constant(const char *name, size_t name_len)
{ {
zend_constant *c; zend_constant *c;
static char haltoff[] = "__COMPILER_HALT_OFFSET__"; static char haltoff[] = "__COMPILER_HALT_OFFSET__";
@ -267,7 +267,7 @@ static zend_constant *zend_get_special_constant(const char *name, size_t name_le
zend_string *haltname; zend_string *haltname;
size_t clen; size_t clen;
cfilename = zend_get_executed_filename(TSRMLS_C); cfilename = zend_get_executed_filename();
clen = strlen(cfilename); clen = strlen(cfilename);
/* check for __COMPILER_HALT_OFFSET__ */ /* check for __COMPILER_HALT_OFFSET__ */
haltname = zend_mangle_property_name(haltoff, haltname = zend_mangle_property_name(haltoff,
@ -281,7 +281,7 @@ static zend_constant *zend_get_special_constant(const char *name, size_t name_le
} }
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC) ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len)
{ {
zend_constant *c; zend_constant *c;
ALLOCA_FLAG(use_heap) ALLOCA_FLAG(use_heap)
@ -294,7 +294,7 @@ ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC
c = NULL; c = NULL;
} }
} else { } else {
c = zend_get_special_constant(name, name_len TSRMLS_CC); c = zend_get_special_constant(name, name_len);
} }
free_alloca(lcname, use_heap); free_alloca(lcname, use_heap);
} }
@ -302,7 +302,7 @@ ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC
return c ? &c->value : NULL; return c ? &c->value : NULL;
} }
ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC) ZEND_API zval *zend_get_constant(zend_string *name)
{ {
zend_constant *c; zend_constant *c;
ALLOCA_FLAG(use_heap) ALLOCA_FLAG(use_heap)
@ -315,7 +315,7 @@ ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC)
c = NULL; c = NULL;
} }
} else { } else {
c = zend_get_special_constant(name->val, name->len TSRMLS_CC); c = zend_get_special_constant(name->val, name->len);
} }
free_alloca(lcname, use_heap); free_alloca(lcname, use_heap);
} }
@ -323,7 +323,7 @@ ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC)
return c ? &c->value : NULL; return c ? &c->value : NULL;
} }
ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, zend_ulong flags TSRMLS_DC) ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, zend_ulong flags)
{ {
zend_constant *c; zend_constant *c;
const char *colon; const char *colon;
@ -383,7 +383,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
zend_error(E_ERROR, "Cannot access static:: when no class scope is active"); zend_error(E_ERROR, "Cannot access static:: when no class scope is active");
} }
} else { } else {
ce = zend_fetch_class(class_name, flags TSRMLS_CC); ce = zend_fetch_class(class_name, flags);
} }
free_alloca(lcname, use_heap); free_alloca(lcname, use_heap);
if (ce) { if (ce) {
@ -399,7 +399,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
zend_string_release(class_name); zend_string_release(class_name);
zend_string_free(constant_name); zend_string_free(constant_name);
if (ret_constant && Z_CONSTANT_P(ret_constant)) { if (ret_constant && Z_CONSTANT_P(ret_constant)) {
zval_update_constant_ex(ret_constant, 1, ce TSRMLS_CC); zval_update_constant_ex(ret_constant, 1, ce);
} }
return ret_constant; return ret_constant;
} }
@ -437,19 +437,19 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
} }
/* name requires runtime resolution, need to check non-namespaced name */ /* name requires runtime resolution, need to check non-namespaced name */
if ((flags & IS_CONSTANT_UNQUALIFIED) != 0) { if ((flags & IS_CONSTANT_UNQUALIFIED) != 0) {
return zend_get_constant_str(constant_name, const_name_len TSRMLS_CC); return zend_get_constant_str(constant_name, const_name_len);
} }
return NULL; return NULL;
} }
if (cname) { if (cname) {
return zend_get_constant(cname TSRMLS_CC); return zend_get_constant(cname);
} else { } else {
return zend_get_constant_str(name, name_len TSRMLS_CC); return zend_get_constant_str(name, name_len);
} }
} }
zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_DC) zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags)
{ {
zend_constant *c; zend_constant *c;
@ -465,12 +465,12 @@ zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_
(c->flags & CONST_CS) != 0) { (c->flags & CONST_CS) != 0) {
key--; key--;
c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key) TSRMLS_CC); c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key));
} }
} }
} else { } else {
key--; key--;
c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key) TSRMLS_CC); c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key));
} }
} }
} }
@ -490,7 +490,7 @@ static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_consta
return ret; return ret;
} }
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) ZEND_API int zend_register_constant(zend_constant *c)
{ {
zend_string *lowercase_name = NULL; zend_string *lowercase_name = NULL;
zend_string *name; zend_string *name;
@ -503,14 +503,14 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
if (!(c->flags & CONST_CS)) { if (!(c->flags & CONST_CS)) {
lowercase_name = zend_string_alloc(c->name->len, c->flags & CONST_PERSISTENT); lowercase_name = zend_string_alloc(c->name->len, c->flags & CONST_PERSISTENT);
zend_str_tolower_copy(lowercase_name->val, c->name->val, c->name->len); zend_str_tolower_copy(lowercase_name->val, c->name->val, c->name->len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC); lowercase_name = zend_new_interned_string(lowercase_name);
name = lowercase_name; name = lowercase_name;
} else { } else {
char *slash = strrchr(c->name->val, '\\'); char *slash = strrchr(c->name->val, '\\');
if (slash) { if (slash) {
lowercase_name = zend_string_init(c->name->val, c->name->len, c->flags & CONST_PERSISTENT); lowercase_name = zend_string_init(c->name->val, c->name->len, c->flags & CONST_PERSISTENT);
zend_str_tolower(lowercase_name->val, slash - c->name->val); zend_str_tolower(lowercase_name->val, slash - c->name->val);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC); lowercase_name = zend_new_interned_string(lowercase_name);
name = lowercase_name; name = lowercase_name;
} else { } else {
name = c->name; name = c->name;

View file

@ -37,46 +37,46 @@ typedef struct _zend_constant {
int module_number; int module_number;
} zend_constant; } zend_constant;
#define REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), module_number TSRMLS_CC) #define REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)
#define REGISTER_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number TSRMLS_CC) #define REGISTER_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number)
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number TSRMLS_CC) #define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
#define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number TSRMLS_CC) #define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number)
#define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number TSRMLS_CC) #define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number)
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number TSRMLS_CC) #define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number)
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number TSRMLS_CC) #define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number)
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number TSRMLS_CC) #define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number)
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number TSRMLS_CC) #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number TSRMLS_CC) #define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number)
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number TSRMLS_CC) #define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number)
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number TSRMLS_CC) #define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number)
#define REGISTER_MAIN_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), 0)
#define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0)
#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0)
#define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0)
#define REGISTER_MAIN_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0)
#define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0)
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
void clean_module_constants(int module_number TSRMLS_DC); void clean_module_constants(int module_number);
void free_zend_constant(zval *zv); void free_zend_constant(zval *zv);
int zend_startup_constants(TSRMLS_D); int zend_startup_constants(void);
int zend_shutdown_constants(TSRMLS_D); int zend_shutdown_constants(void);
void zend_register_standard_constants(TSRMLS_D); void zend_register_standard_constants(void);
void clean_non_persistent_constants(TSRMLS_D); void clean_non_persistent_constants(void);
ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC); ZEND_API zval *zend_get_constant(zend_string *name);
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len TSRMLS_DC); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, zend_ulong flags TSRMLS_DC); ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, zend_ulong flags);
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number);
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number);
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC); ZEND_API int zend_register_constant(zend_constant *c);
void zend_copy_constants(HashTable *target, HashTable *sourc); void zend_copy_constants(HashTable *target, HashTable *sourc);
zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_DC); zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags);
END_EXTERN_C() END_EXTERN_C()
#define ZEND_CONSTANT_DTOR free_zend_constant #define ZEND_CONSTANT_DTOR free_zend_constant

View file

@ -28,13 +28,13 @@
#include "zend_generators.h" #include "zend_generators.h"
ZEND_API void zend_register_default_classes(TSRMLS_D) ZEND_API void zend_register_default_classes(void)
{ {
zend_register_interfaces(TSRMLS_C); zend_register_interfaces();
zend_register_default_exception(TSRMLS_C); zend_register_default_exception();
zend_register_iterator_wrapper(TSRMLS_C); zend_register_iterator_wrapper();
zend_register_closure_ce(TSRMLS_C); zend_register_closure_ce();
zend_register_generator_ce(TSRMLS_C); zend_register_generator_ce();
} }
/* /*

View file

@ -24,7 +24,7 @@
#ifdef HAVE_DTRACE #ifdef HAVE_DTRACE
/* PHP DTrace probes {{{ */ /* PHP DTrace probes {{{ */
static inline const char *dtrace_get_executed_filename(TSRMLS_D) static inline const char *dtrace_get_executed_filename(void)
{ {
zend_execute_data *ex = EG(current_execute_data); zend_execute_data *ex = EG(current_execute_data);
@ -34,22 +34,22 @@ static inline const char *dtrace_get_executed_filename(TSRMLS_D)
if (ex) { if (ex) {
return ex->func->op_array.filename->val; return ex->func->op_array.filename->val;
} else { } else {
return zend_get_executed_filename(TSRMLS_C); return zend_get_executed_filename();
} }
} }
ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type)
{ {
zend_op_array *res; zend_op_array *res;
DTRACE_COMPILE_FILE_ENTRY(file_handle->opened_path, (char *)file_handle->filename); DTRACE_COMPILE_FILE_ENTRY(file_handle->opened_path, (char *)file_handle->filename);
res = compile_file(file_handle, type TSRMLS_CC); res = compile_file(file_handle, type);
DTRACE_COMPILE_FILE_RETURN(file_handle->opened_path, (char *)file_handle->filename); DTRACE_COMPILE_FILE_RETURN(file_handle->opened_path, (char *)file_handle->filename);
return res; return res;
} }
/* We wrap the execute function to have fire the execute-entry/return and function-entry/return probes */ /* We wrap the execute function to have fire the execute-entry/return and function-entry/return probes */
ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC) ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data)
{ {
int lineno; int lineno;
const char *scope, *filename, *funcname, *classname; const char *scope, *filename, *funcname, *classname;
@ -58,13 +58,13 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
/* we need filename and lineno for both execute and function probes */ /* we need filename and lineno for both execute and function probes */
if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED() if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()
|| DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) { || DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) {
filename = dtrace_get_executed_filename(TSRMLS_C); filename = dtrace_get_executed_filename();
lineno = zend_get_executed_lineno(TSRMLS_C); lineno = zend_get_executed_lineno();
} }
if (DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) { if (DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) {
classname = get_active_class_name(&scope TSRMLS_CC); classname = get_active_class_name(&scope);
funcname = get_active_function_name(TSRMLS_C); funcname = get_active_function_name();
} }
if (DTRACE_EXECUTE_ENTRY_ENABLED()) { if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
@ -75,7 +75,7 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
DTRACE_FUNCTION_ENTRY((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope); DTRACE_FUNCTION_ENTRY((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
} }
execute_ex(execute_data TSRMLS_CC); execute_ex(execute_data);
if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) { if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) {
DTRACE_FUNCTION_RETURN((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope); DTRACE_FUNCTION_RETURN((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
@ -86,20 +86,20 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
} }
} }
ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC) ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data, zval *return_value)
{ {
int lineno; int lineno;
const char *filename; const char *filename;
if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()) { if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()) {
filename = dtrace_get_executed_filename(TSRMLS_C); filename = dtrace_get_executed_filename();
lineno = zend_get_executed_lineno(TSRMLS_C); lineno = zend_get_executed_lineno();
} }
if (DTRACE_EXECUTE_ENTRY_ENABLED()) { if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
DTRACE_EXECUTE_ENTRY((char *)filename, lineno); DTRACE_EXECUTE_ENTRY((char *)filename, lineno);
} }
execute_internal(execute_data, return_value TSRMLS_CC); execute_internal(execute_data, return_value);
if (DTRACE_EXECUTE_RETURN_ENABLED()) { if (DTRACE_EXECUTE_RETURN_ENABLED()) {
DTRACE_EXECUTE_RETURN((char *)filename, lineno); DTRACE_EXECUTE_RETURN((char *)filename, lineno);

View file

@ -30,13 +30,13 @@ extern "C" {
#endif #endif
#ifdef HAVE_DTRACE #ifdef HAVE_DTRACE
ZEND_API zend_op_array *(*zend_dtrace_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API zend_op_array *(*zend_dtrace_compile_file)(zend_file_handle *file_handle, int type);
ZEND_API void (*zend_dtrace_execute)(zend_op_array *op_array TSRMLS_DC); ZEND_API void (*zend_dtrace_execute)(zend_op_array *op_array);
ZEND_API void (*zend_dtrace_execute_internal)(zend_execute_data *execute_data, zval *return_value TSRMLS_DC); ZEND_API void (*zend_dtrace_execute_internal)(zend_execute_data *execute_data, zval *return_value);
ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type);
ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC); ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data);
ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC); ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data, zval *return_value);
#include <zend_dtrace_gen.h> #include <zend_dtrace_gen.h>
#endif /* HAVE_DTRACE */ #endif /* HAVE_DTRACE */

View file

@ -33,9 +33,9 @@
static zend_class_entry *default_exception_ce; static zend_class_entry *default_exception_ce;
static zend_class_entry *error_exception_ce; static zend_class_entry *error_exception_ce;
static zend_object_handlers default_exception_handlers; static zend_object_handlers default_exception_handlers;
ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC); ZEND_API void (*zend_throw_exception_hook)(zval *ex);
void zend_exception_set_previous(zend_object *exception, zend_object *add_previous TSRMLS_DC) void zend_exception_set_previous(zend_object *exception, zend_object *add_previous)
{ {
zval tmp, *previous, zv, *pzv; zval tmp, *previous, zv, *pzv;
@ -43,16 +43,16 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
return; return;
} }
ZVAL_OBJ(&tmp, add_previous); ZVAL_OBJ(&tmp, add_previous);
if (!instanceof_function(Z_OBJCE(tmp), default_exception_ce TSRMLS_CC)) { if (!instanceof_function(Z_OBJCE(tmp), default_exception_ce)) {
zend_error(E_ERROR, "Cannot set non exception as previous exception"); zend_error(E_ERROR, "Cannot set non exception as previous exception");
return; return;
} }
ZVAL_OBJ(&zv, exception); ZVAL_OBJ(&zv, exception);
pzv = &zv; pzv = &zv;
do { do {
previous = zend_read_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, 1 TSRMLS_CC); previous = zend_read_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, 1);
if (Z_TYPE_P(previous) == IS_NULL) { if (Z_TYPE_P(previous) == IS_NULL) {
zend_update_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, &tmp TSRMLS_CC); zend_update_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, &tmp);
GC_REFCOUNT(add_previous)--; GC_REFCOUNT(add_previous)--;
return; return;
} }
@ -60,10 +60,10 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
} while (pzv && Z_OBJ_P(pzv) != add_previous); } while (pzv && Z_OBJ_P(pzv) != add_previous);
} }
void zend_exception_save(TSRMLS_D) /* {{{ */ void zend_exception_save(void) /* {{{ */
{ {
if (EG(prev_exception)) { if (EG(prev_exception)) {
zend_exception_set_previous(EG(exception), EG(prev_exception) TSRMLS_CC); zend_exception_set_previous(EG(exception), EG(prev_exception));
} }
if (EG(exception)) { if (EG(exception)) {
EG(prev_exception) = EG(exception); EG(prev_exception) = EG(exception);
@ -72,11 +72,11 @@ void zend_exception_save(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
void zend_exception_restore(TSRMLS_D) /* {{{ */ void zend_exception_restore(void) /* {{{ */
{ {
if (EG(prev_exception)) { if (EG(prev_exception)) {
if (EG(exception)) { if (EG(exception)) {
zend_exception_set_previous(EG(exception), EG(prev_exception) TSRMLS_CC); zend_exception_set_previous(EG(exception), EG(prev_exception));
} else { } else {
EG(exception) = EG(prev_exception); EG(exception) = EG(prev_exception);
} }
@ -85,7 +85,7 @@ void zend_exception_restore(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */ ZEND_API void zend_throw_exception_internal(zval *exception) /* {{{ */
{ {
#ifdef HAVE_DTRACE #ifdef HAVE_DTRACE
if (DTRACE_EXCEPTION_THROWN_ENABLED()) { if (DTRACE_EXCEPTION_THROWN_ENABLED()) {
@ -99,7 +99,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
if (exception != NULL) { if (exception != NULL) {
zend_object *previous = EG(exception); zend_object *previous = EG(exception);
zend_exception_set_previous(Z_OBJ_P(exception), EG(exception) TSRMLS_CC); zend_exception_set_previous(Z_OBJ_P(exception), EG(exception));
EG(exception) = Z_OBJ_P(exception); EG(exception) = Z_OBJ_P(exception);
if (previous) { if (previous) {
return; return;
@ -107,13 +107,13 @@ ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
} }
if (!EG(current_execute_data)) { if (!EG(current_execute_data)) {
if(EG(exception)) { if(EG(exception)) {
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); zend_exception_error(EG(exception), E_ERROR);
} }
zend_error(E_ERROR, "Exception thrown without a stack frame"); zend_error(E_ERROR, "Exception thrown without a stack frame");
} }
if (zend_throw_exception_hook) { if (zend_throw_exception_hook) {
zend_throw_exception_hook(exception TSRMLS_CC); zend_throw_exception_hook(exception);
} }
if (!EG(current_execute_data)->func || if (!EG(current_execute_data)->func ||
@ -127,7 +127,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_clear_exception(TSRMLS_D) /* {{{ */ ZEND_API void zend_clear_exception(void) /* {{{ */
{ {
if (EG(prev_exception)) { if (EG(prev_exception)) {
@ -146,37 +146,37 @@ ZEND_API void zend_clear_exception(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces TSRMLS_DC) /* {{{ */ static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces) /* {{{ */
{ {
zval obj; zval obj;
zend_object *object; zend_object *object;
zval trace; zval trace;
Z_OBJ(obj) = object = zend_objects_new(class_type TSRMLS_CC); Z_OBJ(obj) = object = zend_objects_new(class_type);
Z_OBJ_HT(obj) = &default_exception_handlers; Z_OBJ_HT(obj) = &default_exception_handlers;
object_properties_init(object, class_type); object_properties_init(object, class_type);
zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0 TSRMLS_CC); zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0);
Z_SET_REFCOUNT(trace, 0); Z_SET_REFCOUNT(trace, 0);
zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename());
zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno());
zend_update_property(default_exception_ce, &obj, "trace", sizeof("trace")-1, &trace TSRMLS_CC); zend_update_property(default_exception_ce, &obj, "trace", sizeof("trace")-1, &trace);
return object; return object;
} }
/* }}} */ /* }}} */
static zend_object *zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ static zend_object *zend_default_exception_new(zend_class_entry *class_type) /* {{{ */
{ {
return zend_default_exception_new_ex(class_type, 0 TSRMLS_CC); return zend_default_exception_new_ex(class_type, 0);
} }
/* }}} */ /* }}} */
static zend_object *zend_error_exception_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ static zend_object *zend_error_exception_new(zend_class_entry *class_type) /* {{{ */
{ {
return zend_default_exception_new_ex(class_type, 2 TSRMLS_CC); return zend_default_exception_new_ex(class_type, 2);
} }
/* }}} */ /* }}} */
@ -185,7 +185,7 @@ static zend_object *zend_error_exception_new(zend_class_entry *class_type TSRMLS
ZEND_METHOD(exception, __clone) ZEND_METHOD(exception, __clone)
{ {
/* Should never be executable */ /* Should never be executable */
zend_throw_exception(NULL, "Cannot clone object using __clone()", 0 TSRMLS_CC); zend_throw_exception(NULL, "Cannot clone object using __clone()", 0);
} }
/* }}} */ /* }}} */
@ -198,22 +198,22 @@ ZEND_METHOD(exception, __construct)
zval *object, *previous = NULL; zval *object, *previous = NULL;
int argc = ZEND_NUM_ARGS(); int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SlO!", &message, &code, &previous, default_exception_ce) == FAILURE) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message, &code, &previous, default_exception_ce) == FAILURE) {
zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])"); zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])");
} }
object = getThis(); object = getThis();
if (message) { if (message) {
zend_update_property_str(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC); zend_update_property_str(default_exception_ce, object, "message", sizeof("message")-1, message);
} }
if (code) { if (code) {
zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code);
} }
if (previous) { if (previous) {
zend_update_property(default_exception_ce, object, "previous", sizeof("previous")-1, previous TSRMLS_CC); zend_update_property(default_exception_ce, object, "previous", sizeof("previous")-1, previous);
} }
} }
/* }}} */ /* }}} */
@ -228,32 +228,32 @@ ZEND_METHOD(error_exception, __construct)
int argc = ZEND_NUM_ARGS(); int argc = ZEND_NUM_ARGS();
size_t message_len, filename_len; size_t message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) {
zend_error(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])"); zend_error(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])");
} }
object = getThis(); object = getThis();
if (message) { if (message) {
zend_update_property_string(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC); zend_update_property_string(default_exception_ce, object, "message", sizeof("message")-1, message);
} }
if (code) { if (code) {
zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code);
} }
if (previous) { if (previous) {
zend_update_property(default_exception_ce, object, "previous", sizeof("previous")-1, previous TSRMLS_CC); zend_update_property(default_exception_ce, object, "previous", sizeof("previous")-1, previous);
} }
zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity);
if (argc >= 4) { if (argc >= 4) {
zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC); zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename);
if (argc < 5) { if (argc < 5) {
lineno = 0; /* invalidate lineno */ lineno = 0; /* invalidate lineno */
} }
zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno);
} }
} }
/* }}} */ /* }}} */
@ -264,9 +264,9 @@ ZEND_METHOD(error_exception, __construct)
} }
#define GET_PROPERTY(object, name) \ #define GET_PROPERTY(object, name) \
zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 0 TSRMLS_CC) zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 0)
#define GET_PROPERTY_SILENT(object, name) \ #define GET_PROPERTY_SILENT(object, name) \
zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 1 TSRMLS_CC) zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 1)
/* {{{ proto string Exception::getFile() /* {{{ proto string Exception::getFile()
Get the file in which the exception occurred */ Get the file in which the exception occurred */
@ -398,7 +398,7 @@ static void smart_str_append_escaped(smart_str *str, const char *s, size_t l) {
} }
} }
static void _build_trace_args(zval *arg, smart_str *str TSRMLS_DC) /* {{{ */ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
{ {
/* the trivial way would be to do /* the trivial way would be to do
* convert_to_string_ex(arg); * convert_to_string_ex(arg);
@ -456,7 +456,7 @@ static void _build_trace_args(zval *arg, smart_str *str TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num TSRMLS_DC) /* {{{ */ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* {{{ */
{ {
zval *file, *tmp; zval *file, *tmp;
@ -501,7 +501,7 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num TSRM
zval *arg; zval *arg;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(tmp), arg) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(tmp), arg) {
_build_trace_args(arg, str TSRMLS_CC); _build_trace_args(arg, str);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
if (last_len != str->s->len) { if (last_len != str->s->len) {
@ -526,14 +526,14 @@ ZEND_METHOD(exception, getTraceAsString)
DEFAULT_0_PARAMS; DEFAULT_0_PARAMS;
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC); trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1);
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(trace), index, frame) { ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(trace), index, frame) {
if (Z_TYPE_P(frame) != IS_ARRAY) { if (Z_TYPE_P(frame) != IS_ARRAY) {
zend_error(E_WARNING, "Expected array for frame %pu", index); zend_error(E_WARNING, "Expected array for frame %pu", index);
continue; continue;
} }
_build_trace_string(&str, Z_ARRVAL_P(frame), num++ TSRMLS_CC); _build_trace_string(&str, Z_ARRVAL_P(frame), num++);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
smart_str_appendc(&str, '#'); smart_str_appendc(&str, '#');
@ -610,7 +610,7 @@ ZEND_METHOD(exception, __toString)
fci.params = NULL; fci.params = NULL;
fci.no_separation = 1; fci.no_separation = 1;
zend_call_function(&fci, NULL TSRMLS_CC); zend_call_function(&fci, NULL);
if (Z_TYPE(trace) != IS_STRING) { if (Z_TYPE(trace) != IS_STRING) {
zval_ptr_dtor(&trace); zval_ptr_dtor(&trace);
@ -642,7 +642,7 @@ ZEND_METHOD(exception, __toString)
/* We store the result in the private property string so we can access /* We store the result in the private property string so we can access
* the result in uncaught exception handlers without memleaks. */ * the result in uncaught exception handlers without memleaks. */
zend_update_property_str(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC); zend_update_property_str(default_exception_ce, getThis(), "string", sizeof("string")-1, str);
RETURN_STR(str); RETURN_STR(str);
} }
@ -694,49 +694,49 @@ static const zend_function_entry error_exception_functions[] = {
}; };
/* }}} */ /* }}} */
void zend_register_default_exception(TSRMLS_D) /* {{{ */ void zend_register_default_exception(void) /* {{{ */
{ {
zend_class_entry ce; zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions); INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions);
default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC); default_exception_ce = zend_register_internal_class(&ce);
default_exception_ce->create_object = zend_default_exception_new; default_exception_ce->create_object = zend_default_exception_new;
memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
default_exception_handlers.clone_obj = NULL; default_exception_handlers.clone_obj = NULL;
zend_declare_property_string(default_exception_ce, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(default_exception_ce, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED);
zend_declare_property_string(default_exception_ce, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC); zend_declare_property_string(default_exception_ce, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE);
zend_declare_property_long(default_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(default_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ce, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, "file", sizeof("file")-1, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ce, "line", sizeof("line")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, "line", sizeof("line")-1, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ce, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE TSRMLS_CC); zend_declare_property_null(default_exception_ce, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE);
zend_declare_property_null(default_exception_ce, "previous", sizeof("previous")-1, ZEND_ACC_PRIVATE TSRMLS_CC); zend_declare_property_null(default_exception_ce, "previous", sizeof("previous")-1, ZEND_ACC_PRIVATE);
INIT_CLASS_ENTRY(ce, "ErrorException", error_exception_functions); INIT_CLASS_ENTRY(ce, "ErrorException", error_exception_functions);
error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce TSRMLS_CC); error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce);
error_exception_ce->create_object = zend_error_exception_new; error_exception_ce->create_object = zend_error_exception_new;
zend_declare_property_long(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED);
} }
/* }}} */ /* }}} */
ZEND_API zend_class_entry *zend_exception_get_default(TSRMLS_D) /* {{{ */ ZEND_API zend_class_entry *zend_exception_get_default(void) /* {{{ */
{ {
return default_exception_ce; return default_exception_ce;
} }
/* }}} */ /* }}} */
ZEND_API zend_class_entry *zend_get_error_exception(TSRMLS_D) /* {{{ */ ZEND_API zend_class_entry *zend_get_error_exception(void) /* {{{ */
{ {
return error_exception_ce; return error_exception_ce;
} }
/* }}} */ /* }}} */
ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code TSRMLS_DC) /* {{{ */ ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code) /* {{{ */
{ {
zval ex; zval ex;
if (exception_ce) { if (exception_ce) {
if (!instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) { if (!instanceof_function(exception_ce, default_exception_ce)) {
zend_error(E_NOTICE, "Exceptions must be derived from the Exception base class"); zend_error(E_NOTICE, "Exceptions must be derived from the Exception base class");
exception_ce = default_exception_ce; exception_ce = default_exception_ce;
} }
@ -747,18 +747,18 @@ ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const
if (message) { if (message) {
zend_update_property_string(default_exception_ce, &ex, "message", sizeof("message")-1, message TSRMLS_CC); zend_update_property_string(default_exception_ce, &ex, "message", sizeof("message")-1, message);
} }
if (code) { if (code) {
zend_update_property_long(default_exception_ce, &ex, "code", sizeof("code")-1, code TSRMLS_CC); zend_update_property_long(default_exception_ce, &ex, "code", sizeof("code")-1, code);
} }
zend_throw_exception_internal(&ex TSRMLS_CC); zend_throw_exception_internal(&ex);
return Z_OBJ(ex); return Z_OBJ(ex);
} }
/* }}} */ /* }}} */
ZEND_API zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code TSRMLS_DC, const char *format, ...) /* {{{ */ ZEND_API zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...) /* {{{ */
{ {
va_list arg; va_list arg;
char *message; char *message;
@ -767,18 +767,18 @@ ZEND_API zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, ze
va_start(arg, format); va_start(arg, format);
zend_vspprintf(&message, 0, format, arg); zend_vspprintf(&message, 0, format, arg);
va_end(arg); va_end(arg);
obj = zend_throw_exception(exception_ce, message, code TSRMLS_CC); obj = zend_throw_exception(exception_ce, message, code);
efree(message); efree(message);
return obj; return obj;
} }
/* }}} */ /* }}} */
ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, const char *message, zend_long code, int severity TSRMLS_DC) /* {{{ */ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, const char *message, zend_long code, int severity) /* {{{ */
{ {
zval ex; zval ex;
zend_object *obj = zend_throw_exception(exception_ce, message, code TSRMLS_CC); zend_object *obj = zend_throw_exception(exception_ce, message, code);
ZVAL_OBJ(&ex, obj); ZVAL_OBJ(&ex, obj);
zend_update_property_long(default_exception_ce, &ex, "severity", sizeof("severity")-1, severity TSRMLS_CC); zend_update_property_long(default_exception_ce, &ex, "severity", sizeof("severity")-1, severity);
return obj; return obj;
} }
/* }}} */ /* }}} */
@ -794,14 +794,14 @@ static void zend_error_va(int type, const char *file, uint lineno, const char *f
/* }}} */ /* }}} */
/* This function doesn't return if it uses E_ERROR */ /* This function doesn't return if it uses E_ERROR */
ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {{{ */ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
{ {
zval exception; zval exception;
zend_class_entry *ce_exception; zend_class_entry *ce_exception;
ZVAL_OBJ(&exception, ex); ZVAL_OBJ(&exception, ex);
ce_exception = Z_OBJCE(exception); ce_exception = Z_OBJCE(exception);
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) { if (instanceof_function(ce_exception, default_exception_ce)) {
zval tmp; zval tmp;
zend_string *str, *file = NULL; zend_string *str, *file = NULL;
zend_long line = 0; zend_long line = 0;
@ -813,7 +813,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {
if (Z_TYPE(tmp) != IS_STRING) { if (Z_TYPE(tmp) != IS_STRING) {
zend_error(E_WARNING, "%s::__toString() must return a string", ce_exception->name->val); zend_error(E_WARNING, "%s::__toString() must return a string", ce_exception->name->val);
} else { } else {
zend_update_property_string(default_exception_ce, &exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name->val : Z_STRVAL(tmp) TSRMLS_CC); zend_update_property_string(default_exception_ce, &exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name->val : Z_STRVAL(tmp));
} }
} }
zval_ptr_dtor(&tmp); zval_ptr_dtor(&tmp);
@ -823,7 +823,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {
ZVAL_OBJ(&zv, EG(exception)); ZVAL_OBJ(&zv, EG(exception));
/* do the best we can to inform about the inner exception */ /* do the best we can to inform about the inner exception */
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) { if (instanceof_function(ce_exception, default_exception_ce)) {
file = zval_get_string(GET_PROPERTY_SILENT(&zv, "file")); file = zval_get_string(GET_PROPERTY_SILENT(&zv, "file"));
line = zval_get_long(GET_PROPERTY_SILENT(&zv, "line")); line = zval_get_long(GET_PROPERTY_SILENT(&zv, "line"));
} }
@ -852,7 +852,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {
} }
/* }}} */ /* }}} */
ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC) /* {{{ */ ZEND_API void zend_throw_exception_object(zval *exception) /* {{{ */
{ {
zend_class_entry *exception_ce; zend_class_entry *exception_ce;
@ -862,10 +862,10 @@ ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC) /* {{{ */
exception_ce = Z_OBJCE_P(exception); exception_ce = Z_OBJCE_P(exception);
if (!exception_ce || !instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) { if (!exception_ce || !instanceof_function(exception_ce, default_exception_ce)) {
zend_error(E_ERROR, "Exceptions must be valid objects derived from the Exception base class"); zend_error(E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
} }
zend_throw_exception_internal(exception TSRMLS_CC); zend_throw_exception_internal(exception);
} }
/* }}} */ /* }}} */

View file

@ -26,31 +26,31 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous TSRMLS_DC); ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous);
ZEND_API void zend_exception_save(TSRMLS_D); ZEND_API void zend_exception_save(void);
ZEND_API void zend_exception_restore(TSRMLS_D); ZEND_API void zend_exception_restore(void);
ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC); ZEND_API void zend_throw_exception_internal(zval *exception);
void zend_register_default_exception(TSRMLS_D); void zend_register_default_exception(void);
ZEND_API zend_class_entry *zend_exception_get_default(TSRMLS_D); ZEND_API zend_class_entry *zend_exception_get_default(void);
ZEND_API zend_class_entry *zend_get_error_exception(TSRMLS_D); ZEND_API zend_class_entry *zend_get_error_exception(void);
ZEND_API void zend_register_default_classes(TSRMLS_D); ZEND_API void zend_register_default_classes(void);
/* exception_ce NULL or zend_exception_get_default() or a derived class /* exception_ce NULL or zend_exception_get_default() or a derived class
* message NULL or the message of the exception */ * message NULL or the message of the exception */
ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code TSRMLS_DC); ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code);
ZEND_API zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code TSRMLS_DC, const char *format, ...); ZEND_API zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...);
ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC); ZEND_API void zend_throw_exception_object(zval *exception);
ZEND_API void zend_clear_exception(TSRMLS_D); ZEND_API void zend_clear_exception(void);
ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, const char *message, zend_long code, int severity TSRMLS_DC); ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, const char *message, zend_long code, int severity);
extern ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC); extern ZEND_API void (*zend_throw_exception_hook)(zval *ex);
/* show an exception using zend_error(severity,...), severity should be E_ERROR */ /* show an exception using zend_error(severity,...), severity should be E_ERROR */
ZEND_API void zend_exception_error(zend_object *exception, int severity TSRMLS_DC); ZEND_API void zend_exception_error(zend_object *exception, int severity);
/* do not export, in php it's available thru spprintf directly */ /* do not export, in php it's available thru spprintf directly */
size_t zend_spprintf(char **message, size_t max_len, const char *format, ...); size_t zend_spprintf(char **message, size_t max_len, const char *format, ...);

View file

@ -51,17 +51,17 @@
typedef int (*incdec_t)(zval *); typedef int (*incdec_t)(zval *);
#define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC) #define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type)
#define get_zval_ptr_deref(op_type, node, ex, should_free, type) _get_zval_ptr_deref(op_type, node, ex, should_free, type TSRMLS_CC) #define get_zval_ptr_deref(op_type, node, ex, should_free, type) _get_zval_ptr_deref(op_type, node, ex, should_free, type)
#define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC) #define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
#define get_zval_ptr_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC) #define get_zval_ptr_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
#define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC) #define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type)
#define get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC) #define get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type)
/* Prototypes */ /* Prototypes */
static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array);
static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array);
static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array);
#define RETURN_VALUE_USED(opline) (!((opline)->result_type & EXT_TYPE_UNUSED)) #define RETURN_VALUE_USED(opline) (!((opline)->result_type & EXT_TYPE_UNUSED))
@ -83,7 +83,7 @@ static const zend_internal_function zend_pass_function = {
}; };
#undef zval_ptr_dtor #undef zval_ptr_dtor
#define zval_ptr_dtor(zv) i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC TSRMLS_CC) #define zval_ptr_dtor(zv) i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC)
#define PZVAL_LOCK(z) if (Z_REFCOUNTED_P(z)) Z_ADDREF_P((z)) #define PZVAL_LOCK(z) if (Z_REFCOUNTED_P(z)) Z_ADDREF_P((z))
#define SELECTIVE_PZVAL_LOCK(pzv, opline) if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(pzv); } #define SELECTIVE_PZVAL_LOCK(pzv, opline) if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(pzv); }
@ -142,7 +142,7 @@ static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend
return page; return page;
} }
ZEND_API void zend_vm_stack_init(TSRMLS_D) ZEND_API void zend_vm_stack_init(void)
{ {
EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE, NULL); EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE, NULL);
EG(vm_stack)->top++; EG(vm_stack)->top++;
@ -150,7 +150,7 @@ ZEND_API void zend_vm_stack_init(TSRMLS_D)
EG(vm_stack_end) = EG(vm_stack)->end; EG(vm_stack_end) = EG(vm_stack)->end;
} }
ZEND_API void zend_vm_stack_destroy(TSRMLS_D) ZEND_API void zend_vm_stack_destroy(void)
{ {
zend_vm_stack stack = EG(vm_stack); zend_vm_stack stack = EG(vm_stack);
@ -161,7 +161,7 @@ ZEND_API void zend_vm_stack_destroy(TSRMLS_D)
} }
} }
ZEND_API void* zend_vm_stack_extend(size_t size TSRMLS_DC) ZEND_API void* zend_vm_stack_extend(size_t size)
{ {
zend_vm_stack stack; zend_vm_stack stack;
void *ptr; void *ptr;
@ -210,7 +210,7 @@ static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend
return ret; return ret;
} }
static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type, const zend_execute_data *execute_data TSRMLS_DC) static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type, const zend_execute_data *execute_data)
{ {
zend_string *cv; zend_string *cv;
@ -234,7 +234,7 @@ static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int
return ptr; return ptr;
} }
static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC) static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
{ {
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@ -242,7 +242,7 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t
return &EG(uninitialized_zval); return &EG(uninitialized_zval);
} }
static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC) static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
{ {
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@ -250,7 +250,7 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint
return &EG(uninitialized_zval); return &EG(uninitialized_zval);
} }
static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC) static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
{ {
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@ -259,83 +259,83 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_
return ptr; return ptr;
} }
static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC) static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
{ {
ZVAL_NULL(ptr); ZVAL_NULL(ptr);
return ptr; return ptr;
} }
static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, uint32_t var, int type TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, uint32_t var, int type)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup(ret, var, type, execute_data TSRMLS_CC); return _get_zval_cv_lookup(ret, var, type, execute_data);
} }
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, uint32_t var, int type TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, uint32_t var, int type)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup(ret, var, type, execute_data TSRMLS_CC); return _get_zval_cv_lookup(ret, var, type, execute_data);
} }
ZVAL_DEREF(ret); ZVAL_DEREF(ret);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
} }
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
} }
ZVAL_DEREF(ret); ZVAL_DEREF(ret);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
} }
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
} }
ZVAL_DEREF(ret); ZVAL_DEREF(ret);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
@ -343,54 +343,54 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_exec
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
} }
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
} }
ZVAL_DEREF(ret); ZVAL_DEREF(ret);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (Z_TYPE_P(ret) == IS_UNDEF) { if (Z_TYPE_P(ret) == IS_UNDEF) {
return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
} }
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
{ {
return EX_VAR(var); return EX_VAR(var);
} }
static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
{ {
zval *ret = EX_VAR(var); zval *ret = EX_VAR(var);
if (Z_TYPE_P(ret) == IS_UNDEF) { if (Z_TYPE_P(ret) == IS_UNDEF) {
return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data TSRMLS_CC); return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
} }
ZVAL_DEREF(ret); ZVAL_DEREF(ret);
return ret; return ret;
} }
static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
{ {
if (op_type & (IS_TMP_VAR|IS_VAR)) { if (op_type & (IS_TMP_VAR|IS_VAR)) {
if (op_type == IS_TMP_VAR) { if (op_type == IS_TMP_VAR) {
@ -405,12 +405,12 @@ static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, const
return EX_CONSTANT(node); return EX_CONSTANT(node);
} else { } else {
ZEND_ASSERT(op_type == IS_CV); ZEND_ASSERT(op_type == IS_CV);
return _get_zval_ptr_cv(execute_data, node.var, type TSRMLS_CC); return _get_zval_ptr_cv(execute_data, node.var, type);
} }
} }
} }
static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
{ {
if (op_type & (IS_TMP_VAR|IS_VAR)) { if (op_type & (IS_TMP_VAR|IS_VAR)) {
if (op_type == IS_TMP_VAR) { if (op_type == IS_TMP_VAR) {
@ -425,7 +425,7 @@ static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node,
return EX_CONSTANT(node); return EX_CONSTANT(node);
} else { } else {
ZEND_ASSERT(op_type == IS_CV); ZEND_ASSERT(op_type == IS_CV);
return _get_zval_ptr_cv_deref(execute_data, node.var, type TSRMLS_CC); return _get_zval_ptr_cv_deref(execute_data, node.var, type);
} }
} }
} }
@ -447,11 +447,11 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_e
return ret; return ret;
} }
static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
{ {
if (op_type == IS_CV) { if (op_type == IS_CV) {
*should_free = NULL; *should_free = NULL;
return _get_zval_ptr_cv(execute_data, node.var, type TSRMLS_CC); return _get_zval_ptr_cv(execute_data, node.var, type);
} else /* if (op_type == IS_VAR) */ { } else /* if (op_type == IS_VAR) */ {
ZEND_ASSERT(op_type == IS_VAR); ZEND_ASSERT(op_type == IS_VAR);
return _get_zval_ptr_ptr_var(node.var, execute_data, should_free); return _get_zval_ptr_ptr_var(node.var, execute_data, should_free);
@ -468,7 +468,7 @@ static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *exec
} }
} }
static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type)
{ {
if (op_type == IS_UNUSED) { if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) { if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
@ -481,7 +481,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_dat
return get_zval_ptr(op_type, op, execute_data, should_free, type); return get_zval_ptr(op_type, op, execute_data, should_free, type);
} }
static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execute_data *execute_data, zend_free_op *should_free, int type)
{ {
if (op_type == IS_UNUSED) { if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) { if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
@ -494,7 +494,7 @@ static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execu
return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type); return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
} }
static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr TSRMLS_DC) static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr)
{ {
if (EXPECTED(variable_ptr != value_ptr)) { if (EXPECTED(variable_ptr != value_ptr)) {
zend_reference *ref; zend_reference *ref;
@ -510,7 +510,7 @@ static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *v
} }
/* this should modify object only if it's empty */ /* this should modify object only if it's empty */
static inline int make_real_object(zval **object_ptr TSRMLS_DC) static inline int make_real_object(zval **object_ptr)
{ {
zval *object = *object_ptr; zval *object = *object_ptr;
@ -529,13 +529,13 @@ static inline int make_real_object(zval **object_ptr TSRMLS_DC)
return 1; return 1;
} }
ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC) ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce)
{ {
zend_string *key; zend_string *key;
ALLOCA_FLAG(use_heap); ALLOCA_FLAG(use_heap);
STR_ALLOCA_INIT(key, cur_arg_info->class_name, strlen(cur_arg_info->class_name), use_heap); STR_ALLOCA_INIT(key, cur_arg_info->class_name, strlen(cur_arg_info->class_name), use_heap);
*pce = zend_fetch_class(key, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD) TSRMLS_CC); *pce = zend_fetch_class(key, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
STR_ALLOCA_FREE(key, use_heap); STR_ALLOCA_FREE(key, use_heap);
*class_name = (*pce) ? (*pce)->name->val : (char*)cur_arg_info->class_name; *class_name = (*pce) ? (*pce)->name->val : (char*)cur_arg_info->class_name;
@ -546,9 +546,9 @@ ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info
} }
} }
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC) ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce)
{ {
*pce = zend_fetch_class(cur_arg_info->class_name, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD) TSRMLS_CC); *pce = zend_fetch_class(cur_arg_info->class_name, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
*class_name = (*pce) ? (*pce)->name->val : cur_arg_info->class_name->val; *class_name = (*pce) ? (*pce)->name->val : cur_arg_info->class_name->val;
if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) { if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) {
@ -558,7 +558,7 @@ ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ch
} }
} }
ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC) ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg)
{ {
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data; zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
const char *fname = zf->common.function_name->val; const char *fname = zf->common.function_name->val;
@ -594,13 +594,13 @@ ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uin
} }
} }
static int is_null_constant(zval *default_value TSRMLS_DC) static int is_null_constant(zval *default_value)
{ {
if (Z_CONSTANT_P(default_value)) { if (Z_CONSTANT_P(default_value)) {
zval constant; zval constant;
ZVAL_COPY_VALUE(&constant, default_value); ZVAL_COPY_VALUE(&constant, default_value);
zval_update_constant(&constant, 0 TSRMLS_CC); zval_update_constant(&constant, 0);
if (Z_TYPE(constant) == IS_NULL) { if (Z_TYPE(constant) == IS_NULL) {
return 1; return 1;
} }
@ -609,7 +609,7 @@ static int is_null_constant(zval *default_value TSRMLS_DC)
return 0; return 0;
} }
static void zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg TSRMLS_DC) static void zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg)
{ {
zend_internal_arg_info *cur_arg_info; zend_internal_arg_info *cur_arg_info;
char *need_msg; char *need_msg;
@ -632,23 +632,23 @@ static void zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, z
ZVAL_DEREF(arg); ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) == IS_OBJECT) { if (Z_TYPE_P(arg) == IS_OBJECT) {
need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce TSRMLS_CC); need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) { if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce)) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg);
} }
} else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) { } else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) {
need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce TSRMLS_CC); need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg);
} }
} else if (cur_arg_info->type_hint) { } else if (cur_arg_info->type_hint) {
if (cur_arg_info->type_hint == IS_ARRAY) { if (cur_arg_info->type_hint == IS_ARRAY) {
ZVAL_DEREF(arg); ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) { if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg);
} }
} else if (cur_arg_info->type_hint == IS_CALLABLE) { } else if (cur_arg_info->type_hint == IS_CALLABLE) {
if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) { if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
} }
#if ZEND_DEBUG #if ZEND_DEBUG
} else { } else {
@ -658,7 +658,7 @@ static void zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, z
} }
} }
static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value TSRMLS_DC) static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value)
{ {
zend_arg_info *cur_arg_info; zend_arg_info *cur_arg_info;
char *need_msg; char *need_msg;
@ -681,23 +681,23 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg,
ZVAL_DEREF(arg); ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) == IS_OBJECT) { if (Z_TYPE_P(arg) == IS_OBJECT) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC); need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) { if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce)) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg);
} }
} else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC)))) { } else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value)))) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC); need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg);
} }
} else if (cur_arg_info->type_hint) { } else if (cur_arg_info->type_hint) {
if (cur_arg_info->type_hint == IS_ARRAY) { if (cur_arg_info->type_hint == IS_ARRAY) {
ZVAL_DEREF(arg); ZVAL_DEREF(arg);
if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC))))) { if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value))))) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg);
} }
} else if (cur_arg_info->type_hint == IS_CALLABLE) { } else if (cur_arg_info->type_hint == IS_CALLABLE) {
if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC))))) { if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL) && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value))))) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
} }
#if ZEND_DEBUG #if ZEND_DEBUG
} else { } else {
@ -707,7 +707,7 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg,
} }
} }
static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num TSRMLS_DC) static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num)
{ {
zend_arg_info *cur_arg_info; zend_arg_info *cur_arg_info;
char *need_msg; char *need_msg;
@ -728,14 +728,14 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_n
if (cur_arg_info->class_name) { if (cur_arg_info->class_name) {
char *class_name; char *class_name;
need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC); need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "none", "", NULL TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, "none", "", NULL);
return 0; return 0;
} else if (cur_arg_info->type_hint) { } else if (cur_arg_info->type_hint) {
if (cur_arg_info->type_hint == IS_ARRAY) { if (cur_arg_info->type_hint == IS_ARRAY) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", "none", "", NULL TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", "none", "", NULL);
} else if (cur_arg_info->type_hint == IS_CALLABLE) { } else if (cur_arg_info->type_hint == IS_CALLABLE) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", "none", "", NULL TSRMLS_CC); zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", "none", "", NULL);
#if ZEND_DEBUG #if ZEND_DEBUG
} else { } else {
zend_error(E_ERROR, "Unknown typehint"); zend_error(E_ERROR, "Unknown typehint");
@ -746,10 +746,10 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_n
return 1; return 1;
} }
static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num TSRMLS_DC) static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num)
{ {
if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) || if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
zend_verify_missing_arg_type(EX(func), arg_num TSRMLS_CC)) { zend_verify_missing_arg_type(EX(func), arg_num)) {
const char *class_name = EX(func)->common.scope ? EX(func)->common.scope->name->val : ""; const char *class_name = EX(func)->common.scope ? EX(func)->common.scope->name->val : "";
const char *space = EX(func)->common.scope ? "::" : ""; const char *space = EX(func)->common.scope ? "::" : "";
const char *func_name = EX(func)->common.function_name ? EX(func)->common.function_name->val : "main"; const char *func_name = EX(func)->common.function_name ? EX(func)->common.function_name->val : "main";
@ -763,7 +763,7 @@ static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t ar
} }
} }
static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, uint32_t property_op_type, int value_type, znode_op value_op, const zend_execute_data *execute_data, void **cache_slot TSRMLS_DC) static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, uint32_t property_op_type, int value_type, znode_op value_op, const zend_execute_data *execute_data, void **cache_slot)
{ {
zend_free_op free_value; zend_free_op free_value;
zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R); zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
@ -824,7 +824,7 @@ static zend_always_inline void zend_assign_to_object(zval *retval, zval *object,
property = OBJ_PROP(zobj, prop_info->offset); property = OBJ_PROP(zobj, prop_info->offset);
if (Z_TYPE_P(property) != IS_UNDEF) { if (Z_TYPE_P(property) != IS_UNDEF) {
fast_assign: fast_assign:
value = zend_assign_to_variable(property, value, value_type TSRMLS_CC); value = zend_assign_to_variable(property, value, value_type);
if (retval && !EG(exception)) { if (retval && !EG(exception)) {
ZVAL_COPY(retval, value); ZVAL_COPY(retval, value);
} }
@ -889,7 +889,7 @@ fast_assign:
Z_ADDREF_P(value); Z_ADDREF_P(value);
} }
Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot TSRMLS_CC); Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot);
if (retval && !EG(exception)) { if (retval && !EG(exception)) {
ZVAL_COPY(retval, value); ZVAL_COPY(retval, value);
@ -900,7 +900,7 @@ fast_assign:
} }
} }
static zend_always_inline void zend_assign_to_object_dim(zval *retval, zval *object, zval *property_name, int value_type, znode_op value_op, const zend_execute_data *execute_data TSRMLS_DC) static zend_always_inline void zend_assign_to_object_dim(zval *retval, zval *object, zval *property_name, int value_type, znode_op value_op, const zend_execute_data *execute_data)
{ {
zend_free_op free_value; zend_free_op free_value;
zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R); zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
@ -923,7 +923,7 @@ static zend_always_inline void zend_assign_to_object_dim(zval *retval, zval *obj
Z_ADDREF_P(value); Z_ADDREF_P(value);
} }
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC); Z_OBJ_HT_P(object)->write_dimension(object, property_name, value);
if (retval && !EG(exception)) { if (retval && !EG(exception)) {
ZVAL_COPY(retval, value); ZVAL_COPY(retval, value);
@ -934,27 +934,27 @@ static zend_always_inline void zend_assign_to_object_dim(zval *retval, zval *obj
} }
} }
static void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value, zval *retval, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC) TSRMLS_DC) static void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value, zval *retval, int (*binary_op)(zval *result, zval *op1, zval *op2))
{ {
zval *z; zval *z;
zval rv; zval rv;
if (Z_OBJ_HT_P(object)->read_dimension && if (Z_OBJ_HT_P(object)->read_dimension &&
(z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv TSRMLS_CC)) != NULL) { (z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) {
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
zval rv; zval rv;
zval *value = Z_OBJ_HT_P(z)->get(z, &rv TSRMLS_CC); zval *value = Z_OBJ_HT_P(z)->get(z, &rv);
if (Z_REFCOUNT_P(z) == 0) { if (Z_REFCOUNT_P(z) == 0) {
zend_objects_store_del(Z_OBJ_P(z) TSRMLS_CC); zend_objects_store_del(Z_OBJ_P(z));
} }
ZVAL_COPY_VALUE(z, value); ZVAL_COPY_VALUE(z, value);
} }
ZVAL_DEREF(z); ZVAL_DEREF(z);
SEPARATE_ZVAL_NOREF(z); SEPARATE_ZVAL_NOREF(z);
binary_op(z, z, value TSRMLS_CC); binary_op(z, z, value);
Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); Z_OBJ_HT_P(object)->write_dimension(object, property, z);
if (retval) { if (retval) {
ZVAL_COPY(retval, z); ZVAL_COPY(retval, z);
} }
@ -967,7 +967,7 @@ static void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *va
} }
} }
static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result TSRMLS_DC) static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result)
{ {
zend_string *old_str; zend_string *old_str;
@ -1018,7 +1018,7 @@ static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *valu
} }
/* Utility Functions for Extensions */ /* Utility Functions for Extensions */
static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->statement_handler) { if (extension->statement_handler) {
extension->statement_handler(op_array); extension->statement_handler(op_array);
@ -1026,7 +1026,7 @@ static void zend_extension_statement_handler(const zend_extension *extension, ze
} }
static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->fcall_begin_handler) { if (extension->fcall_begin_handler) {
extension->fcall_begin_handler(op_array); extension->fcall_begin_handler(op_array);
@ -1034,7 +1034,7 @@ static void zend_extension_fcall_begin_handler(const zend_extension *extension,
} }
static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->fcall_end_handler) { if (extension->fcall_end_handler) {
extension->fcall_end_handler(op_array); extension->fcall_end_handler(op_array);
@ -1042,7 +1042,7 @@ static void zend_extension_fcall_end_handler(const zend_extension *extension, ze
} }
static zend_always_inline HashTable *zend_get_target_symbol_table(zend_execute_data *execute_data, int fetch_type TSRMLS_DC) static zend_always_inline HashTable *zend_get_target_symbol_table(zend_execute_data *execute_data, int fetch_type)
{ {
HashTable *ht; HashTable *ht;
@ -1055,14 +1055,14 @@ static zend_always_inline HashTable *zend_get_target_symbol_table(zend_execute_d
} else { } else {
ZEND_ASSERT(fetch_type == ZEND_FETCH_LOCAL); ZEND_ASSERT(fetch_type == ZEND_FETCH_LOCAL);
if (!EX(symbol_table)) { if (!EX(symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C); zend_rebuild_symbol_table();
} }
ht = &EX(symbol_table)->ht; ht = &EX(symbol_table)->ht;
} }
return ht; return ht;
} }
static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht, const zval *dim, int dim_type, int type TSRMLS_DC) static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht, const zval *dim, int dim_type, int type)
{ {
zval *retval; zval *retval;
zend_string *offset_key; zend_string *offset_key;
@ -1168,7 +1168,7 @@ str_index:
return retval; return retval;
} }
static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type TSRMLS_DC) static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type)
{ {
zend_long offset; zend_long offset;
@ -1209,9 +1209,9 @@ try_again:
return offset; return offset;
} }
static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type TSRMLS_DC) static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type)
{ {
zend_long offset = zend_check_string_offset(dim, type TSRMLS_CC); zend_long offset = zend_check_string_offset(dim, type);
if (Z_REFCOUNTED_P(container)) { if (Z_REFCOUNTED_P(container)) {
if (Z_REFCOUNT_P(container) > 1) { if (Z_REFCOUNT_P(container) > 1) {
@ -1223,7 +1223,7 @@ static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zv
return offset; return offset;
} }
static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *container, zval *dim, int dim_type, int type TSRMLS_DC) static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *container, zval *dim, int dim_type, int type)
{ {
zval *retval; zval *retval;
@ -1238,7 +1238,7 @@ fetch_from_array:
retval = &EG(error_zval); retval = &EG(error_zval);
} }
} else { } else {
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC); retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
} }
ZVAL_INDIRECT(result, retval); ZVAL_INDIRECT(result, retval);
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
@ -1250,14 +1250,14 @@ convert_to_array:
goto fetch_from_array; goto fetch_from_array;
} }
zend_check_string_offset(dim, type TSRMLS_CC); zend_check_string_offset(dim, type);
ZVAL_INDIRECT(result, NULL); /* wrong string offset */ ZVAL_INDIRECT(result, NULL); /* wrong string offset */
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
if (!Z_OBJ_HT_P(container)->read_dimension) { if (!Z_OBJ_HT_P(container)->read_dimension) {
zend_error_noreturn(E_ERROR, "Cannot use object as array"); zend_error_noreturn(E_ERROR, "Cannot use object as array");
} else { } else {
retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result TSRMLS_CC); retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
if (UNEXPECTED(retval == &EG(uninitialized_zval))) { if (UNEXPECTED(retval == &EG(uninitialized_zval))) {
zend_class_entry *ce = Z_OBJCE_P(container); zend_class_entry *ce = Z_OBJCE_P(container);
@ -1312,28 +1312,28 @@ convert_to_array:
} }
} }
static zend_never_inline void zend_fetch_dimension_address_W(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC) static zend_never_inline void zend_fetch_dimension_address_W(zval *result, zval *container_ptr, zval *dim, int dim_type)
{ {
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W TSRMLS_CC); zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W);
} }
static zend_never_inline void zend_fetch_dimension_address_RW(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC) static zend_never_inline void zend_fetch_dimension_address_RW(zval *result, zval *container_ptr, zval *dim, int dim_type)
{ {
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW TSRMLS_CC); zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW);
} }
static zend_never_inline void zend_fetch_dimension_address_UNSET(zval *result, zval *container_ptr, zval *dim, int dim_type TSRMLS_DC) static zend_never_inline void zend_fetch_dimension_address_UNSET(zval *result, zval *container_ptr, zval *dim, int dim_type)
{ {
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET TSRMLS_CC); zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET);
} }
static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type TSRMLS_DC) static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type)
{ {
zval *retval; zval *retval;
try_again: try_again:
if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC); retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
ZVAL_COPY(result, retval); ZVAL_COPY(result, retval);
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
zend_long offset; zend_long offset;
@ -1389,7 +1389,7 @@ try_string_offset:
if (!Z_OBJ_HT_P(container)->read_dimension) { if (!Z_OBJ_HT_P(container)->read_dimension) {
zend_error_noreturn(E_ERROR, "Cannot use object as array"); zend_error_noreturn(E_ERROR, "Cannot use object as array");
} else { } else {
retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result TSRMLS_CC); retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
ZEND_ASSERT(result != NULL); ZEND_ASSERT(result != NULL);
if (retval) { if (retval) {
@ -1408,22 +1408,22 @@ try_string_offset:
} }
} }
static zend_never_inline void zend_fetch_dimension_address_read_R(zval *result, zval *container, zval *dim, int dim_type TSRMLS_DC) static zend_never_inline void zend_fetch_dimension_address_read_R(zval *result, zval *container, zval *dim, int dim_type)
{ {
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R TSRMLS_CC); zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R);
} }
static zend_never_inline void zend_fetch_dimension_address_read_IS(zval *result, zval *container, zval *dim, int dim_type TSRMLS_DC) static zend_never_inline void zend_fetch_dimension_address_read_IS(zval *result, zval *container, zval *dim, int dim_type)
{ {
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS TSRMLS_CC); zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS);
} }
ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim TSRMLS_DC) ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim)
{ {
zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR TSRMLS_CC); zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR);
} }
static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type TSRMLS_DC) static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type)
{ {
if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
do { do {
@ -1473,10 +1473,10 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
} }
} }
if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) { if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) {
zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot TSRMLS_CC); zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot);
if (NULL == ptr) { if (NULL == ptr) {
if (Z_OBJ_HT_P(container)->read_property && if (Z_OBJ_HT_P(container)->read_property &&
(ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result TSRMLS_CC)) != NULL) { (ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result)) != NULL) {
if (ptr != result) { if (ptr != result) {
ZVAL_INDIRECT(result, ptr); ZVAL_INDIRECT(result, ptr);
} }
@ -1487,7 +1487,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
ZVAL_INDIRECT(result, ptr); ZVAL_INDIRECT(result, ptr);
} }
} else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) { } else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result TSRMLS_CC); zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
if (ptr != result) { if (ptr != result) {
ZVAL_INDIRECT(result, ptr); ZVAL_INDIRECT(result, ptr);
} }
@ -1497,7 +1497,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
} }
} }
static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const zend_execute_data *execute_data TSRMLS_DC) static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const zend_execute_data *execute_data)
{ {
int original_nest_levels = nest_levels; int original_nest_levels = nest_levels;
zend_brk_cont_element *jmp_to; zend_brk_cont_element *jmp_to;
@ -1524,12 +1524,12 @@ static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_of
#if ZEND_INTENSIVE_DEBUGGING #if ZEND_INTENSIVE_DEBUGGING
#define CHECK_SYMBOL_TABLES() \ #define CHECK_SYMBOL_TABLES() \
zend_hash_apply(&EG(symbol_table), zend_check_symbol TSRMLS_CC); \ zend_hash_apply(&EG(symbol_table), zend_check_symbol); \
if (&EG(symbol_table)!=EX(symbol_table)) { \ if (&EG(symbol_table)!=EX(symbol_table)) { \
zend_hash_apply(EX(symbol_table), zend_check_symbol TSRMLS_CC); \ zend_hash_apply(EX(symbol_table), zend_check_symbol); \
} }
static int zend_check_symbol(zval *pz TSRMLS_DC) static int zend_check_symbol(zval *pz)
{ {
if (Z_TYPE_P(pz) == IS_INDIRECT) { if (Z_TYPE_P(pz) == IS_INDIRECT) {
pz = Z_INDIRECT_P(pz); pz = Z_INDIRECT_P(pz);
@ -1541,10 +1541,10 @@ static int zend_check_symbol(zval *pz TSRMLS_DC)
fflush(stderr); fflush(stderr);
#endif #endif
} else if (Z_TYPE_P(pz) == IS_ARRAY) { } else if (Z_TYPE_P(pz) == IS_ARRAY) {
zend_hash_apply(Z_ARRVAL_P(pz), zend_check_symbol TSRMLS_CC); zend_hash_apply(Z_ARRVAL_P(pz), zend_check_symbol);
} else if (Z_TYPE_P(pz) == IS_OBJECT) { } else if (Z_TYPE_P(pz) == IS_OBJECT) {
/* OBJ-TBI - doesn't support new object model! */ /* OBJ-TBI - doesn't support new object model! */
zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol TSRMLS_CC); zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol);
} }
return 0; return 0;
@ -1557,26 +1557,26 @@ static int zend_check_symbol(zval *pz TSRMLS_DC)
ZEND_API opcode_handler_t *zend_opcode_handlers; ZEND_API opcode_handler_t *zend_opcode_handlers;
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC) ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value)
{ {
execute_data->func->internal_function.handler(execute_data, return_value TSRMLS_CC); execute_data->func->internal_function.handler(execute_data, return_value);
} }
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC) /* {{{ */ ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
{ {
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) { if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
zend_array_destroy(&symbol_table->ht TSRMLS_CC); zend_array_destroy(&symbol_table->ht);
efree_size(symbol_table, sizeof(zend_array)); efree_size(symbol_table, sizeof(zend_array));
} else { } else {
/* clean before putting into the cache, since clean /* clean before putting into the cache, since clean
could call dtors, which could use cached hash */ could call dtors, which could use cached hash */
zend_symtable_clean(&symbol_table->ht TSRMLS_CC); zend_symtable_clean(&symbol_table->ht);
*(++EG(symtable_cache_ptr)) = symbol_table; *(++EG(symtable_cache_ptr)) = symbol_table;
} }
} }
/* }}} */ /* }}} */
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
{ {
if (EXPECTED(EX(func)->op_array.last_var > 0)) { if (EXPECTED(EX(func)->op_array.last_var > 0)) {
zval *cv = EX_VAR_NUM(0); zval *cv = EX_VAR_NUM(0);
@ -1589,9 +1589,9 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec
} }
/* }}} */ /* }}} */
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
{ {
i_free_compiled_variables(execute_data TSRMLS_CC); i_free_compiled_variables(execute_data);
} }
/* }}} */ /* }}} */
@ -1615,7 +1615,7 @@ void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /*
* +----------------------------------------+ * +----------------------------------------+
*/ */
static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
uint32_t first_extra_arg, num_args; uint32_t first_extra_arg, num_args;
ZEND_ASSERT(EX(func) == (zend_function*)op_array); ZEND_ASSERT(EX(func) == (zend_function*)op_array);
@ -1681,7 +1681,7 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
} }
/* }}} */ /* }}} */
static zend_always_inline void i_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
ZEND_ASSERT(EX(func) == (zend_function*)op_array); ZEND_ASSERT(EX(func) == (zend_function*)op_array);
@ -1706,7 +1706,7 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
} }
/* }}} */ /* }}} */
static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
ZEND_ASSERT(EX(func) == (zend_function*)op_array); ZEND_ASSERT(EX(func) == (zend_function*)op_array);
@ -1781,7 +1781,7 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
} }
/* }}} */ /* }}} */
ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
/* /*
* Normally the execute_data is allocated on the VM stack (because it does * Normally the execute_data is allocated on the VM stack (because it does
@ -1810,7 +1810,7 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
num_args, num_args,
call->called_scope, call->called_scope,
Z_OBJ(call->This), Z_OBJ(call->This),
NULL TSRMLS_CC); NULL);
EX_NUM_ARGS() = num_args; EX_NUM_ARGS() = num_args;
/* copy arguments */ /* copy arguments */
@ -1826,33 +1826,33 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
EX(symbol_table) = NULL; EX(symbol_table) = NULL;
i_init_func_execute_data(execute_data, op_array, return_value TSRMLS_CC); i_init_func_execute_data(execute_data, op_array, return_value);
return execute_data; return execute_data;
} }
/* }}} */ /* }}} */
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
EX(prev_execute_data) = EG(current_execute_data); EX(prev_execute_data) = EG(current_execute_data);
i_init_execute_data(execute_data, op_array, return_value TSRMLS_CC); i_init_execute_data(execute_data, op_array, return_value);
} }
/* }}} */ /* }}} */
static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(const zend_op *opline, zend_execute_data *call TSRMLS_DC) /* {{{ */ static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(const zend_op *opline, zend_execute_data *call) /* {{{ */
{ {
uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK; uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num); return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num);
} }
/* }}} */ /* }}} */
static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, uint32_t passed_args, uint32_t additional_args TSRMLS_DC) /* {{{ */ static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
{ {
zend_execute_data *new_call; zend_execute_data *new_call;
int used_stack = (EG(vm_stack_top) - (zval*)call) + additional_args; int used_stack = (EG(vm_stack_top) - (zval*)call) + additional_args;
/* copy call frame into new stack segment */ /* copy call frame into new stack segment */
new_call = zend_vm_stack_extend(used_stack * sizeof(zval) TSRMLS_CC); new_call = zend_vm_stack_extend(used_stack * sizeof(zval));
*new_call = *call; *new_call = *call;
if (passed_args) { if (passed_args) {
zval *src = ZEND_CALL_ARG(call, 1); zval *src = ZEND_CALL_ARG(call, 1);
@ -1880,12 +1880,12 @@ static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call,
} }
/* }}} */ /* }}} */
static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, uint32_t passed_args, uint32_t additional_args TSRMLS_DC) /* {{{ */ static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
{ {
if (EXPECTED(EG(vm_stack_end) - EG(vm_stack_top) > additional_args)) { if (EXPECTED(EG(vm_stack_end) - EG(vm_stack_top) > additional_args)) {
EG(vm_stack_top) += additional_args; EG(vm_stack_top) += additional_args;
} else { } else {
*call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args TSRMLS_CC); *call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args);
} }
} }
/* }}} */ /* }}} */
@ -1941,7 +1941,7 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
return zend_user_opcode_handlers[opcode]; return zend_user_opcode_handlers[opcode];
} }
ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type) {
return get_zval_ptr(op_type, *node, execute_data, should_free, type); return get_zval_ptr(op_type, *node, execute_data, should_free, type);
} }

View file

@ -29,29 +29,29 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
struct _zend_fcall_info; struct _zend_fcall_info;
ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value TSRMLS_DC); ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
void init_executor(TSRMLS_D); void init_executor(void);
void shutdown_executor(TSRMLS_D); void shutdown_executor(void);
void shutdown_destructors(TSRMLS_D); void shutdown_destructors(void);
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC); ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value TSRMLS_DC); ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value);
ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value TSRMLS_DC); ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC); ZEND_API void execute_ex(zend_execute_data *execute_data);
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC); ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC); ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload TSRMLS_DC); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name);
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name TSRMLS_DC); ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name);
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC); ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions);
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC); ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions);
ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC); ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce);
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC); ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce);
ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC); ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg);
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type TSRMLS_DC) static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
{ {
do { do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) { if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
@ -65,7 +65,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
} }
if (Z_TYPE_P(variable_ptr) == IS_OBJECT && if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) { UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value TSRMLS_CC); Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
return variable_ptr; return variable_ptr;
} }
if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) { if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
@ -90,7 +90,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
/* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */ /* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
if ((Z_COLLECTABLE_P(variable_ptr)) && if ((Z_COLLECTABLE_P(variable_ptr)) &&
UNEXPECTED(!GC_INFO(garbage))) { UNEXPECTED(!GC_INFO(garbage))) {
gc_possible_root(garbage TSRMLS_CC); gc_possible_root(garbage);
} }
} }
} }
@ -110,10 +110,10 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
return variable_ptr; return variable_ptr;
} }
ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change TSRMLS_DC); ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change);
ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC); ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope);
ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC); ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope);
ZEND_API int zval_update_constant_ex(zval *pp, zend_bool inline_change, zend_class_entry *scope TSRMLS_DC); ZEND_API int zval_update_constant_ex(zval *pp, zend_bool inline_change, zend_class_entry *scope);
/* dedicated Zend executor functions - do not use! */ /* dedicated Zend executor functions - do not use! */
struct _zend_vm_stack { struct _zend_vm_stack {
@ -128,24 +128,24 @@ struct _zend_vm_stack {
#define ZEND_VM_STACK_ELEMETS(stack) \ #define ZEND_VM_STACK_ELEMETS(stack) \
(((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS) (((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
ZEND_API void zend_vm_stack_init(TSRMLS_D); ZEND_API void zend_vm_stack_init(void);
ZEND_API void zend_vm_stack_destroy(TSRMLS_D); ZEND_API void zend_vm_stack_destroy(void);
ZEND_API void* zend_vm_stack_extend(size_t size TSRMLS_DC); ZEND_API void* zend_vm_stack_extend(size_t size);
static zend_always_inline zval* zend_vm_stack_alloc(size_t size TSRMLS_DC) static zend_always_inline zval* zend_vm_stack_alloc(size_t size)
{ {
char *top = (char*)EG(vm_stack_top); char *top = (char*)EG(vm_stack_top);
if (UNEXPECTED(size > (size_t)(((char*)EG(vm_stack_end)) - top))) { if (UNEXPECTED(size > (size_t)(((char*)EG(vm_stack_end)) - top))) {
return (zval*)zend_vm_stack_extend(size TSRMLS_CC); return (zval*)zend_vm_stack_extend(size);
} }
EG(vm_stack_top) = (zval*)(top + size); EG(vm_stack_top) = (zval*)(top + size);
return (zval*)top; return (zval*)top;
} }
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(uint32_t call_info, zend_function *func, uint32_t used_stack, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC) static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(uint32_t call_info, zend_function *func, uint32_t used_stack, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev)
{ {
zend_execute_data *call = (zend_execute_data*)zend_vm_stack_alloc(used_stack TSRMLS_CC); zend_execute_data *call = (zend_execute_data*)zend_vm_stack_alloc(used_stack);
call->func = func; call->func = func;
Z_OBJ(call->This) = object; Z_OBJ(call->This) = object;
@ -166,15 +166,15 @@ static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, ze
return used_stack * sizeof(zval); return used_stack * sizeof(zval);
} }
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC) static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev)
{ {
uint32_t used_stack = zend_vm_calc_used_stack(num_args, func); uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);
return zend_vm_stack_push_call_frame_ex(call_info, return zend_vm_stack_push_call_frame_ex(call_info,
func, used_stack, called_scope, object, prev TSRMLS_CC); func, used_stack, called_scope, object, prev);
} }
static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call TSRMLS_DC) static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call)
{ {
uint32_t first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0); uint32_t first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0);
@ -188,7 +188,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *
} }
} }
static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call TSRMLS_DC) static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
{ {
uint32_t num_args = ZEND_CALL_NUM_ARGS(call); uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
@ -203,7 +203,7 @@ static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call T
} }
} }
static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call TSRMLS_DC) static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call)
{ {
zend_vm_stack p = EG(vm_stack); zend_vm_stack p = EG(vm_stack);
if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(p) == (zval*)call)) { if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(p) == (zval*)call)) {
@ -219,20 +219,20 @@ static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *
} }
/* services */ /* services */
ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC); ZEND_API const char *get_active_class_name(const char **space);
ZEND_API const char *get_active_function_name(TSRMLS_D); ZEND_API const char *get_active_function_name(void);
ZEND_API const char *zend_get_executed_filename(TSRMLS_D); ZEND_API const char *zend_get_executed_filename(void);
ZEND_API uint zend_get_executed_lineno(TSRMLS_D); ZEND_API uint zend_get_executed_lineno(void);
ZEND_API zend_bool zend_is_executing(TSRMLS_D); ZEND_API zend_bool zend_is_executing(void);
ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals); ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
ZEND_API void zend_unset_timeout(TSRMLS_D); ZEND_API void zend_unset_timeout(void);
ZEND_API void zend_timeout(int dummy); ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type TSRMLS_DC); ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type TSRMLS_DC); ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type);
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC); void zend_verify_abstract_class(zend_class_entry *ce);
ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim TSRMLS_DC); ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim);
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var); ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
@ -250,12 +250,12 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
/* former zend_execute_locks.h */ /* former zend_execute_locks.h */
typedef zval* zend_free_op; typedef zval* zend_free_op;
ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type);
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS); ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC); ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC); void zend_free_compiled_variables(zend_execute_data *execute_data);
#define CACHED_PTR(num) \ #define CACHED_PTR(num) \
EX_RUN_TIME_CACHE()[(num)] EX_RUN_TIME_CACHE()[(num)]

View file

@ -38,8 +38,8 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value TSRMLS_DC); ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
/* true globals */ /* true globals */
ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, {{0}, {{0}}, {0}}, NULL, NULL, NULL, NULL, 0, 0 }; ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, {{0}, {{0}}, {0}}, NULL, NULL, NULL, NULL, 0, 0 };
@ -64,14 +64,13 @@ static void zend_handle_sigsegv(int dummy) /* {{{ */
signal(SIGSEGV, SIG_DFL); signal(SIGSEGV, SIG_DFL);
} }
{ {
TSRMLS_FETCH();
fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n", fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
active_opline->opcode, active_opline->opcode,
active_opline-EG(active_op_array)->opcodes, active_opline-EG(active_op_array)->opcodes,
get_active_function_name(TSRMLS_C), get_active_function_name(),
zend_get_executed_filename(TSRMLS_C), zend_get_executed_filename(),
zend_get_executed_lineno(TSRMLS_C)); zend_get_executed_lineno());
/* See http://support.microsoft.com/kb/190351 */ /* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32 #ifdef PHP_WIN32
fflush(stderr); fflush(stderr);
@ -84,7 +83,7 @@ static void zend_handle_sigsegv(int dummy) /* {{{ */
/* }}} */ /* }}} */
#endif #endif
static void zend_extension_activator(zend_extension *extension TSRMLS_DC) /* {{{ */ static void zend_extension_activator(zend_extension *extension) /* {{{ */
{ {
if (extension->activate) { if (extension->activate) {
extension->activate(); extension->activate();
@ -92,7 +91,7 @@ static void zend_extension_activator(zend_extension *extension TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC) /* {{{ */ static void zend_extension_deactivator(zend_extension *extension) /* {{{ */
{ {
if (extension->deactivate) { if (extension->deactivate) {
extension->deactivate(); extension->deactivate();
@ -100,37 +99,37 @@ static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC) /* {
} }
/* }}} */ /* }}} */
static int clean_non_persistent_function(zval *zv TSRMLS_DC) /* {{{ */ static int clean_non_persistent_function(zval *zv) /* {{{ */
{ {
zend_function *function = Z_PTR_P(zv); zend_function *function = Z_PTR_P(zv);
return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
} }
/* }}} */ /* }}} */
ZEND_API int clean_non_persistent_function_full(zval *zv TSRMLS_DC) /* {{{ */ ZEND_API int clean_non_persistent_function_full(zval *zv) /* {{{ */
{ {
zend_function *function = Z_PTR_P(zv); zend_function *function = Z_PTR_P(zv);
return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
} }
/* }}} */ /* }}} */
static int clean_non_persistent_class(zval *zv TSRMLS_DC) /* {{{ */ static int clean_non_persistent_class(zval *zv) /* {{{ */
{ {
zend_class_entry *ce = Z_PTR_P(zv); zend_class_entry *ce = Z_PTR_P(zv);
return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
} }
/* }}} */ /* }}} */
ZEND_API int clean_non_persistent_class_full(zval *zv TSRMLS_DC) /* {{{ */ ZEND_API int clean_non_persistent_class_full(zval *zv) /* {{{ */
{ {
zend_class_entry *ce = Z_PTR_P(zv); zend_class_entry *ce = Z_PTR_P(zv);
return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
} }
/* }}} */ /* }}} */
void init_executor(TSRMLS_D) /* {{{ */ void init_executor(void) /* {{{ */
{ {
zend_init_fpu(TSRMLS_C); zend_init_fpu();
ZVAL_NULL(&EG(uninitialized_zval)); ZVAL_NULL(&EG(uninitialized_zval));
/* trick to make uninitialized_zval never be modified, passed by ref, etc. */ /* trick to make uninitialized_zval never be modified, passed by ref, etc. */
@ -151,14 +150,14 @@ void init_executor(TSRMLS_D) /* {{{ */
EG(autoload_func) = NULL; EG(autoload_func) = NULL;
EG(error_handling) = EH_NORMAL; EG(error_handling) = EH_NORMAL;
zend_vm_stack_init(TSRMLS_C); zend_vm_stack_init();
zend_hash_init(&EG(symbol_table).ht, 64, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(&EG(symbol_table).ht, 64, NULL, ZVAL_PTR_DTOR, 0);
GC_REFCOUNT(&EG(symbol_table)) = 1; GC_REFCOUNT(&EG(symbol_table)) = 1;
GC_TYPE_INFO(&EG(symbol_table)) = IS_ARRAY; GC_TYPE_INFO(&EG(symbol_table)) = IS_ARRAY;
EG(valid_symbol_table) = 1; EG(valid_symbol_table) = 1;
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator);
zend_hash_init(&EG(included_files), 8, NULL, NULL, 0); zend_hash_init(&EG(included_files), 8, NULL, NULL, 0);
@ -188,7 +187,7 @@ void init_executor(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
static int zval_call_destructor(zval *zv TSRMLS_DC) /* {{{ */ static int zval_call_destructor(zval *zv) /* {{{ */
{ {
if (Z_TYPE_P(zv) == IS_INDIRECT) { if (Z_TYPE_P(zv) == IS_INDIRECT) {
zv = Z_INDIRECT_P(zv); zv = Z_INDIRECT_P(zv);
@ -203,16 +202,15 @@ static int zval_call_destructor(zval *zv TSRMLS_DC) /* {{{ */
static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */ static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */
{ {
TSRMLS_FETCH();
if (Z_TYPE_P(zv) == IS_INDIRECT) { if (Z_TYPE_P(zv) == IS_INDIRECT) {
zv = Z_INDIRECT_P(zv); zv = Z_INDIRECT_P(zv);
} }
i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC);
} }
/* }}} */ /* }}} */
void shutdown_destructors(TSRMLS_D) /* {{{ */ void shutdown_destructors(void) /* {{{ */
{ {
if (CG(unclean_shutdown)) { if (CG(unclean_shutdown)) {
EG(symbol_table).ht.pDestructor = zend_unclean_zval_ptr_dtor; EG(symbol_table).ht.pDestructor = zend_unclean_zval_ptr_dtor;
@ -221,17 +219,17 @@ void shutdown_destructors(TSRMLS_D) /* {{{ */
uint32_t symbols; uint32_t symbols;
do { do {
symbols = zend_hash_num_elements(&EG(symbol_table).ht); symbols = zend_hash_num_elements(&EG(symbol_table).ht);
zend_hash_reverse_apply(&EG(symbol_table).ht, (apply_func_t) zval_call_destructor TSRMLS_CC); zend_hash_reverse_apply(&EG(symbol_table).ht, (apply_func_t) zval_call_destructor);
} while (symbols != zend_hash_num_elements(&EG(symbol_table).ht)); } while (symbols != zend_hash_num_elements(&EG(symbol_table).ht));
zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); zend_objects_store_call_destructors(&EG(objects_store));
} zend_catch { } zend_catch {
/* if we couldn't destruct cleanly, mark all objects as destructed anyway */ /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); zend_objects_store_mark_destructed(&EG(objects_store));
} zend_end_try(); } zend_end_try();
} }
/* }}} */ /* }}} */
void shutdown_executor(TSRMLS_D) /* {{{ */ void shutdown_executor(void) /* {{{ */
{ {
zend_function *func; zend_function *func;
zend_class_entry *ce; zend_class_entry *ce;
@ -243,7 +241,7 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
Object 3 holds reference to object 2. Object 3 holds reference to object 2.
Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with
very problematic results */ very problematic results */
/* zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); */ /* zend_objects_store_call_destructors(&EG(objects_store)); */
/* Moved after symbol table cleaners, because some of the cleaners can call /* Moved after symbol table cleaners, because some of the cleaners can call
destructors, which would use EG(symtable_cache_ptr) and thus leave leaks */ destructors, which would use EG(symtable_cache_ptr) and thus leave leaks */
@ -253,7 +251,7 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
EG(symtable_cache_ptr)--; EG(symtable_cache_ptr)--;
} }
*/ */
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator);
if (CG(unclean_shutdown)) { if (CG(unclean_shutdown)) {
EG(symbol_table).ht.pDestructor = zend_unclean_zval_ptr_dtor; EG(symbol_table).ht.pDestructor = zend_unclean_zval_ptr_dtor;
@ -301,9 +299,9 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) { ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
if (ce->type == ZEND_USER_CLASS) { if (ce->type == ZEND_USER_CLASS) {
zend_cleanup_user_class_data(ce TSRMLS_CC); zend_cleanup_user_class_data(ce);
} else { } else {
zend_cleanup_internal_class_data(ce TSRMLS_CC); zend_cleanup_internal_class_data(ce);
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
} else { } else {
@ -317,9 +315,9 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
if (ce->type != ZEND_USER_CLASS) { if (ce->type != ZEND_USER_CLASS) {
break; break;
} }
zend_cleanup_user_class_data(ce TSRMLS_CC); zend_cleanup_user_class_data(ce);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
zend_cleanup_internal_classes(TSRMLS_C); zend_cleanup_internal_classes();
} }
} zend_end_try(); } zend_end_try();
@ -328,21 +326,21 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
} zend_end_try(); } zend_end_try();
zend_try { zend_try {
zend_close_rsrc_list(&EG(regular_list) TSRMLS_CC); zend_close_rsrc_list(&EG(regular_list));
} zend_end_try(); } zend_end_try();
zend_try { zend_try {
zend_objects_store_free_object_storage(&EG(objects_store) TSRMLS_CC); zend_objects_store_free_object_storage(&EG(objects_store));
zend_vm_stack_destroy(TSRMLS_C); zend_vm_stack_destroy();
/* Destroy all op arrays */ /* Destroy all op arrays */
if (EG(full_tables_cleanup)) { if (EG(full_tables_cleanup)) {
zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full TSRMLS_CC); zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);
zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full TSRMLS_CC); zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full);
} else { } else {
zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function TSRMLS_CC); zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function);
zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class TSRMLS_CC); zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class);
} }
while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
@ -353,7 +351,7 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
} zend_end_try(); } zend_end_try();
zend_try { zend_try {
clean_non_persistent_constants(TSRMLS_C); clean_non_persistent_constants();
} zend_end_try(); } zend_end_try();
zend_try { zend_try {
@ -373,18 +371,18 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
} }
} zend_end_try(); } zend_end_try();
zend_shutdown_fpu(TSRMLS_C); zend_shutdown_fpu();
EG(active) = 0; EG(active) = 0;
} }
/* }}} */ /* }}} */
/* return class name and "::" or "". */ /* return class name and "::" or "". */
ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC) /* {{{ */ ZEND_API const char *get_active_class_name(const char **space) /* {{{ */
{ {
zend_function *func; zend_function *func;
if (!zend_is_executing(TSRMLS_C)) { if (!zend_is_executing()) {
if (space) { if (space) {
*space = ""; *space = "";
} }
@ -412,11 +410,11 @@ ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
ZEND_API const char *get_active_function_name(TSRMLS_D) /* {{{ */ ZEND_API const char *get_active_function_name(void) /* {{{ */
{ {
zend_function *func; zend_function *func;
if (!zend_is_executing(TSRMLS_C)) { if (!zend_is_executing()) {
return NULL; return NULL;
} }
func = EG(current_execute_data)->func; func = EG(current_execute_data)->func;
@ -440,7 +438,7 @@ ZEND_API const char *get_active_function_name(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API const char *zend_get_executed_filename(TSRMLS_D) /* {{{ */ ZEND_API const char *zend_get_executed_filename(void) /* {{{ */
{ {
zend_execute_data *ex = EG(current_execute_data); zend_execute_data *ex = EG(current_execute_data);
@ -455,7 +453,7 @@ ZEND_API const char *zend_get_executed_filename(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */ ZEND_API uint zend_get_executed_lineno(void) /* {{{ */
{ {
zend_execute_data *ex = EG(current_execute_data); zend_execute_data *ex = EG(current_execute_data);
@ -474,7 +472,7 @@ ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */ ZEND_API zend_bool zend_is_executing(void) /* {{{ */
{ {
return EG(current_execute_data) != 0; return EG(current_execute_data) != 0;
} }
@ -482,8 +480,7 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */
ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ */ ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
{ {
TSRMLS_FETCH(); i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_RELAY_CC);
i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
} }
/* }}} */ /* }}} */
@ -502,7 +499,7 @@ ZEND_API void _zval_internal_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ *
#define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT) #define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
#define MARK_CONSTANT_VISITED(p) Z_TYPE_INFO_P(p) |= IS_VISITED_CONSTANT #define MARK_CONSTANT_VISITED(p) Z_TYPE_INFO_P(p) |= IS_VISITED_CONSTANT
ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_class_entry *scope TSRMLS_DC) /* {{{ */ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_class_entry *scope) /* {{{ */
{ {
zval *const_value; zval *const_value;
char *colon; char *colon;
@ -515,7 +512,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
SEPARATE_ZVAL_NOREF(p); SEPARATE_ZVAL_NOREF(p);
MARK_CONSTANT_VISITED(p); MARK_CONSTANT_VISITED(p);
refcount = Z_REFCOUNTED_P(p) ? Z_REFCOUNT_P(p) : 1; refcount = Z_REFCOUNTED_P(p) ? Z_REFCOUNT_P(p) : 1;
const_value = zend_get_constant_ex(Z_STR_P(p), scope, Z_CONST_FLAGS_P(p) TSRMLS_CC); const_value = zend_get_constant_ex(Z_STR_P(p), scope, Z_CONST_FLAGS_P(p));
if (!const_value) { if (!const_value) {
char *actual = Z_STRVAL_P(p); char *actual = Z_STRVAL_P(p);
@ -582,7 +579,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
} }
ZVAL_COPY_VALUE(p, const_value); ZVAL_COPY_VALUE(p, const_value);
if (Z_OPT_CONSTANT_P(p)) { if (Z_OPT_CONSTANT_P(p)) {
zval_update_constant_ex(p, 1, NULL TSRMLS_CC); zval_update_constant_ex(p, 1, NULL);
} }
zval_opt_copy_ctor(p); zval_opt_copy_ctor(p);
} }
@ -592,7 +589,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
zval tmp; zval tmp;
SEPARATE_ZVAL_NOREF(p); SEPARATE_ZVAL_NOREF(p);
zend_ast_evaluate(&tmp, Z_ASTVAL_P(p), scope TSRMLS_CC); zend_ast_evaluate(&tmp, Z_ASTVAL_P(p), scope);
if (inline_change) { if (inline_change) {
zend_ast_destroy_and_free(Z_ASTVAL_P(p)); zend_ast_destroy_and_free(Z_ASTVAL_P(p));
efree_size(Z_AST_P(p), sizeof(zend_ast_ref)); efree_size(Z_AST_P(p), sizeof(zend_ast_ref));
@ -603,31 +600,31 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
} }
/* }}} */ /* }}} */
ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC) /* {{{ */ ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope) /* {{{ */
{ {
return zval_update_constant_ex(pp, 1, scope TSRMLS_CC); return zval_update_constant_ex(pp, 1, scope);
} }
/* }}} */ /* }}} */
ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC) /* {{{ */ ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope) /* {{{ */
{ {
return zval_update_constant_ex(pp, 0, scope TSRMLS_CC); return zval_update_constant_ex(pp, 0, scope);
} }
/* }}} */ /* }}} */
ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change TSRMLS_DC) /* {{{ */ ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change) /* {{{ */
{ {
return zval_update_constant_ex(pp, inline_change, NULL TSRMLS_CC); return zval_update_constant_ex(pp, inline_change, NULL);
} }
/* }}} */ /* }}} */
int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[] TSRMLS_DC) /* {{{ */ int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]) /* {{{ */
{ {
return call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, 1, NULL TSRMLS_CC); return call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, 1, NULL);
} }
/* }}} */ /* }}} */
int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC) /* {{{ */ int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table) /* {{{ */
{ {
zend_fcall_info fci; zend_fcall_info fci;
@ -641,11 +638,11 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
fci.no_separation = (zend_bool) no_separation; fci.no_separation = (zend_bool) no_separation;
fci.symbol_table = symbol_table; fci.symbol_table = symbol_table;
return zend_call_function(&fci, NULL TSRMLS_CC); return zend_call_function(&fci, NULL);
} }
/* }}} */ /* }}} */
int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) /* {{{ */ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */
{ {
uint32_t i; uint32_t i;
zend_class_entry *calling_scope = NULL; zend_class_entry *calling_scope = NULL;
@ -703,7 +700,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
fci_cache = &fci_cache_local; fci_cache = &fci_cache_local;
} }
if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error TSRMLS_CC)) { if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error)) {
if (error) { if (error) {
zend_error(E_WARNING, "Invalid callback %s, %s", callable_name->val, error); zend_error(E_WARNING, "Invalid callback %s, %s", callable_name->val, error);
efree(error); efree(error);
@ -728,7 +725,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
func = fci_cache->function_handler; func = fci_cache->function_handler;
call = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_FUNCTION, call = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_FUNCTION,
func, fci->param_count, fci_cache->called_scope, fci_cache->object, NULL TSRMLS_CC); func, fci->param_count, fci_cache->called_scope, fci_cache->object, NULL);
calling_scope = fci_cache->calling_scope; calling_scope = fci_cache->calling_scope;
fci->object = fci_cache->object; fci->object = fci_cache->object;
if (fci->object && if (fci->object &&
@ -779,9 +776,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
if (i) { if (i) {
/* hack to clean up the stack */ /* hack to clean up the stack */
ZEND_CALL_NUM_ARGS(call) = i; ZEND_CALL_NUM_ARGS(call) = i;
zend_vm_stack_free_args(call TSRMLS_CC); zend_vm_stack_free_args(call);
} }
zend_vm_stack_free_call_frame(call TSRMLS_CC); zend_vm_stack_free_call_frame(call);
zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
i+1, i+1,
@ -835,10 +832,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(scope) = func->common.scope; EG(scope) = func->common.scope;
call->symbol_table = fci->symbol_table; call->symbol_table = fci->symbol_table;
if (EXPECTED((func->op_array.fn_flags & ZEND_ACC_GENERATOR) == 0)) { if (EXPECTED((func->op_array.fn_flags & ZEND_ACC_GENERATOR) == 0)) {
zend_init_execute_data(call, &func->op_array, fci->retval TSRMLS_CC); zend_init_execute_data(call, &func->op_array, fci->retval);
zend_execute_ex(call TSRMLS_CC); zend_execute_ex(call);
} else { } else {
zend_generator_create_zval(call, &func->op_array, fci->retval TSRMLS_CC); zend_generator_create_zval(call, &func->op_array, fci->retval);
} }
} else if (func->type == ZEND_INTERNAL_FUNCTION) { } else if (func->type == ZEND_INTERNAL_FUNCTION) {
int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
@ -851,13 +848,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(current_execute_data) = call; EG(current_execute_data) = call;
if (EXPECTED(zend_execute_internal == NULL)) { if (EXPECTED(zend_execute_internal == NULL)) {
/* saves one function call if zend_execute_internal is not used */ /* saves one function call if zend_execute_internal is not used */
func->internal_function.handler(call, fci->retval TSRMLS_CC); func->internal_function.handler(call, fci->retval);
} else { } else {
zend_execute_internal(call, fci->retval TSRMLS_CC); zend_execute_internal(call, fci->retval);
} }
EG(current_execute_data) = call->prev_execute_data; EG(current_execute_data) = call->prev_execute_data;
zend_vm_stack_free_args(call TSRMLS_CC); zend_vm_stack_free_args(call);
zend_vm_stack_free_call_frame(call TSRMLS_CC); zend_vm_stack_free_call_frame(call);
/* We shouldn't fix bad extensions here, /* We shouldn't fix bad extensions here,
because it can break proper ones (Bug #34045) because it can break proper ones (Bug #34045)
@ -881,14 +878,14 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
if (fci->object) { if (fci->object) {
call->prev_execute_data = EG(current_execute_data); call->prev_execute_data = EG(current_execute_data);
EG(current_execute_data) = call; EG(current_execute_data) = call;
fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval TSRMLS_CC); fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval);
EG(current_execute_data) = call->prev_execute_data; EG(current_execute_data) = call->prev_execute_data;
} else { } else {
zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
} }
zend_vm_stack_free_args(call TSRMLS_CC); zend_vm_stack_free_args(call);
zend_vm_stack_free_call_frame(call TSRMLS_CC); zend_vm_stack_free_call_frame(call);
if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
zend_string_release(func->common.function_name); zend_string_release(func->common.function_name);
@ -911,13 +908,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
} }
if (EG(exception)) { if (EG(exception)) {
zend_throw_exception_internal(NULL TSRMLS_CC); zend_throw_exception_internal(NULL);
} }
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload TSRMLS_DC) /* {{{ */ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload) /* {{{ */
{ {
zend_class_entry *ce = NULL; zend_class_entry *ce = NULL;
zval args[1]; zval args[1];
@ -954,7 +951,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
/* The compiler is not-reentrant. Make sure we __autoload() only during run-time /* The compiler is not-reentrant. Make sure we __autoload() only during run-time
* (doesn't impact functionality of __autoload() * (doesn't impact functionality of __autoload()
*/ */
if (!use_autoload || zend_is_compiling(TSRMLS_C)) { if (!use_autoload || zend_is_compiling()) {
if (!key) { if (!key) {
zend_string_free(lc_name); zend_string_free(lc_name);
} }
@ -1018,9 +1015,9 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
fcall_cache.called_scope = NULL; fcall_cache.called_scope = NULL;
fcall_cache.object = NULL; fcall_cache.object = NULL;
zend_exception_save(TSRMLS_C); zend_exception_save();
retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC); retval = zend_call_function(&fcall_info, &fcall_cache);
zend_exception_restore(TSRMLS_C); zend_exception_restore();
zval_ptr_dtor(&args[0]); zval_ptr_dtor(&args[0]);
zval_dtor(&fcall_info.function_name); zval_dtor(&fcall_info.function_name);
@ -1039,13 +1036,13 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
} }
/* }}} */ /* }}} */
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC) /* {{{ */ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name) /* {{{ */
{ {
return zend_lookup_class_ex(name, NULL, 1 TSRMLS_CC); return zend_lookup_class_ex(name, NULL, 1);
} }
/* }}} */ /* }}} */
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name) /* {{{ */
{ {
zval pv; zval pv;
zend_op_array *new_op_array; zend_op_array *new_op_array;
@ -1066,7 +1063,7 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char
original_compiler_options = CG(compiler_options); original_compiler_options = CG(compiler_options);
CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL; CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
new_op_array = zend_compile_string(&pv, string_name TSRMLS_CC); new_op_array = zend_compile_string(&pv, string_name);
CG(compiler_options) = original_compiler_options; CG(compiler_options) = original_compiler_options;
if (new_op_array) { if (new_op_array) {
@ -1076,9 +1073,9 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char
zend_try { zend_try {
ZVAL_UNDEF(&local_retval); ZVAL_UNDEF(&local_retval);
zend_execute(new_op_array, &local_retval TSRMLS_CC); zend_execute(new_op_array, &local_retval);
} zend_catch { } zend_catch {
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array);
efree_size(new_op_array, sizeof(zend_op_array)); efree_size(new_op_array, sizeof(zend_op_array));
zend_bailout(); zend_bailout();
} zend_end_try(); } zend_end_try();
@ -1096,7 +1093,7 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char
} }
EG(no_extensions)=0; EG(no_extensions)=0;
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array);
efree_size(new_op_array, sizeof(zend_op_array)); efree_size(new_op_array, sizeof(zend_op_array));
retval = SUCCESS; retval = SUCCESS;
} else { } else {
@ -1107,34 +1104,33 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char
} }
/* }}} */ /* }}} */
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name) /* {{{ */
{ {
return zend_eval_stringl(str, strlen(str), retval_ptr, string_name TSRMLS_CC); return zend_eval_stringl(str, strlen(str), retval_ptr, string_name);
} }
/* }}} */ /* }}} */
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */ ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
{ {
int result; int result;
result = zend_eval_stringl(str, str_len, retval_ptr, string_name TSRMLS_CC); result = zend_eval_stringl(str, str_len, retval_ptr, string_name);
if (handle_exceptions && EG(exception)) { if (handle_exceptions && EG(exception)) {
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); zend_exception_error(EG(exception), E_ERROR);
result = FAILURE; result = FAILURE;
} }
return result; return result;
} }
/* }}} */ /* }}} */
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */ ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
{ {
return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions TSRMLS_CC); return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions);
} }
/* }}} */ /* }}} */
ZEND_API void zend_timeout(int dummy) /* {{{ */ ZEND_API void zend_timeout(int dummy) /* {{{ */
{ {
TSRMLS_FETCH();
if (zend_on_timeout) { if (zend_on_timeout) {
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
@ -1146,7 +1142,7 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */
*/ */
SIGG(running) = 0; SIGG(running) = 0;
#endif #endif
zend_on_timeout(EG(timeout_seconds) TSRMLS_CC); zend_on_timeout(EG(timeout_seconds));
} }
zend_error(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); zend_error(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
@ -1176,7 +1172,6 @@ VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out)
void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
{ {
TSRMLS_FETCH();
EG(timeout_seconds) = seconds; EG(timeout_seconds) = seconds;
@ -1228,7 +1223,7 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
if (reset_signals) { if (reset_signals) {
# ifdef ZEND_SIGNALS # ifdef ZEND_SIGNALS
zend_signal(signo, zend_timeout TSRMLS_CC); zend_signal(signo, zend_timeout);
# else # else
sigset_t sigset; sigset_t sigset;
@ -1244,7 +1239,7 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
} }
/* }}} */ /* }}} */
void zend_unset_timeout(TSRMLS_D) /* {{{ */ void zend_unset_timeout(void) /* {{{ */
{ {
#ifdef ZEND_WIN32 #ifdef ZEND_WIN32
if (NULL != tq_timer) { if (NULL != tq_timer) {
@ -1275,7 +1270,7 @@ void zend_unset_timeout(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type TSRMLS_DC) /* {{{ */ zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type) /* {{{ */
{ {
zend_class_entry *ce; zend_class_entry *ce;
int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
@ -1312,7 +1307,7 @@ check_fetch_type:
break; break;
} }
if ((ce = zend_lookup_class_ex(class_name, NULL, use_autoload TSRMLS_CC)) == NULL) { if ((ce = zend_lookup_class_ex(class_name, NULL, use_autoload)) == NULL) {
if (use_autoload) { if (use_autoload) {
if (!silent && !EG(exception)) { if (!silent && !EG(exception)) {
if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) { if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
@ -1330,12 +1325,12 @@ check_fetch_type:
} }
/* }}} */ /* }}} */
zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type TSRMLS_DC) /* {{{ */ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type) /* {{{ */
{ {
zend_class_entry *ce; zend_class_entry *ce;
int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
if ((ce = zend_lookup_class_ex(class_name, key, use_autoload TSRMLS_CC)) == NULL) { if ((ce = zend_lookup_class_ex(class_name, key, use_autoload)) == NULL) {
if (use_autoload) { if (use_autoload) {
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) { if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) { if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
@ -1367,7 +1362,7 @@ typedef struct _zend_abstract_info {
int ctor; int ctor;
} zend_abstract_info; } zend_abstract_info;
static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai TSRMLS_DC) /* {{{ */ static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai) /* {{{ */
{ {
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) { if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
if (ai->cnt < MAX_ABSTRACT_INFO_CNT) { if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
@ -1387,7 +1382,7 @@ static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract
} }
/* }}} */ /* }}} */
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
{ {
zend_function *func; zend_function *func;
zend_abstract_info ai; zend_abstract_info ai;
@ -1396,7 +1391,7 @@ void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */
memset(&ai, 0, sizeof(ai)); memset(&ai, 0, sizeof(ai));
ZEND_HASH_FOREACH_PTR(&ce->function_table, func) { ZEND_HASH_FOREACH_PTR(&ce->function_table, func) {
zend_verify_abstract_class_function(func, &ai TSRMLS_CC); zend_verify_abstract_class_function(func, &ai);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
if (ai.cnt) { if (ai.cnt) {
@ -1412,13 +1407,13 @@ void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int zend_delete_global_variable(zend_string *name TSRMLS_DC) /* {{{ */ ZEND_API int zend_delete_global_variable(zend_string *name) /* {{{ */
{ {
return zend_hash_del_ind(&EG(symbol_table).ht, name); return zend_hash_del_ind(&EG(symbol_table).ht, name);
} }
/* }}} */ /* }}} */
ZEND_API zend_array *zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */
{ {
int i; int i;
zend_execute_data *ex; zend_execute_data *ex;
@ -1506,7 +1501,7 @@ ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS_DC) /* {{{ */ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{{ */
{ {
zend_execute_data *execute_data = EG(current_execute_data); zend_execute_data *execute_data = EG(current_execute_data);
@ -1529,7 +1524,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS
} }
} }
if (force) { if (force) {
zend_array *symbol_table = zend_rebuild_symbol_table(TSRMLS_C); zend_array *symbol_table = zend_rebuild_symbol_table();
if (symbol_table) { if (symbol_table) {
return zend_hash_update(&symbol_table->ht, name, value) ? SUCCESS : FAILURE;; return zend_hash_update(&symbol_table->ht, name, value) ? SUCCESS : FAILURE;;
} }
@ -1542,7 +1537,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS
} }
/* }}} */ /* }}} */
ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force TSRMLS_DC) /* {{{ */ ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force) /* {{{ */
{ {
zend_execute_data *execute_data = EG(current_execute_data); zend_execute_data *execute_data = EG(current_execute_data);
@ -1567,7 +1562,7 @@ ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, i
} }
if (force) { if (force) {
zend_array *symbol_table = zend_rebuild_symbol_table(TSRMLS_C); zend_array *symbol_table = zend_rebuild_symbol_table();
if (symbol_table) { if (symbol_table) {
return zend_hash_str_update(&symbol_table->ht, name, len, value) ? SUCCESS : FAILURE;; return zend_hash_str_update(&symbol_table->ht, name, len, value) ? SUCCESS : FAILURE;;
} }

View file

@ -24,7 +24,7 @@
ZEND_API zend_llist zend_extensions; ZEND_API zend_llist zend_extensions;
static int last_resource_number; static int last_resource_number;
int zend_load_extension(const char *path TSRMLS_DC) int zend_load_extension(const char *path)
{ {
#if ZEND_EXTENSIONS_SUPPORT #if ZEND_EXTENSIONS_SUPPORT
DL_HANDLE handle; DL_HANDLE handle;
@ -115,7 +115,7 @@ int zend_load_extension(const char *path TSRMLS_DC)
return FAILURE; return FAILURE;
} }
return zend_register_extension(new_extension, handle TSRMLS_CC); return zend_register_extension(new_extension, handle);
#else #else
fprintf(stderr, "Extensions are not supported on this platform.\n"); fprintf(stderr, "Extensions are not supported on this platform.\n");
/* See http://support.microsoft.com/kb/190351 */ /* See http://support.microsoft.com/kb/190351 */
@ -127,7 +127,7 @@ int zend_load_extension(const char *path TSRMLS_DC)
} }
int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle TSRMLS_DC) int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle)
{ {
#if ZEND_EXTENSIONS_SUPPORT #if ZEND_EXTENSIONS_SUPPORT
zend_extension extension; zend_extension extension;
@ -135,7 +135,7 @@ int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle TSRM
extension = *new_extension; extension = *new_extension;
extension.handle = handle; extension.handle = handle;
zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension TSRMLS_CC); zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);
zend_llist_add_element(&zend_extensions, &extension); zend_llist_add_element(&zend_extensions, &extension);
@ -146,7 +146,7 @@ int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle TSRM
} }
static void zend_extension_shutdown(zend_extension *extension TSRMLS_DC) static void zend_extension_shutdown(zend_extension *extension)
{ {
#if ZEND_EXTENSIONS_SUPPORT #if ZEND_EXTENSIONS_SUPPORT
if (extension->shutdown) { if (extension->shutdown) {
@ -185,9 +185,9 @@ int zend_startup_extensions()
} }
void zend_shutdown_extensions(TSRMLS_D) void zend_shutdown_extensions(void)
{ {
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_shutdown TSRMLS_CC); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_shutdown);
zend_llist_destroy(&zend_extensions); zend_llist_destroy(&zend_extensions);
} }
@ -202,7 +202,7 @@ void zend_extension_dtor(zend_extension *extension)
} }
static void zend_extension_message_dispatcher(const zend_extension *extension, int num_args, va_list args TSRMLS_DC) static void zend_extension_message_dispatcher(const zend_extension *extension, int num_args, va_list args)
{ {
int message; int message;
void *arg; void *arg;
@ -216,9 +216,9 @@ static void zend_extension_message_dispatcher(const zend_extension *extension, i
} }
ZEND_API void zend_extension_dispatch_message(int message, void *arg TSRMLS_DC) ZEND_API void zend_extension_dispatch_message(int message, void *arg)
{ {
zend_llist_apply_with_arguments(&zend_extensions, (llist_apply_with_args_func_t) zend_extension_message_dispatcher TSRMLS_CC, 2, message, arg); zend_llist_apply_with_arguments(&zend_extensions, (llist_apply_with_args_func_t) zend_extension_message_dispatcher, 2, message, arg);
} }

View file

@ -94,7 +94,7 @@ struct _zend_extension {
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_get_resource_handle(zend_extension *extension); ZEND_API int zend_get_resource_handle(zend_extension *extension);
ZEND_API void zend_extension_dispatch_message(int message, void *arg TSRMLS_DC); ZEND_API void zend_extension_dispatch_message(int message, void *arg);
END_EXTERN_C() END_EXTERN_C()
#define ZEND_EXTMSG_NEW_EXTENSION 1 #define ZEND_EXTMSG_NEW_EXTENSION 1
@ -114,11 +114,11 @@ void zend_extension_dtor(zend_extension *extension);
ZEND_API void zend_append_version_info(const zend_extension *extension); ZEND_API void zend_append_version_info(const zend_extension *extension);
int zend_startup_extensions_mechanism(void); int zend_startup_extensions_mechanism(void);
int zend_startup_extensions(void); int zend_startup_extensions(void);
void zend_shutdown_extensions(TSRMLS_D); void zend_shutdown_extensions(void);
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_load_extension(const char *path TSRMLS_DC); ZEND_API int zend_load_extension(const char *path);
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle TSRMLS_DC); ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API zend_extension *zend_get_extension(const char *extension_name);
END_EXTERN_C() END_EXTERN_C()

View file

@ -22,7 +22,7 @@
#include "zend_compile.h" #include "zend_compile.h"
#include "zend_float.h" #include "zend_float.h"
ZEND_API void zend_init_fpu(TSRMLS_D) /* {{{ */ ZEND_API void zend_init_fpu(void) /* {{{ */
{ {
#if XPFPA_HAVE_CW #if XPFPA_HAVE_CW
XPFPA_DECLARE XPFPA_DECLARE
@ -38,7 +38,7 @@ ZEND_API void zend_init_fpu(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_shutdown_fpu(TSRMLS_D) /* {{{ */ ZEND_API void zend_shutdown_fpu(void) /* {{{ */
{ {
#if XPFPA_HAVE_CW #if XPFPA_HAVE_CW
if (EG(saved_fpu_cw_ptr)) { if (EG(saved_fpu_cw_ptr)) {
@ -49,7 +49,7 @@ ZEND_API void zend_shutdown_fpu(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_ensure_fpu_mode(TSRMLS_D) /* {{{ */ ZEND_API void zend_ensure_fpu_mode(void) /* {{{ */
{ {
XPFPA_DECLARE XPFPA_DECLARE

View file

@ -26,9 +26,9 @@ BEGIN_EXTERN_C()
/* /*
Define functions for FP initialization and de-initialization. Define functions for FP initialization and de-initialization.
*/ */
extern ZEND_API void zend_init_fpu(TSRMLS_D); extern ZEND_API void zend_init_fpu(void);
extern ZEND_API void zend_shutdown_fpu(TSRMLS_D); extern ZEND_API void zend_shutdown_fpu(void);
extern ZEND_API void zend_ensure_fpu_mode(TSRMLS_D); extern ZEND_API void zend_ensure_fpu_mode(void);
END_EXTERN_C() END_EXTERN_C()

View file

@ -32,9 +32,9 @@ ZEND_API zend_gc_globals gc_globals;
#endif #endif
#define GC_REMOVE_FROM_ROOTS(current) \ #define GC_REMOVE_FROM_ROOTS(current) \
gc_remove_from_roots((current) TSRMLS_CC) gc_remove_from_roots((current))
static zend_always_inline void gc_remove_from_roots(gc_root_buffer *root TSRMLS_DC) static zend_always_inline void gc_remove_from_roots(gc_root_buffer *root)
{ {
root->next->prev = root->prev; root->next->prev = root->prev;
root->prev->next = root->next; root->prev->next = root->next;
@ -43,7 +43,7 @@ static zend_always_inline void gc_remove_from_roots(gc_root_buffer *root TSRMLS_
GC_BENCH_DEC(root_buf_length); GC_BENCH_DEC(root_buf_length);
} }
static void root_buffer_dtor(zend_gc_globals *gc_globals TSRMLS_DC) static void root_buffer_dtor(zend_gc_globals *gc_globals)
{ {
if (gc_globals->buf) { if (gc_globals->buf) {
free(gc_globals->buf); free(gc_globals->buf);
@ -51,7 +51,7 @@ static void root_buffer_dtor(zend_gc_globals *gc_globals TSRMLS_DC)
} }
} }
static void gc_globals_ctor_ex(zend_gc_globals *gc_globals TSRMLS_DC) static void gc_globals_ctor_ex(zend_gc_globals *gc_globals)
{ {
gc_globals->gc_enabled = 0; gc_globals->gc_enabled = 0;
gc_globals->gc_active = 0; gc_globals->gc_active = 0;
@ -79,7 +79,7 @@ static void gc_globals_ctor_ex(zend_gc_globals *gc_globals TSRMLS_DC)
#endif #endif
} }
ZEND_API void gc_globals_ctor(TSRMLS_D) ZEND_API void gc_globals_ctor(void)
{ {
#ifdef ZTS #ifdef ZTS
ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor); ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
@ -88,14 +88,14 @@ ZEND_API void gc_globals_ctor(TSRMLS_D)
#endif #endif
} }
ZEND_API void gc_globals_dtor(TSRMLS_D) ZEND_API void gc_globals_dtor(void)
{ {
#ifndef ZTS #ifndef ZTS
root_buffer_dtor(&gc_globals TSRMLS_DC); root_buffer_dtor(&gc_globals);
#endif #endif
} }
ZEND_API void gc_reset(TSRMLS_D) ZEND_API void gc_reset(void)
{ {
GC_G(gc_runs) = 0; GC_G(gc_runs) = 0;
GC_G(collected) = 0; GC_G(collected) = 0;
@ -126,16 +126,16 @@ ZEND_API void gc_reset(TSRMLS_D)
} }
} }
ZEND_API void gc_init(TSRMLS_D) ZEND_API void gc_init(void)
{ {
if (GC_G(buf) == NULL && GC_G(gc_enabled)) { if (GC_G(buf) == NULL && GC_G(gc_enabled)) {
GC_G(buf) = (gc_root_buffer*) malloc(sizeof(gc_root_buffer) * GC_ROOT_BUFFER_MAX_ENTRIES); GC_G(buf) = (gc_root_buffer*) malloc(sizeof(gc_root_buffer) * GC_ROOT_BUFFER_MAX_ENTRIES);
GC_G(last_unused) = &GC_G(buf)[GC_ROOT_BUFFER_MAX_ENTRIES]; GC_G(last_unused) = &GC_G(buf)[GC_ROOT_BUFFER_MAX_ENTRIES];
gc_reset(TSRMLS_C); gc_reset();
} }
} }
ZEND_API void gc_possible_root(zend_refcounted *ref TSRMLS_DC) ZEND_API void gc_possible_root(zend_refcounted *ref)
{ {
GC_BENCH_INC(zval_possible_root); GC_BENCH_INC(zval_possible_root);
@ -156,7 +156,7 @@ ZEND_API void gc_possible_root(zend_refcounted *ref TSRMLS_DC)
return; return;
} }
GC_REFCOUNT(ref)++; GC_REFCOUNT(ref)++;
gc_collect_cycles(TSRMLS_C); gc_collect_cycles();
GC_REFCOUNT(ref)--; GC_REFCOUNT(ref)--;
newRoot = GC_G(unused); newRoot = GC_G(unused);
if (!newRoot) { if (!newRoot) {
@ -182,7 +182,7 @@ ZEND_API void gc_possible_root(zend_refcounted *ref TSRMLS_DC)
} }
} }
ZEND_API void gc_remove_from_buffer(zend_refcounted *ref TSRMLS_DC) ZEND_API void gc_remove_from_buffer(zend_refcounted *ref)
{ {
gc_root_buffer *root; gc_root_buffer *root;
@ -197,7 +197,7 @@ ZEND_API void gc_remove_from_buffer(zend_refcounted *ref TSRMLS_DC)
} }
} }
static void gc_scan_black(zend_refcounted *ref TSRMLS_DC) static void gc_scan_black(zend_refcounted *ref)
{ {
HashTable *ht; HashTable *ht;
uint idx; uint idx;
@ -219,7 +219,7 @@ tail_call:
HashTable *props; HashTable *props;
ZVAL_OBJ(&tmp, obj); ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC); props = get_gc(&tmp, &table, &n);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--; while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (Z_REFCOUNTED(table[i])) { if (Z_REFCOUNTED(table[i])) {
@ -231,7 +231,7 @@ tail_call:
if (!props && i == n - 1) { if (!props && i == n - 1) {
goto tail_call; goto tail_call;
} else { } else {
gc_scan_black(ref TSRMLS_CC); gc_scan_black(ref);
} }
} }
} }
@ -273,13 +273,13 @@ tail_call:
if (idx == ht->nNumUsed-1) { if (idx == ht->nNumUsed-1) {
goto tail_call; goto tail_call;
} else { } else {
gc_scan_black(ref TSRMLS_CC); gc_scan_black(ref);
} }
} }
} }
} }
static void gc_mark_grey(zend_refcounted *ref TSRMLS_DC) static void gc_mark_grey(zend_refcounted *ref)
{ {
HashTable *ht; HashTable *ht;
uint idx; uint idx;
@ -303,7 +303,7 @@ tail_call:
HashTable *props; HashTable *props;
ZVAL_OBJ(&tmp, obj); ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC); props = get_gc(&tmp, &table, &n);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--; while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -315,7 +315,7 @@ tail_call:
if (!props && i == n - 1) { if (!props && i == n - 1) {
goto tail_call; goto tail_call;
} else { } else {
gc_mark_grey(ref TSRMLS_CC); gc_mark_grey(ref);
} }
} }
} }
@ -355,25 +355,25 @@ tail_call:
if (idx == ht->nNumUsed-1) { if (idx == ht->nNumUsed-1) {
goto tail_call; goto tail_call;
} else { } else {
gc_mark_grey(ref TSRMLS_CC); gc_mark_grey(ref);
} }
} }
} }
} }
static void gc_mark_roots(TSRMLS_D) static void gc_mark_roots(void)
{ {
gc_root_buffer *current = GC_G(roots).next; gc_root_buffer *current = GC_G(roots).next;
while (current != &GC_G(roots)) { while (current != &GC_G(roots)) {
if (GC_GET_COLOR(GC_INFO(current->ref)) == GC_PURPLE) { if (GC_GET_COLOR(GC_INFO(current->ref)) == GC_PURPLE) {
gc_mark_grey(current->ref TSRMLS_CC); gc_mark_grey(current->ref);
} }
current = current->next; current = current->next;
} }
} }
static void gc_scan(zend_refcounted *ref TSRMLS_DC) static void gc_scan(zend_refcounted *ref)
{ {
HashTable *ht; HashTable *ht;
uint idx; uint idx;
@ -383,7 +383,7 @@ tail_call:
if (GC_GET_COLOR(GC_INFO(ref)) == GC_GREY) { if (GC_GET_COLOR(GC_INFO(ref)) == GC_GREY) {
ht = NULL; ht = NULL;
if (GC_REFCOUNT(ref) > 0) { if (GC_REFCOUNT(ref) > 0) {
gc_scan_black(ref TSRMLS_CC); gc_scan_black(ref);
} else { } else {
GC_SET_COLOR(GC_INFO(ref), GC_WHITE); GC_SET_COLOR(GC_INFO(ref), GC_WHITE);
if (GC_TYPE(ref) == IS_OBJECT && EG(objects_store).object_buckets) { if (GC_TYPE(ref) == IS_OBJECT && EG(objects_store).object_buckets) {
@ -398,7 +398,7 @@ tail_call:
HashTable *props; HashTable *props;
ZVAL_OBJ(&tmp, obj); ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC); props = get_gc(&tmp, &table, &n);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--; while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (Z_REFCOUNTED(table[i])) { if (Z_REFCOUNTED(table[i])) {
@ -406,7 +406,7 @@ tail_call:
if (!props && i == n - 1) { if (!props && i == n - 1) {
goto tail_call; goto tail_call;
} else { } else {
gc_scan(ref TSRMLS_CC); gc_scan(ref);
} }
} }
} }
@ -441,23 +441,23 @@ tail_call:
if (idx == ht->nNumUsed-1) { if (idx == ht->nNumUsed-1) {
goto tail_call; goto tail_call;
} else { } else {
gc_scan(ref TSRMLS_CC); gc_scan(ref);
} }
} }
} }
} }
static void gc_scan_roots(TSRMLS_D) static void gc_scan_roots(void)
{ {
gc_root_buffer *current = GC_G(roots).next; gc_root_buffer *current = GC_G(roots).next;
while (current != &GC_G(roots)) { while (current != &GC_G(roots)) {
gc_scan(current->ref TSRMLS_CC); gc_scan(current->ref);
current = current->next; current = current->next;
} }
} }
static int gc_collect_white(zend_refcounted *ref TSRMLS_DC) static int gc_collect_white(zend_refcounted *ref)
{ {
int count = 0; int count = 0;
HashTable *ht; HashTable *ht;
@ -513,7 +513,7 @@ tail_call:
HashTable *props; HashTable *props;
ZVAL_OBJ(&tmp, obj); ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC); props = get_gc(&tmp, &table, &n);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) { while (n > 0 && !Z_REFCOUNTED(table[n-1])) {
/* count non-refcounted for compatibility ??? */ /* count non-refcounted for compatibility ??? */
if (Z_TYPE(table[n-1]) != IS_UNDEF) { if (Z_TYPE(table[n-1]) != IS_UNDEF) {
@ -530,7 +530,7 @@ tail_call:
if (!props && i == n - 1) { if (!props && i == n - 1) {
goto tail_call; goto tail_call;
} else { } else {
count += gc_collect_white(ref TSRMLS_CC); count += gc_collect_white(ref);
} }
/* count non-refcounted for compatibility ??? */ /* count non-refcounted for compatibility ??? */
} else if (Z_TYPE(table[i]) != IS_UNDEF) { } else if (Z_TYPE(table[i]) != IS_UNDEF) {
@ -576,14 +576,14 @@ tail_call:
if (idx == ht->nNumUsed-1) { if (idx == ht->nNumUsed-1) {
goto tail_call; goto tail_call;
} else { } else {
count += gc_collect_white(ref TSRMLS_CC); count += gc_collect_white(ref);
} }
} }
} }
return count; return count;
} }
static int gc_collect_roots(TSRMLS_D) static int gc_collect_roots(void)
{ {
int count = 0; int count = 0;
gc_root_buffer *current = GC_G(roots).next; gc_root_buffer *current = GC_G(roots).next;
@ -601,7 +601,7 @@ static int gc_collect_roots(TSRMLS_D)
while (current != &GC_G(roots)) { while (current != &GC_G(roots)) {
if (GC_GET_COLOR(GC_INFO(current->ref)) == GC_WHITE) { if (GC_GET_COLOR(GC_INFO(current->ref)) == GC_WHITE) {
GC_REFCOUNT(current->ref)++; GC_REFCOUNT(current->ref)++;
count += gc_collect_white(current->ref TSRMLS_CC); count += gc_collect_white(current->ref);
} }
current = current->next; current = current->next;
} }
@ -613,7 +613,7 @@ static int gc_collect_roots(TSRMLS_D)
GC_SET_BLACK(GC_INFO(current->ref)); GC_SET_BLACK(GC_INFO(current->ref));
current = current->next; current = current->next;
} }
gc_reset(TSRMLS_C); gc_reset();
return 0; return 0;
} }
@ -639,7 +639,7 @@ static int gc_collect_roots(TSRMLS_D)
return count; return count;
} }
static void gc_remove_nested_data_from_buffer(zend_refcounted *ref TSRMLS_DC) static void gc_remove_nested_data_from_buffer(zend_refcounted *ref)
{ {
HashTable *ht = NULL; HashTable *ht = NULL;
uint idx; uint idx;
@ -661,7 +661,7 @@ tail_call:
HashTable *props; HashTable *props;
ZVAL_OBJ(&tmp, obj); ZVAL_OBJ(&tmp, obj);
props = get_gc(&tmp, &table, &n TSRMLS_CC); props = get_gc(&tmp, &table, &n);
while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--; while (n > 0 && !Z_REFCOUNTED(table[n-1])) n--;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -670,7 +670,7 @@ tail_call:
if (!props && i == n - 1) { if (!props && i == n - 1) {
goto tail_call; goto tail_call;
} else { } else {
gc_remove_nested_data_from_buffer(ref TSRMLS_CC); gc_remove_nested_data_from_buffer(ref);
} }
} }
} }
@ -700,13 +700,13 @@ tail_call:
if (idx == ht->nNumUsed-1) { if (idx == ht->nNumUsed-1) {
goto tail_call; goto tail_call;
} else { } else {
gc_remove_nested_data_from_buffer(ref TSRMLS_CC); gc_remove_nested_data_from_buffer(ref);
} }
} }
} }
} }
ZEND_API int gc_collect_cycles(TSRMLS_D) ZEND_API int gc_collect_cycles(void)
{ {
int count = 0; int count = 0;
@ -720,9 +720,9 @@ ZEND_API int gc_collect_cycles(TSRMLS_D)
} }
GC_G(gc_runs)++; GC_G(gc_runs)++;
GC_G(gc_active) = 1; GC_G(gc_active) = 1;
gc_mark_roots(TSRMLS_C); gc_mark_roots();
gc_scan_roots(TSRMLS_C); gc_scan_roots();
count = gc_collect_roots(TSRMLS_C); count = gc_collect_roots();
GC_G(gc_active) = 0; GC_G(gc_active) = 0;
if (GC_G(to_free).next == &GC_G(to_free)) { if (GC_G(to_free).next == &GC_G(to_free)) {
@ -764,7 +764,7 @@ ZEND_API int gc_collect_cycles(TSRMLS_D)
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED; GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
if (obj->handlers->dtor_obj) { if (obj->handlers->dtor_obj) {
GC_REFCOUNT(obj)++; GC_REFCOUNT(obj)++;
obj->handlers->dtor_obj(obj TSRMLS_CC); obj->handlers->dtor_obj(obj);
GC_REFCOUNT(obj)--; GC_REFCOUNT(obj)--;
} }
} }
@ -777,7 +777,7 @@ ZEND_API int gc_collect_cycles(TSRMLS_D)
while (current != &to_free) { while (current != &to_free) {
GC_G(next_to_free) = current->next; GC_G(next_to_free) = current->next;
if (GC_REFCOUNT(current->ref) > current->refcount) { if (GC_REFCOUNT(current->ref) > current->refcount) {
gc_remove_nested_data_from_buffer(current->ref TSRMLS_CC); gc_remove_nested_data_from_buffer(current->ref);
} }
current = GC_G(next_to_free); current = GC_G(next_to_free);
} }
@ -797,7 +797,7 @@ ZEND_API int gc_collect_cycles(TSRMLS_D)
GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED; GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED;
if (obj->handlers->free_obj) { if (obj->handlers->free_obj) {
GC_REFCOUNT(obj)++; GC_REFCOUNT(obj)++;
obj->handlers->free_obj(obj TSRMLS_CC); obj->handlers->free_obj(obj);
GC_REFCOUNT(obj)--; GC_REFCOUNT(obj)--;
} }
} }
@ -821,7 +821,7 @@ ZEND_API int gc_collect_cycles(TSRMLS_D)
if (EG(objects_store).object_buckets && if (EG(objects_store).object_buckets &&
IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) { IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) {
zend_objects_store_free(obj TSRMLS_CC); zend_objects_store_free(obj);
} }
} else { } else {
GC_REMOVE_FROM_BUFFER(p); GC_REMOVE_FROM_BUFFER(p);

View file

@ -119,30 +119,30 @@ extern ZEND_API zend_gc_globals gc_globals;
#endif #endif
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int gc_collect_cycles(TSRMLS_D); ZEND_API int gc_collect_cycles(void);
ZEND_API void gc_possible_root(zend_refcounted *ref TSRMLS_DC); ZEND_API void gc_possible_root(zend_refcounted *ref);
ZEND_API void gc_remove_from_buffer(zend_refcounted *ref TSRMLS_DC); ZEND_API void gc_remove_from_buffer(zend_refcounted *ref);
ZEND_API void gc_globals_ctor(TSRMLS_D); ZEND_API void gc_globals_ctor(void);
ZEND_API void gc_globals_dtor(TSRMLS_D); ZEND_API void gc_globals_dtor(void);
ZEND_API void gc_init(TSRMLS_D); ZEND_API void gc_init(void);
ZEND_API void gc_reset(TSRMLS_D); ZEND_API void gc_reset(void);
END_EXTERN_C() END_EXTERN_C()
#define GC_ZVAL_CHECK_POSSIBLE_ROOT(z) \ #define GC_ZVAL_CHECK_POSSIBLE_ROOT(z) \
gc_check_possible_root((z) TSRMLS_CC) gc_check_possible_root((z))
#define GC_REMOVE_FROM_BUFFER(p) do { \ #define GC_REMOVE_FROM_BUFFER(p) do { \
zend_refcounted *_p = (zend_refcounted*)(p); \ zend_refcounted *_p = (zend_refcounted*)(p); \
if (GC_ADDRESS(GC_INFO(_p))) { \ if (GC_ADDRESS(GC_INFO(_p))) { \
gc_remove_from_buffer(_p TSRMLS_CC); \ gc_remove_from_buffer(_p); \
} \ } \
} while (0) } while (0)
static zend_always_inline void gc_check_possible_root(zval *z TSRMLS_DC) static zend_always_inline void gc_check_possible_root(zval *z)
{ {
ZVAL_DEREF(z); ZVAL_DEREF(z);
if (Z_COLLECTABLE_P(z) && UNEXPECTED(!Z_GC_INFO_P(z))) { if (Z_COLLECTABLE_P(z) && UNEXPECTED(!Z_GC_INFO_P(z))) {
gc_possible_root(Z_COUNTED_P(z) TSRMLS_CC); gc_possible_root(Z_COUNTED_P(z));
} }
} }

View file

@ -27,9 +27,9 @@
ZEND_API zend_class_entry *zend_ce_generator; ZEND_API zend_class_entry *zend_ce_generator;
static zend_object_handlers zend_generator_handlers; static zend_object_handlers zend_generator_handlers;
static zend_object *zend_generator_create(zend_class_entry *class_type TSRMLS_DC); static zend_object *zend_generator_create(zend_class_entry *class_type);
static void zend_generator_cleanup_unfinished_execution(zend_generator *generator TSRMLS_DC) /* {{{ */ static void zend_generator_cleanup_unfinished_execution(zend_generator *generator) /* {{{ */
{ {
zend_execute_data *execute_data = generator->execute_data; zend_execute_data *execute_data = generator->execute_data;
zend_op_array *op_array = &execute_data->func->op_array; zend_op_array *op_array = &execute_data->func->op_array;
@ -76,7 +76,7 @@ static void zend_generator_cleanup_unfinished_execution(zend_generator *generato
} }
/* }}} */ /* }}} */
ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC) /* {{{ */ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution) /* {{{ */
{ {
if (Z_TYPE(generator->value) != IS_UNDEF) { if (Z_TYPE(generator->value) != IS_UNDEF) {
zval_ptr_dtor(&generator->value); zval_ptr_dtor(&generator->value);
@ -93,9 +93,9 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
zend_op_array *op_array = &execute_data->func->op_array; zend_op_array *op_array = &execute_data->func->op_array;
if (!execute_data->symbol_table) { if (!execute_data->symbol_table) {
zend_free_compiled_variables(execute_data TSRMLS_CC); zend_free_compiled_variables(execute_data);
} else { } else {
zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC); zend_clean_and_cache_symbol_table(execute_data->symbol_table);
} }
if (Z_OBJ(execute_data->This)) { if (Z_OBJ(execute_data->This)) {
@ -109,17 +109,17 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
return; return;
} }
zend_vm_stack_free_extra_args(generator->execute_data TSRMLS_CC); zend_vm_stack_free_extra_args(generator->execute_data);
/* Some cleanups are only necessary if the generator was closued /* Some cleanups are only necessary if the generator was closued
* before it could finish execution (reach a return statement). */ * before it could finish execution (reach a return statement). */
if (!finished_execution) { if (!finished_execution) {
zend_generator_cleanup_unfinished_execution(generator TSRMLS_CC); zend_generator_cleanup_unfinished_execution(generator);
} }
/* Free a clone of closure */ /* Free a clone of closure */
if (op_array->fn_flags & ZEND_ACC_CLOSURE) { if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
destroy_op_array(op_array TSRMLS_CC); destroy_op_array(op_array);
efree_size(op_array, sizeof(zend_op_array)); efree_size(op_array, sizeof(zend_op_array));
} }
@ -129,7 +129,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
} }
/* }}} */ /* }}} */
static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */
{ {
zend_generator *generator = (zend_generator*) object; zend_generator *generator = (zend_generator*) object;
zend_execute_data *ex = generator->execute_data; zend_execute_data *ex = generator->execute_data;
@ -169,26 +169,26 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
fast_call->u2.lineno = (uint32_t)-1; fast_call->u2.lineno = (uint32_t)-1;
ex->opline = &ex->func->op_array.opcodes[finally_op_num]; ex->opline = &ex->func->op_array.opcodes[finally_op_num];
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE; generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
} }
} }
/* }}} */ /* }}} */
static void zend_generator_free_storage(zend_object *object TSRMLS_DC) /* {{{ */ static void zend_generator_free_storage(zend_object *object) /* {{{ */
{ {
zend_generator *generator = (zend_generator*) object; zend_generator *generator = (zend_generator*) object;
zend_generator_close(generator, 0 TSRMLS_CC); zend_generator_close(generator, 0);
zend_object_std_dtor(&generator->std TSRMLS_CC); zend_object_std_dtor(&generator->std);
if (generator->iterator) { if (generator->iterator) {
zend_iterator_dtor(generator->iterator TSRMLS_CC); zend_iterator_dtor(generator->iterator);
} }
} }
/* }}} */ /* }}} */
static zend_object *zend_generator_create(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ static zend_object *zend_generator_create(zend_class_entry *class_type) /* {{{ */
{ {
zend_generator *generator; zend_generator *generator;
@ -198,14 +198,14 @@ static zend_object *zend_generator_create(zend_class_entry *class_type TSRMLS_DC
/* The key will be incremented on first use, so it'll start at 0 */ /* The key will be incremented on first use, so it'll start at 0 */
generator->largest_used_integer_key = -1; generator->largest_used_integer_key = -1;
zend_object_std_init(&generator->std, class_type TSRMLS_CC); zend_object_std_init(&generator->std, class_type);
generator->std.handlers = &zend_generator_handlers; generator->std.handlers = &zend_generator_handlers;
return (zend_object*)generator; return (zend_object*)generator;
} }
/* }}} */ /* }}} */
static int copy_closure_static_var(zval *var TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */ static int copy_closure_static_var(zval *var, int num_args, va_list args, zend_hash_key *key) /* {{{ */
{ {
HashTable *target = va_arg(args, HashTable *); HashTable *target = va_arg(args, HashTable *);
@ -217,7 +217,7 @@ static int copy_closure_static_var(zval *var TSRMLS_DC, int num_args, va_list ar
/* }}} */ /* }}} */
/* Requires globals EG(scope), EG(This) and EG(current_execute_data). */ /* Requires globals EG(scope), EG(This) and EG(current_execute_data). */
ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array *op_array, zval *return_value TSRMLS_DC) /* {{{ */ ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array *op_array, zval *return_value) /* {{{ */
{ {
zend_generator *generator; zend_generator *generator;
zend_execute_data *current_execute_data; zend_execute_data *current_execute_data;
@ -240,7 +240,7 @@ ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array
NULL, ZVAL_PTR_DTOR, 0 NULL, ZVAL_PTR_DTOR, 0
); );
zend_hash_apply_with_arguments( zend_hash_apply_with_arguments(
op_array->static_variables TSRMLS_CC, op_array->static_variables,
copy_closure_static_var, 1, copy_closure_static_var, 1,
op_array_copy->static_variables op_array_copy->static_variables
); );
@ -252,7 +252,7 @@ ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array
/* Create new execution context. We have to back up and restore /* Create new execution context. We have to back up and restore
* EG(current_execute_data) here. */ * EG(current_execute_data) here. */
current_execute_data = EG(current_execute_data); current_execute_data = EG(current_execute_data);
execute_data = zend_create_generator_execute_data(call, op_array, return_value TSRMLS_CC); execute_data = zend_create_generator_execute_data(call, op_array, return_value);
EG(current_execute_data) = current_execute_data; EG(current_execute_data) = current_execute_data;
object_init_ex(return_value, zend_ce_generator); object_init_ex(return_value, zend_ce_generator);
@ -276,7 +276,7 @@ ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array
} }
/* }}} */ /* }}} */
static zend_function *zend_generator_get_constructor(zend_object *object TSRMLS_DC) /* {{{ */ static zend_function *zend_generator_get_constructor(zend_object *object) /* {{{ */
{ {
zend_error(E_RECOVERABLE_ERROR, "The \"Generator\" class is reserved for internal use and cannot be manually instantiated"); zend_error(E_RECOVERABLE_ERROR, "The \"Generator\" class is reserved for internal use and cannot be manually instantiated");
@ -284,7 +284,7 @@ static zend_function *zend_generator_get_constructor(zend_object *object TSRMLS_
} }
/* }}} */ /* }}} */
ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */
{ {
/* The generator is already closed, thus can't resume */ /* The generator is already closed, thus can't resume */
if (!generator->execute_data) { if (!generator->execute_data) {
@ -320,7 +320,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
/* Resume execution */ /* Resume execution */
generator->flags |= ZEND_GENERATOR_CURRENTLY_RUNNING; generator->flags |= ZEND_GENERATOR_CURRENTLY_RUNNING;
zend_execute_ex(generator->execute_data TSRMLS_CC); zend_execute_ex(generator->execute_data);
generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING; generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING;
/* Unlink generator call_frame from the caller */ /* Unlink generator call_frame from the caller */
@ -338,27 +338,27 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
/* If an exception was thrown in the generator we have to internally /* If an exception was thrown in the generator we have to internally
* rethrow it in the parent scope. */ * rethrow it in the parent scope. */
if (UNEXPECTED(EG(exception) != NULL)) { if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC); zend_throw_exception_internal(NULL);
} }
} }
} }
/* }}} */ /* }}} */
static void zend_generator_ensure_initialized(zend_generator *generator TSRMLS_DC) /* {{{ */ static void zend_generator_ensure_initialized(zend_generator *generator) /* {{{ */
{ {
if (generator->execute_data && Z_TYPE(generator->value) == IS_UNDEF) { if (generator->execute_data && Z_TYPE(generator->value) == IS_UNDEF) {
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD; generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD;
} }
} }
/* }}} */ /* }}} */
static void zend_generator_rewind(zend_generator *generator TSRMLS_DC) /* {{{ */ static void zend_generator_rewind(zend_generator *generator) /* {{{ */
{ {
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
if (!(generator->flags & ZEND_GENERATOR_AT_FIRST_YIELD)) { if (!(generator->flags & ZEND_GENERATOR_AT_FIRST_YIELD)) {
zend_throw_exception(NULL, "Cannot rewind a generator that was already run", 0 TSRMLS_CC); zend_throw_exception(NULL, "Cannot rewind a generator that was already run", 0);
} }
} }
/* }}} */ /* }}} */
@ -375,7 +375,7 @@ ZEND_METHOD(Generator, rewind)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_rewind(generator TSRMLS_CC); zend_generator_rewind(generator);
} }
/* }}} */ /* }}} */
@ -391,7 +391,7 @@ ZEND_METHOD(Generator, valid)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
RETURN_BOOL(Z_TYPE(generator->value) != IS_UNDEF); RETURN_BOOL(Z_TYPE(generator->value) != IS_UNDEF);
} }
@ -409,7 +409,7 @@ ZEND_METHOD(Generator, current)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
if (Z_TYPE(generator->value) != IS_UNDEF) { if (Z_TYPE(generator->value) != IS_UNDEF) {
RETURN_ZVAL_FAST(&generator->value); RETURN_ZVAL_FAST(&generator->value);
@ -429,7 +429,7 @@ ZEND_METHOD(Generator, key)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
if (Z_TYPE(generator->key) != IS_UNDEF) { if (Z_TYPE(generator->key) != IS_UNDEF) {
RETURN_ZVAL_FAST(&generator->key); RETURN_ZVAL_FAST(&generator->key);
@ -449,9 +449,9 @@ ZEND_METHOD(Generator, next)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
} }
/* }}} */ /* }}} */
@ -462,13 +462,13 @@ ZEND_METHOD(Generator, send)
zval *value; zval *value;
zend_generator *generator; zend_generator *generator;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
return; return;
} }
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
/* The generator is already closed, thus can't send anything */ /* The generator is already closed, thus can't send anything */
if (!generator->execute_data) { if (!generator->execute_data) {
@ -481,7 +481,7 @@ ZEND_METHOD(Generator, send)
ZVAL_COPY(generator->send_target, value); ZVAL_COPY(generator->send_target, value);
} }
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
if (Z_TYPE(generator->value) != IS_UNDEF) { if (Z_TYPE(generator->value) != IS_UNDEF) {
RETURN_ZVAL_FAST(&generator->value); RETURN_ZVAL_FAST(&generator->value);
@ -496,7 +496,7 @@ ZEND_METHOD(Generator, throw)
zval *exception, exception_copy; zval *exception, exception_copy;
zend_generator *generator; zend_generator *generator;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &exception) == FAILURE) {
return; return;
} }
@ -504,18 +504,18 @@ ZEND_METHOD(Generator, throw)
generator = (zend_generator *) Z_OBJ_P(getThis()); generator = (zend_generator *) Z_OBJ_P(getThis());
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
if (generator->execute_data) { if (generator->execute_data) {
/* Throw the exception in the context of the generator */ /* Throw the exception in the context of the generator */
zend_execute_data *current_execute_data = EG(current_execute_data); zend_execute_data *current_execute_data = EG(current_execute_data);
EG(current_execute_data) = generator->execute_data; EG(current_execute_data) = generator->execute_data;
zend_throw_exception_object(&exception_copy TSRMLS_CC); zend_throw_exception_object(&exception_copy);
EG(current_execute_data) = current_execute_data; EG(current_execute_data) = current_execute_data;
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
if (Z_TYPE(generator->value) != IS_UNDEF) { if (Z_TYPE(generator->value) != IS_UNDEF) {
RETURN_ZVAL_FAST(&generator->value); RETURN_ZVAL_FAST(&generator->value);
@ -523,7 +523,7 @@ ZEND_METHOD(Generator, throw)
} else { } else {
/* If the generator is already closed throw the exception in the /* If the generator is already closed throw the exception in the
* current context */ * current context */
zend_throw_exception_object(&exception_copy TSRMLS_CC); zend_throw_exception_object(&exception_copy);
} }
} }
/* }}} */ /* }}} */
@ -540,46 +540,46 @@ ZEND_METHOD(Generator, __wakeup)
return; return;
} }
zend_throw_exception(NULL, "Unserialization of 'Generator' is not allowed", 0 TSRMLS_CC); zend_throw_exception(NULL, "Unserialization of 'Generator' is not allowed", 0);
} }
/* }}} */ /* }}} */
/* get_iterator implementation */ /* get_iterator implementation */
static void zend_generator_iterator_dtor(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ static void zend_generator_iterator_dtor(zend_object_iterator *iterator) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
generator->iterator = NULL; generator->iterator = NULL;
zval_ptr_dtor(&iterator->data); zval_ptr_dtor(&iterator->data);
zend_iterator_dtor(iterator TSRMLS_CC); zend_iterator_dtor(iterator);
} }
/* }}} */ /* }}} */
static int zend_generator_iterator_valid(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ static int zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
return Z_TYPE(generator->value) != IS_UNDEF ? SUCCESS : FAILURE; return Z_TYPE(generator->value) != IS_UNDEF ? SUCCESS : FAILURE;
} }
/* }}} */ /* }}} */
static zval *zend_generator_iterator_get_data(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ static zval *zend_generator_iterator_get_data(zend_object_iterator *iterator) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
return &generator->value; return &generator->value;
} }
/* }}} */ /* }}} */
static void zend_generator_iterator_get_key(zend_object_iterator *iterator, zval *key TSRMLS_DC) /* {{{ */ static void zend_generator_iterator_get_key(zend_object_iterator *iterator, zval *key) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
if (Z_TYPE(generator->key) != IS_UNDEF) { if (Z_TYPE(generator->key) != IS_UNDEF) {
ZVAL_ZVAL(key, &generator->key, 1, 0); ZVAL_ZVAL(key, &generator->key, 1, 0);
@ -589,21 +589,21 @@ static void zend_generator_iterator_get_key(zend_object_iterator *iterator, zval
} }
/* }}} */ /* }}} */
static void zend_generator_iterator_move_forward(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ static void zend_generator_iterator_move_forward(zend_object_iterator *iterator) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zend_generator_ensure_initialized(generator TSRMLS_CC); zend_generator_ensure_initialized(generator);
zend_generator_resume(generator TSRMLS_CC); zend_generator_resume(generator);
} }
/* }}} */ /* }}} */
static void zend_generator_iterator_rewind(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ static void zend_generator_iterator_rewind(zend_object_iterator *iterator) /* {{{ */
{ {
zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zend_generator_rewind(generator TSRMLS_CC); zend_generator_rewind(generator);
} }
/* }}} */ /* }}} */
@ -616,24 +616,24 @@ static zend_object_iterator_funcs zend_generator_iterator_functions = {
zend_generator_iterator_rewind zend_generator_iterator_rewind
}; };
zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
{ {
zend_object_iterator *iterator; zend_object_iterator *iterator;
zend_generator *generator = (zend_generator*)Z_OBJ_P(object); zend_generator *generator = (zend_generator*)Z_OBJ_P(object);
if (!generator->execute_data) { if (!generator->execute_data) {
zend_throw_exception(NULL, "Cannot traverse an already closed generator", 0 TSRMLS_CC); zend_throw_exception(NULL, "Cannot traverse an already closed generator", 0);
return NULL; return NULL;
} }
if (by_ref && !(generator->execute_data->func->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE)) { if (by_ref && !(generator->execute_data->func->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE)) {
zend_throw_exception(NULL, "You can only iterate a generator by-reference if it declared that it yields by-reference", 0 TSRMLS_CC); zend_throw_exception(NULL, "You can only iterate a generator by-reference if it declared that it yields by-reference", 0);
return NULL; return NULL;
} }
iterator = generator->iterator = emalloc(sizeof(zend_object_iterator)); iterator = generator->iterator = emalloc(sizeof(zend_object_iterator));
zend_iterator_init(iterator TSRMLS_CC); zend_iterator_init(iterator);
iterator->funcs = &zend_generator_iterator_functions; iterator->funcs = &zend_generator_iterator_functions;
ZVAL_COPY(&iterator->data, object); ZVAL_COPY(&iterator->data, object);
@ -665,19 +665,19 @@ static const zend_function_entry generator_functions[] = {
ZEND_FE_END ZEND_FE_END
}; };
void zend_register_generator_ce(TSRMLS_D) /* {{{ */ void zend_register_generator_ce(void) /* {{{ */
{ {
zend_class_entry ce; zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Generator", generator_functions); INIT_CLASS_ENTRY(ce, "Generator", generator_functions);
zend_ce_generator = zend_register_internal_class(&ce TSRMLS_CC); zend_ce_generator = zend_register_internal_class(&ce);
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL; zend_ce_generator->ce_flags |= ZEND_ACC_FINAL;
zend_ce_generator->create_object = zend_generator_create; zend_ce_generator->create_object = zend_generator_create;
zend_ce_generator->serialize = zend_class_serialize_deny; zend_ce_generator->serialize = zend_class_serialize_deny;
zend_ce_generator->unserialize = zend_class_unserialize_deny; zend_ce_generator->unserialize = zend_class_unserialize_deny;
/* get_iterator has to be assigned *after* implementing the inferface */ /* get_iterator has to be assigned *after* implementing the inferface */
zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator); zend_class_implements(zend_ce_generator, 1, zend_ce_iterator);
zend_ce_generator->get_iterator = zend_generator_get_iterator; zend_ce_generator->get_iterator = zend_generator_get_iterator;
zend_ce_generator->iterator_funcs.funcs = &zend_generator_iterator_functions; zend_ce_generator->iterator_funcs.funcs = &zend_generator_iterator_functions;

View file

@ -53,10 +53,10 @@ static const zend_uchar ZEND_GENERATOR_CURRENTLY_RUNNING = 0x1;
static const zend_uchar ZEND_GENERATOR_FORCED_CLOSE = 0x2; static const zend_uchar ZEND_GENERATOR_FORCED_CLOSE = 0x2;
static const zend_uchar ZEND_GENERATOR_AT_FIRST_YIELD = 0x4; static const zend_uchar ZEND_GENERATOR_AT_FIRST_YIELD = 0x4;
void zend_register_generator_ce(TSRMLS_D); void zend_register_generator_ce(void);
ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array *op_array, zval *return_value TSRMLS_DC); ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array *op_array, zval *return_value);
ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC); ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution);
ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC); ZEND_API void zend_generator_resume(zend_generator *generator);
END_EXTERN_C() END_EXTERN_C()

View file

@ -265,7 +265,6 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -419,7 +418,6 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht,
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -568,7 +566,6 @@ ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_
static void zend_hash_do_resize(HashTable *ht) static void zend_hash_do_resize(HashTable *ht)
{ {
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -689,7 +686,6 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key)
Bucket *p; Bucket *p;
Bucket *prev = NULL; Bucket *prev = NULL;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -728,7 +724,6 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key)
Bucket *p; Bucket *p;
Bucket *prev = NULL; Bucket *prev = NULL;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -780,7 +775,6 @@ ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, size_t len)
Bucket *p; Bucket *p;
Bucket *prev = NULL; Bucket *prev = NULL;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -831,7 +825,6 @@ ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len)
Bucket *p; Bucket *p;
Bucket *prev = NULL; Bucket *prev = NULL;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -864,7 +857,6 @@ ZEND_API int zend_hash_index_del(HashTable *ht, zend_ulong h)
Bucket *p; Bucket *p;
Bucket *prev = NULL; Bucket *prev = NULL;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
IS_CONSISTENT(ht); IS_CONSISTENT(ht);
@ -945,7 +937,7 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT); pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
} }
ZEND_API void zend_array_destroy(HashTable *ht TSRMLS_DC) ZEND_API void zend_array_destroy(HashTable *ht)
{ {
Bucket *p, *end; Bucket *p, *end;
@ -966,13 +958,13 @@ ZEND_API void zend_array_destroy(HashTable *ht TSRMLS_DC)
if (ht->u.flags & HASH_FLAG_PACKED) { if (ht->u.flags & HASH_FLAG_PACKED) {
do { do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) { if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC);
} }
} while (++p != end); } while (++p != end);
} else { } else {
do { do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) { if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC);
if (EXPECTED(p->key)) { if (EXPECTED(p->key)) {
zend_string_release(p->key); zend_string_release(p->key);
} }
@ -1036,7 +1028,7 @@ ZEND_API void zend_hash_clean(HashTable *ht)
} }
} }
ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC) ZEND_API void zend_symtable_clean(HashTable *ht)
{ {
Bucket *p, *end; Bucket *p, *end;
@ -1047,7 +1039,7 @@ ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC)
end = p + ht->nNumUsed; end = p + ht->nNumUsed;
do { do {
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) { if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF)) {
i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(&p->val ZEND_FILE_LINE_CC);
if (EXPECTED(p->key)) { if (EXPECTED(p->key)) {
zend_string_release(p->key); zend_string_release(p->key);
} }
@ -1073,7 +1065,6 @@ ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC)
static void zend_hash_apply_deleter(HashTable *ht, uint32_t idx, Bucket *p) static void zend_hash_apply_deleter(HashTable *ht, uint32_t idx, Bucket *p)
{ {
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif #endif
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
@ -1132,7 +1123,7 @@ ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)
* ZEND_HASH_APPLY_REMOVE - delete the element, combineable with the former * ZEND_HASH_APPLY_REMOVE - delete the element, combineable with the former
*/ */
ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC) ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
@ -1145,7 +1136,7 @@ ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
p = ht->arData + idx; p = ht->arData + idx;
if (Z_TYPE(p->val) == IS_UNDEF) continue; if (Z_TYPE(p->val) == IS_UNDEF) continue;
result = apply_func(&p->val TSRMLS_CC); result = apply_func(&p->val);
if (result & ZEND_HASH_APPLY_REMOVE) { if (result & ZEND_HASH_APPLY_REMOVE) {
zend_hash_apply_deleter(ht, idx, p); zend_hash_apply_deleter(ht, idx, p);
@ -1158,7 +1149,7 @@ ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
} }
ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
@ -1171,7 +1162,7 @@ ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t appl
p = ht->arData + idx; p = ht->arData + idx;
if (Z_TYPE(p->val) == IS_UNDEF) continue; if (Z_TYPE(p->val) == IS_UNDEF) continue;
result = apply_func(&p->val, argument TSRMLS_CC); result = apply_func(&p->val, argument);
if (result & ZEND_HASH_APPLY_REMOVE) { if (result & ZEND_HASH_APPLY_REMOVE) {
zend_hash_apply_deleter(ht, idx, p); zend_hash_apply_deleter(ht, idx, p);
@ -1184,7 +1175,7 @@ ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t appl
} }
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...) ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int num_args, ...)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
@ -1203,7 +1194,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func
hash_key.h = p->h; hash_key.h = p->h;
hash_key.key = p->key; hash_key.key = p->key;
result = apply_func(&p->val TSRMLS_CC, num_args, args, &hash_key); result = apply_func(&p->val, num_args, args, &hash_key);
if (result & ZEND_HASH_APPLY_REMOVE) { if (result & ZEND_HASH_APPLY_REMOVE) {
zend_hash_apply_deleter(ht, idx, p); zend_hash_apply_deleter(ht, idx, p);
@ -1219,7 +1210,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func
} }
ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC) ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
@ -1234,7 +1225,7 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSR
p = ht->arData + idx; p = ht->arData + idx;
if (Z_TYPE(p->val) == IS_UNDEF) continue; if (Z_TYPE(p->val) == IS_UNDEF) continue;
result = apply_func(&p->val TSRMLS_CC); result = apply_func(&p->val);
if (result & ZEND_HASH_APPLY_REMOVE) { if (result & ZEND_HASH_APPLY_REMOVE) {
zend_hash_apply_deleter(ht, idx, p); zend_hash_apply_deleter(ht, idx, p);
@ -1750,7 +1741,7 @@ ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
} }
ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
compare_func_t compar, zend_bool renumber TSRMLS_DC) compare_func_t compar, zend_bool renumber)
{ {
Bucket *p; Bucket *p;
uint32_t i, j; uint32_t i, j;
@ -1774,7 +1765,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
} }
} }
(*sort_func)((void *) ht->arData, i, sizeof(Bucket), compar TSRMLS_CC); (*sort_func)((void *) ht->arData, i, sizeof(Bucket), compar);
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
ht->nNumUsed = i; ht->nNumUsed = i;
@ -1812,7 +1803,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
} }
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered)
{ {
uint32_t idx1, idx2; uint32_t idx1, idx2;
Bucket *p1, *p2 = NULL; Bucket *p1, *p2 = NULL;
@ -1901,7 +1892,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
} else if (Z_TYPE_P(pData2) == IS_UNDEF) { } else if (Z_TYPE_P(pData2) == IS_UNDEF) {
return 1; return 1;
} else { } else {
result = compar(pData1, pData2 TSRMLS_CC); result = compar(pData1, pData2);
} }
if (result != 0) { if (result != 0) {
HASH_UNPROTECT_RECURSION(ht1); HASH_UNPROTECT_RECURSION(ht1);
@ -1919,7 +1910,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
} }
ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag TSRMLS_DC) ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag)
{ {
uint32_t idx; uint32_t idx;
Bucket *p, *res; Bucket *p, *res;
@ -1944,11 +1935,11 @@ ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint
if (Z_TYPE(p->val) == IS_UNDEF) continue; if (Z_TYPE(p->val) == IS_UNDEF) continue;
if (flag) { if (flag) {
if (compar(res, p TSRMLS_CC) < 0) { /* max */ if (compar(res, p) < 0) { /* max */
res = p; res = p;
} }
} else { } else {
if (compar(res, p TSRMLS_CC) > 0) { /* min */ if (compar(res, p) > 0) { /* min */
res = p; res = p;
} }
} }

View file

@ -122,15 +122,15 @@ ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *key, s
#define ZEND_HASH_APPLY_REMOVE 1<<0 #define ZEND_HASH_APPLY_REMOVE 1<<0
#define ZEND_HASH_APPLY_STOP 1<<1 #define ZEND_HASH_APPLY_STOP 1<<1
typedef int (*apply_func_t)(zval *pDest TSRMLS_DC); typedef int (*apply_func_t)(zval *pDest);
typedef int (*apply_func_arg_t)(zval *pDest, void *argument TSRMLS_DC); typedef int (*apply_func_arg_t)(zval *pDest, void *argument);
typedef int (*apply_func_args_t)(zval *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key); typedef int (*apply_func_args_t)(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key);
ZEND_API void zend_hash_graceful_destroy(HashTable *ht); ZEND_API void zend_hash_graceful_destroy(HashTable *ht);
ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht); ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht);
ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC); ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func);
ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC); ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *);
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int, ...); ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
/* This function should be used with special care (in other words, /* This function should be used with special care (in other words,
* it should usually not be used). When used with the ZEND_HASH_APPLY_STOP * it should usually not be used). When used with the ZEND_HASH_APPLY_STOP
@ -138,7 +138,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func
* Also, it does not provide the same kind of reentrancy protection that * Also, it does not provide the same kind of reentrancy protection that
* the standard apply functions do. * the standard apply functions do.
*/ */
ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC); ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func);
/* Deletes */ /* Deletes */
@ -200,9 +200,9 @@ typedef struct _HashPointer {
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor); ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor);
ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, zend_bool overwrite ZEND_FILE_LINE_DC); ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, zend_bool overwrite ZEND_FILE_LINE_DC);
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam); ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam);
ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, zend_bool renumber TSRMLS_DC); ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, zend_bool renumber);
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC); ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered);
ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag TSRMLS_DC); ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);
#define zend_hash_merge(target, source, pCopyConstructor, overwrite) \ #define zend_hash_merge(target, source, pCopyConstructor, overwrite) \
_zend_hash_merge(target, source, pCopyConstructor, overwrite ZEND_FILE_LINE_CC) _zend_hash_merge(target, source, pCopyConstructor, overwrite ZEND_FILE_LINE_CC)
@ -216,8 +216,8 @@ ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint
ZEND_API int zend_hash_rehash(HashTable *ht); ZEND_API int zend_hash_rehash(HashTable *ht);
ZEND_API void zend_array_dup(HashTable *target, HashTable *source); ZEND_API void zend_array_dup(HashTable *target, HashTable *source);
ZEND_API void zend_array_destroy(HashTable *ht TSRMLS_DC); ZEND_API void zend_array_destroy(HashTable *ht);
ZEND_API void zend_symtable_clean(HashTable *ht TSRMLS_DC); ZEND_API void zend_symtable_clean(HashTable *ht);
#if ZEND_DEBUG #if ZEND_DEBUG
/* debug */ /* debug */

View file

@ -54,14 +54,14 @@ ZEND_API void zend_html_putc(char c)
} }
ZEND_API void zend_html_puts(const char *s, size_t len TSRMLS_DC) ZEND_API void zend_html_puts(const char *s, size_t len)
{ {
const unsigned char *ptr = (const unsigned char*)s, *end = ptr + len; const unsigned char *ptr = (const unsigned char*)s, *end = ptr + len;
unsigned char *filtered = NULL; unsigned char *filtered = NULL;
size_t filtered_len; size_t filtered_len;
if (LANG_SCNG(output_filter)) { if (LANG_SCNG(output_filter)) {
LANG_SCNG(output_filter)(&filtered, &filtered_len, ptr, len TSRMLS_CC); LANG_SCNG(output_filter)(&filtered, &filtered_len, ptr, len);
ptr = filtered; ptr = filtered;
end = filtered + filtered_len; end = filtered + filtered_len;
} }
@ -82,7 +82,7 @@ ZEND_API void zend_html_puts(const char *s, size_t len TSRMLS_DC)
} }
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini)
{ {
zval token; zval token;
int token_type; int token_type;
@ -93,7 +93,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_printf("<span style=\"color: %s\">\n", last_color); zend_printf("<span style=\"color: %s\">\n", last_color);
/* highlight stuff coming back from zendlex() */ /* highlight stuff coming back from zendlex() */
ZVAL_UNDEF(&token); ZVAL_UNDEF(&token);
while ((token_type=lex_scan(&token TSRMLS_CC))) { while ((token_type=lex_scan(&token))) {
switch (token_type) { switch (token_type) {
case T_INLINE_HTML: case T_INLINE_HTML:
next_color = syntax_highlighter_ini->highlight_html; next_color = syntax_highlighter_ini->highlight_html;
@ -121,7 +121,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
next_color = syntax_highlighter_ini->highlight_string; next_color = syntax_highlighter_ini->highlight_string;
break; break;
case T_WHITESPACE: case T_WHITESPACE:
zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC); /* no color needed */ zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); /* no color needed */
ZVAL_UNDEF(&token); ZVAL_UNDEF(&token);
continue; continue;
break; break;
@ -144,7 +144,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
} }
} }
zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC); zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
if (Z_TYPE(token) == IS_STRING) { if (Z_TYPE(token) == IS_STRING) {
switch (token_type) { switch (token_type) {
@ -170,14 +170,14 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_printf("</code>"); zend_printf("</code>");
} }
ZEND_API void zend_strip(TSRMLS_D) ZEND_API void zend_strip(void)
{ {
zval token; zval token;
int token_type; int token_type;
int prev_space = 0; int prev_space = 0;
ZVAL_UNDEF(&token); ZVAL_UNDEF(&token);
while ((token_type=lex_scan(&token TSRMLS_CC))) { while ((token_type=lex_scan(&token))) {
switch (token_type) { switch (token_type) {
case T_WHITESPACE: case T_WHITESPACE:
if (!prev_space) { if (!prev_space) {
@ -193,7 +193,7 @@ ZEND_API void zend_strip(TSRMLS_D)
case T_END_HEREDOC: case T_END_HEREDOC:
zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
/* read the following character, either newline or ; */ /* read the following character, either newline or ; */
if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) { if (lex_scan(&token) != T_WHITESPACE) {
zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
} }
zend_write("\n", sizeof("\n") - 1); zend_write("\n", sizeof("\n") - 1);

View file

@ -39,12 +39,12 @@ typedef struct _zend_syntax_highlighter_ini {
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC); ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API void zend_strip(TSRMLS_D); ZEND_API void zend_strip(void);
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC); ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC); ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name);
ZEND_API void zend_html_putc(char c); ZEND_API void zend_html_putc(char c);
ZEND_API void zend_html_puts(const char *s, size_t len TSRMLS_DC); ZEND_API void zend_html_puts(const char *s, size_t len);
END_EXTERN_C() END_EXTERN_C()
extern zend_syntax_highlighter_ini syntax_highlighter_ini; extern zend_syntax_highlighter_ini syntax_highlighter_ini;

View file

@ -47,7 +47,7 @@ static void handle_whitespace(unsigned int *emit_whitespace)
} }
ZEND_API void zend_indent(TSRMLS_D) ZEND_API void zend_indent(void)
{ {
zval token; zval token;
int token_type; int token_type;
@ -60,7 +60,7 @@ ZEND_API void zend_indent(TSRMLS_D)
/* highlight stuff coming back from zendlex() */ /* highlight stuff coming back from zendlex() */
ZVAL_UNDEF(&token); ZVAL_UNDEF(&token);
while ((token_type=lex_scan(&token TSRMLS_CC))) { while ((token_type=lex_scan(&token))) {
switch (token_type) { switch (token_type) {
case T_INLINE_HTML: case T_INLINE_HTML:
zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));

View file

@ -23,7 +23,7 @@
#define ZEND_INDENT_H #define ZEND_INDENT_H
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_indent(TSRMLS_D); ZEND_API void zend_indent(void);
END_EXTERN_C() END_EXTERN_C()
#endif /* ZEND_INDENT_H */ #endif /* ZEND_INDENT_H */

View file

@ -29,7 +29,7 @@ static void ptr_dtor(zval *zv) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_property_info *zend_duplicate_property_info(zend_property_info *property_info TSRMLS_DC) /* {{{ */ static zend_property_info *zend_duplicate_property_info(zend_property_info *property_info) /* {{{ */
{ {
zend_property_info* new_property_info; zend_property_info* new_property_info;
@ -52,7 +52,7 @@ static zend_property_info *zend_duplicate_property_info_internal(zend_property_i
} }
/* }}} */ /* }}} */
static void do_inherit_parent_constructor(zend_class_entry *ce TSRMLS_DC) /* {{{ */ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
{ {
zend_function *function, *new_function; zend_function *function, *new_function;
@ -187,7 +187,7 @@ char *zend_visibility_string(uint32_t fn_flags) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_function *do_inherit_method(zend_function *old_function, zend_class_entry *ce TSRMLS_DC) /* {{{ */ static zend_function *do_inherit_method(zend_function *old_function, zend_class_entry *ce) /* {{{ */
{ {
zend_function *new_function; zend_function *new_function;
@ -213,7 +213,7 @@ static zend_function *do_inherit_method(zend_function *old_function, zend_class_
} }
/* }}} */ /* }}} */
static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto TSRMLS_DC) /* {{{ */ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto) /* {{{ */
{ {
uint32_t i, num_args; uint32_t i, num_args;
@ -331,8 +331,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
strcasecmp(colon+1, proto_class_name->val) != 0) { strcasecmp(colon+1, proto_class_name->val) != 0) {
zend_class_entry *fe_ce, *proto_ce; zend_class_entry *fe_ce, *proto_ce;
fe_ce = zend_lookup_class(fe_class_name TSRMLS_CC); fe_ce = zend_lookup_class(fe_class_name);
proto_ce = zend_lookup_class(proto_class_name TSRMLS_CC); proto_ce = zend_lookup_class(proto_class_name);
/* Check for class alias */ /* Check for class alias */
if (!fe_ce || !proto_ce || if (!fe_ce || !proto_ce ||
@ -363,7 +363,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
} }
/* }}} */ /* }}} */
static zend_string *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{ */ static zend_string *zend_get_function_declaration(zend_function *fptr) /* {{{ */
{ {
smart_str str = {0}; smart_str str = {0};
@ -500,7 +500,7 @@ static zend_string *zend_get_function_declaration(zend_function *fptr TSRMLS_DC)
} }
/* }}} */ /* }}} */
static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC) /* {{{ */ static void do_inheritance_check_on_method(zend_function *child, zend_function *parent) /* {{{ */
{ {
uint32_t child_flags; uint32_t child_flags;
uint32_t parent_flags = parent->common.fn_flags; uint32_t parent_flags = parent->common.fn_flags;
@ -559,12 +559,12 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
} }
if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) { if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) {
if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) { if (!zend_do_perform_implementation_check(child, child->common.prototype)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name->val, zend_get_function_declaration(child->common.prototype TSRMLS_CC)->val); zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name->val, zend_get_function_declaration(child->common.prototype)->val);
} }
} else if (EG(error_reporting) & E_STRICT || Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */ } else if (EG(error_reporting) & E_STRICT || Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */
if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) { if (!zend_do_perform_implementation_check(child, parent)) {
zend_string *method_prototype = zend_get_function_declaration(parent TSRMLS_CC); zend_string *method_prototype = zend_get_function_declaration(parent);
zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name->val, method_prototype->val); zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name->val, method_prototype->val);
zend_string_free(method_prototype); zend_string_free(method_prototype);
} }
@ -576,7 +576,6 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
{ {
uint32_t parent_flags = parent->common.fn_flags; uint32_t parent_flags = parent->common.fn_flags;
zend_function *child; zend_function *child;
TSRMLS_FETCH();
if ((child = zend_hash_find_ptr(child_function_table, key)) == NULL) { if ((child = zend_hash_find_ptr(child_function_table, key)) == NULL) {
if (parent_flags & (ZEND_ACC_ABSTRACT)) { if (parent_flags & (ZEND_ACC_ABSTRACT)) {
@ -585,13 +584,13 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
return 1; /* method doesn't exist in child, copy from parent */ return 1; /* method doesn't exist in child, copy from parent */
} }
do_inheritance_check_on_method(child, parent TSRMLS_CC); do_inheritance_check_on_method(child, parent);
return 0; return 0;
} }
/* }}} */ /* }}} */
static zend_bool do_inherit_property_access_check(zend_property_info *parent_info, zend_string *key, zend_class_entry *ce TSRMLS_DC) /* {{{ */ static zend_bool do_inherit_property_access_check(zend_property_info *parent_info, zend_string *key, zend_class_entry *ce) /* {{{ */
{ {
zend_property_info *child_info; zend_property_info *child_info;
zend_class_entry *parent_ce = ce->parent; zend_class_entry *parent_ce = ce->parent;
@ -603,7 +602,7 @@ static zend_bool do_inherit_property_access_check(zend_property_info *parent_inf
if(ce->type & ZEND_INTERNAL_CLASS) { if(ce->type & ZEND_INTERNAL_CLASS) {
child_info = zend_duplicate_property_info_internal(parent_info); child_info = zend_duplicate_property_info_internal(parent_info);
} else { } else {
child_info = zend_duplicate_property_info(parent_info TSRMLS_CC); child_info = zend_duplicate_property_info(parent_info);
} }
zend_hash_update_ptr(&ce->properties_info, key, child_info); zend_hash_update_ptr(&ce->properties_info, key, child_info);
child_info->flags &= ~ZEND_ACC_PRIVATE; /* it's not private anymore */ child_info->flags &= ~ZEND_ACC_PRIVATE; /* it's not private anymore */
@ -642,9 +641,9 @@ static zend_bool do_inherit_property_access_check(zend_property_info *parent_inf
} }
/* }}} */ /* }}} */
static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */ static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
{ {
if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce TSRMLS_CC) == FAILURE) { if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce) == FAILURE) {
zend_error(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name->val, iface->name->val); zend_error(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name->val, iface->name->val);
} }
if (ce == iface) { if (ce == iface) {
@ -653,7 +652,7 @@ static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry
} }
/* }}} */ /* }}} */
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC) /* {{{ */ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface) /* {{{ */
{ {
/* expects interface to be contained in ce's interface list already */ /* expects interface to be contained in ce's interface list already */
uint32_t i, ce_num, if_num = iface->num_interfaces; uint32_t i, ce_num, if_num = iface->num_interfaces;
@ -685,7 +684,7 @@ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_
/* and now call the implementing handlers */ /* and now call the implementing handlers */
while (ce_num < ce->num_interfaces) { while (ce_num < ce->num_interfaces) {
do_implement_interface(ce, ce->interfaces[ce_num++] TSRMLS_CC); do_implement_interface(ce, ce->interfaces[ce_num++]);
} }
} }
/* }}} */ /* }}} */
@ -698,7 +697,7 @@ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_
zval_add_ref zval_add_ref
#endif #endif
static void do_inherit_class_constant(zend_string *name, zval *zv, zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC) /* {{{ */ static void do_inherit_class_constant(zend_string *name, zval *zv, zend_class_entry *ce, zend_class_entry *parent_ce) /* {{{ */
{ {
if (!Z_ISREF_P(zv)) { if (!Z_ISREF_P(zv)) {
if (parent_ce->type == ZEND_INTERNAL_CLASS) { if (parent_ce->type == ZEND_INTERNAL_CLASS) {
@ -716,7 +715,7 @@ static void do_inherit_class_constant(zend_string *name, zval *zv, zend_class_en
} }
/* }}} */ /* }}} */
ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC) /* {{{ */ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce) /* {{{ */
{ {
zend_property_info *property_info; zend_property_info *property_info;
zend_function *func; zend_function *func;
@ -741,7 +740,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
} }
/* Inherit interfaces */ /* Inherit interfaces */
zend_do_inherit_interfaces(ce, parent_ce TSRMLS_CC); zend_do_inherit_interfaces(ce, parent_ce);
/* Inherit properties */ /* Inherit properties */
if (parent_ce->default_properties_count) { if (parent_ce->default_properties_count) {
@ -774,7 +773,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
if (parent_ce->type != ce->type) { if (parent_ce->type != ce->type) {
/* User class extends internal class */ /* User class extends internal class */
zend_update_class_constants(parent_ce TSRMLS_CC); zend_update_class_constants(parent_ce );
if (parent_ce->default_static_members_count) { if (parent_ce->default_static_members_count) {
int i = ce->default_static_members_count + parent_ce->default_static_members_count; int i = ce->default_static_members_count + parent_ce->default_static_members_count;
@ -831,34 +830,34 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_FOREACH_STR_KEY_PTR(&parent_ce->properties_info, key, property_info) { ZEND_HASH_FOREACH_STR_KEY_PTR(&parent_ce->properties_info, key, property_info) {
if (do_inherit_property_access_check(property_info, key, ce TSRMLS_CC)) { if (do_inherit_property_access_check(property_info, key, ce)) {
if (ce->type & ZEND_INTERNAL_CLASS) { if (ce->type & ZEND_INTERNAL_CLASS) {
property_info = zend_duplicate_property_info_internal(property_info); property_info = zend_duplicate_property_info_internal(property_info);
} else { } else {
property_info = zend_duplicate_property_info(property_info TSRMLS_CC); property_info = zend_duplicate_property_info(property_info);
} }
zend_hash_add_new_ptr(&ce->properties_info, key, property_info); zend_hash_add_new_ptr(&ce->properties_info, key, property_info);
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_FOREACH_STR_KEY_VAL(&parent_ce->constants_table, key, zv) { ZEND_HASH_FOREACH_STR_KEY_VAL(&parent_ce->constants_table, key, zv) {
do_inherit_class_constant(key, zv, ce, parent_ce TSRMLS_CC); do_inherit_class_constant(key, zv, ce, parent_ce);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) { ZEND_HASH_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) {
if (do_inherit_method_check(&ce->function_table, func, key, ce)) { if (do_inherit_method_check(&ce->function_table, func, key, ce)) {
zend_function *new_func = do_inherit_method(func, ce TSRMLS_CC); zend_function *new_func = do_inherit_method(func, ce);
zend_hash_add_new_ptr(&ce->function_table, key, new_func); zend_hash_add_new_ptr(&ce->function_table, key, new_func);
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
do_inherit_parent_constructor(ce TSRMLS_CC); do_inherit_parent_constructor(ce);
if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS && ce->type == ZEND_INTERNAL_CLASS) { if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS && ce->type == ZEND_INTERNAL_CLASS) {
ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
} else if (!(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))) { } else if (!(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))) {
/* The verification will be done in runtime by ZEND_VERIFY_ABSTRACT_CLASS */ /* The verification will be done in runtime by ZEND_VERIFY_ABSTRACT_CLASS */
zend_verify_abstract_class(ce TSRMLS_CC); zend_verify_abstract_class(ce);
} }
ce->ce_flags |= parent_ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS; ce->ce_flags |= parent_ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS;
} }
@ -880,7 +879,7 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zva
} }
/* }}} */ /* }}} */
static void do_inherit_iface_constant(zend_string *name, zval *zv, zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */ static void do_inherit_iface_constant(zend_string *name, zval *zv, zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
{ {
if (do_inherit_constant_check(&ce->constants_table, zv, name, iface)) { if (do_inherit_constant_check(&ce->constants_table, zv, name, iface)) {
ZVAL_MAKE_REF(zv); ZVAL_MAKE_REF(zv);
@ -893,7 +892,7 @@ static void do_inherit_iface_constant(zend_string *name, zval *zv, zend_class_en
} }
/* }}} */ /* }}} */
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
{ {
uint32_t i, ignore = 0; uint32_t i, ignore = 0;
uint32_t current_iface_num = ce->num_interfaces; uint32_t current_iface_num = ce->num_interfaces;
@ -930,23 +929,23 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
ce->interfaces[ce->num_interfaces++] = iface; ce->interfaces[ce->num_interfaces++] = iface;
ZEND_HASH_FOREACH_STR_KEY_VAL(&iface->constants_table, key, zv) { ZEND_HASH_FOREACH_STR_KEY_VAL(&iface->constants_table, key, zv) {
do_inherit_iface_constant(key, zv, ce, iface TSRMLS_CC); do_inherit_iface_constant(key, zv, ce, iface);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
ZEND_HASH_FOREACH_STR_KEY_PTR(&iface->function_table, key, func) { ZEND_HASH_FOREACH_STR_KEY_PTR(&iface->function_table, key, func) {
if (do_inherit_method_check(&ce->function_table, func, key, ce)) { if (do_inherit_method_check(&ce->function_table, func, key, ce)) {
zend_function *new_func = do_inherit_method(func, ce TSRMLS_CC); zend_function *new_func = do_inherit_method(func, ce);
zend_hash_add_new_ptr(&ce->function_table, key, new_func); zend_hash_add_new_ptr(&ce->function_table, key, new_func);
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
do_implement_interface(ce, iface TSRMLS_CC); do_implement_interface(ce, iface);
zend_do_inherit_interfaces(ce, iface TSRMLS_CC); zend_do_inherit_interfaces(ce, iface);
} }
} }
/* }}} */ /* }}} */
ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC) /* {{{ */ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait) /* {{{ */
{ {
uint32_t i, ignore = 0; uint32_t i, ignore = 0;
uint32_t current_trait_num = ce->num_traits; uint32_t current_trait_num = ce->num_traits;
@ -975,19 +974,19 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr
} }
/* }}} */ /* }}} */
static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_function *other_fn TSRMLS_DC) /* {{{ */ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_function *other_fn) /* {{{ */
{ {
uint32_t fn_flags = fn->common.scope->ce_flags; uint32_t fn_flags = fn->common.scope->ce_flags;
uint32_t other_flags = other_fn->common.scope->ce_flags; uint32_t other_flags = other_fn->common.scope->ce_flags;
return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC) return zend_do_perform_implementation_check(fn, other_fn)
&& ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC)) && ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn))
&& ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) == && ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) ==
(other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */ (other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */
} }
/* }}} */ /* }}} */
static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe TSRMLS_DC) /* {{{ */ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */
{ {
if (!strncmp(mname->val, ZEND_CLONE_FUNC_NAME, mname->len)) { if (!strncmp(mname->val, ZEND_CLONE_FUNC_NAME, mname->len)) {
ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE; ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE;
@ -1017,7 +1016,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
} else if (ce->name->len == mname->len) { } else if (ce->name->len == mname->len) {
zend_string *lowercase_name = zend_string_alloc(ce->name->len, 0); zend_string *lowercase_name = zend_string_alloc(ce->name->len, 0);
zend_str_tolower_copy(lowercase_name->val, ce->name->val, ce->name->len); zend_str_tolower_copy(lowercase_name->val, ce->name->val, ce->name->len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC); lowercase_name = zend_new_interned_string(lowercase_name);
if (!memcmp(mname->val, lowercase_name->val, mname->len)) { if (!memcmp(mname->val, lowercase_name->val, mname->len)) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name->val); zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name->val);
@ -1030,7 +1029,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
} }
/* }}} */ /* }}} */
static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_string *key, zend_function *fn, HashTable **overriden TSRMLS_DC) /* {{{ */ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_string *key, zend_function *fn, HashTable **overriden) /* {{{ */
{ {
zend_function *existing_fn = NULL; zend_function *existing_fn = NULL;
zend_function *new_fn; zend_function *new_fn;
@ -1043,17 +1042,17 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
if ((existing_fn = zend_hash_find_ptr(*overriden, key)) != NULL) { if ((existing_fn = zend_hash_find_ptr(*overriden, key)) != NULL) {
if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) { if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the trait method is compatible with previosly declared abstract method */ /* Make sure the trait method is compatible with previosly declared abstract method */
if (!zend_traits_method_compatibility_check(fn, existing_fn TSRMLS_CC)) { if (!zend_traits_method_compatibility_check(fn, existing_fn)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
zend_get_function_declaration(fn TSRMLS_CC)->val, zend_get_function_declaration(fn)->val,
zend_get_function_declaration(existing_fn TSRMLS_CC)->val); zend_get_function_declaration(existing_fn)->val);
} }
} else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) { } else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the abstract declaration is compatible with previous declaration */ /* Make sure the abstract declaration is compatible with previous declaration */
if (!zend_traits_method_compatibility_check(existing_fn, fn TSRMLS_CC)) { if (!zend_traits_method_compatibility_check(existing_fn, fn)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
zend_get_function_declaration(fn TSRMLS_CC)->val, zend_get_function_declaration(fn)->val,
zend_get_function_declaration(existing_fn TSRMLS_CC)->val); zend_get_function_declaration(existing_fn)->val);
} }
return; return;
} }
@ -1066,17 +1065,17 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
return; return;
} else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) { } else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the trait method is compatible with previosly declared abstract method */ /* Make sure the trait method is compatible with previosly declared abstract method */
if (!zend_traits_method_compatibility_check(fn, existing_fn TSRMLS_CC)) { if (!zend_traits_method_compatibility_check(fn, existing_fn)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
zend_get_function_declaration(fn TSRMLS_CC)->val, zend_get_function_declaration(fn)->val,
zend_get_function_declaration(existing_fn TSRMLS_CC)->val); zend_get_function_declaration(existing_fn)->val);
} }
} else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) { } else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the abstract declaration is compatible with previous declaration */ /* Make sure the abstract declaration is compatible with previous declaration */
if (!zend_traits_method_compatibility_check(existing_fn, fn TSRMLS_CC)) { if (!zend_traits_method_compatibility_check(existing_fn, fn)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
zend_get_function_declaration(fn TSRMLS_CC)->val, zend_get_function_declaration(fn)->val,
zend_get_function_declaration(existing_fn TSRMLS_CC)->val); zend_get_function_declaration(existing_fn)->val);
} }
return; return;
} else if ((existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { } else if ((existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
@ -1093,7 +1092,7 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
} else { } else {
/* inherited members are overridden by members inserted by traits */ /* inherited members are overridden by members inserted by traits */
/* check whether the trait method fulfills the inheritance requirements */ /* check whether the trait method fulfills the inheritance requirements */
do_inheritance_check_on_method(fn, existing_fn TSRMLS_CC); do_inheritance_check_on_method(fn, existing_fn);
} }
} }
@ -1101,7 +1100,7 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_fn, fn, sizeof(zend_op_array)); memcpy(new_fn, fn, sizeof(zend_op_array));
fn = zend_hash_update_ptr(&ce->function_table, key, new_fn); fn = zend_hash_update_ptr(&ce->function_table, key, new_fn);
zend_add_magic_methods(ce, key, fn TSRMLS_CC); zend_add_magic_methods(ce, key, fn);
} }
/* }}} */ /* }}} */
@ -1121,7 +1120,7 @@ static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /*
} }
/* }}} */ /* }}} */
static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, zend_class_entry *ce, HashTable **overriden, HashTable *exclude_table TSRMLS_DC) /* {{{ */ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, zend_class_entry *ce, HashTable **overriden, HashTable *exclude_table) /* {{{ */
{ {
zend_trait_alias *alias, **alias_ptr; zend_trait_alias *alias, **alias_ptr;
zend_string *lcname; zend_string *lcname;
@ -1146,7 +1145,7 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
lcname = zend_string_alloc(alias->alias->len, 0); lcname = zend_string_alloc(alias->alias->len, 0);
zend_str_tolower_copy(lcname->val, alias->alias->val, alias->alias->len); zend_str_tolower_copy(lcname->val, alias->alias->val, alias->alias->len);
zend_add_trait_method(ce, alias->alias->val, lcname, &fn_copy, overriden TSRMLS_CC); zend_add_trait_method(ce, alias->alias->val, lcname, &fn_copy, overriden);
zend_string_release(lcname); zend_string_release(lcname);
/* Record the trait from which this alias was resolved. */ /* Record the trait from which this alias was resolved. */
@ -1186,14 +1185,14 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
} }
} }
zend_add_trait_method(ce, fn->common.function_name->val, fnname, &fn_copy, overriden TSRMLS_CC); zend_add_trait_method(ce, fn->common.function_name->val, fnname, &fn_copy, overriden);
} }
return ZEND_HASH_APPLY_KEEP; return ZEND_HASH_APPLY_KEEP;
} }
/* }}} */ /* }}} */
static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC) /* {{{ */ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait) /* {{{ */
{ {
uint32_t i; uint32_t i;
@ -1210,7 +1209,7 @@ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait
} }
/* }}} */ /* }}} */
static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* {{{ */ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
{ {
size_t i, j = 0; size_t i, j = 0;
zend_trait_precedence *cur_precedence; zend_trait_precedence *cur_precedence;
@ -1226,10 +1225,10 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
if (cur_precedence->exclude_from_classes) { if (cur_precedence->exclude_from_classes) {
cur_method_ref = cur_precedence->trait_method; cur_method_ref = cur_precedence->trait_method;
if (!(cur_precedence->trait_method->ce = zend_fetch_class(cur_method_ref->class_name, if (!(cur_precedence->trait_method->ce = zend_fetch_class(cur_method_ref->class_name,
ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) { ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val); zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val);
} }
zend_check_trait_usage(ce, cur_precedence->trait_method->ce TSRMLS_CC); zend_check_trait_usage(ce, cur_precedence->trait_method->ce);
/** Ensure that the preferred method is actually available. */ /** Ensure that the preferred method is actually available. */
lcname = zend_string_alloc(cur_method_ref->method_name->len, 0); lcname = zend_string_alloc(cur_method_ref->method_name->len, 0);
@ -1256,10 +1255,10 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
while (cur_precedence->exclude_from_classes[j].class_name) { while (cur_precedence->exclude_from_classes[j].class_name) {
zend_string* class_name = cur_precedence->exclude_from_classes[j].class_name; zend_string* class_name = cur_precedence->exclude_from_classes[j].class_name;
if (!(cur_precedence->exclude_from_classes[j].ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_TRAIT |ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) { if (!(cur_precedence->exclude_from_classes[j].ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_TRAIT |ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", class_name->val); zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", class_name->val);
} }
zend_check_trait_usage(ce, cur_precedence->exclude_from_classes[j].ce TSRMLS_CC); zend_check_trait_usage(ce, cur_precedence->exclude_from_classes[j].ce);
/* make sure that the trait method is not from a class mentioned in /* make sure that the trait method is not from a class mentioned in
exclude_from_classes, for consistency */ exclude_from_classes, for consistency */
@ -1286,10 +1285,10 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
/** For all aliases with an explicit class name, resolve the class now. */ /** For all aliases with an explicit class name, resolve the class now. */
if (ce->trait_aliases[i]->trait_method->class_name) { if (ce->trait_aliases[i]->trait_method->class_name) {
cur_method_ref = ce->trait_aliases[i]->trait_method; cur_method_ref = ce->trait_aliases[i]->trait_method;
if (!(cur_method_ref->ce = zend_fetch_class(cur_method_ref->class_name, ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) { if (!(cur_method_ref->ce = zend_fetch_class(cur_method_ref->class_name, ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val); zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val);
} }
zend_check_trait_usage(ce, cur_method_ref->ce TSRMLS_CC); zend_check_trait_usage(ce, cur_method_ref->ce);
/** And, ensure that the referenced method is resolvable, too. */ /** And, ensure that the referenced method is resolvable, too. */
lcname = zend_string_alloc(cur_method_ref->method_name->len, 0); lcname = zend_string_alloc(cur_method_ref->method_name->len, 0);
@ -1341,7 +1340,7 @@ static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_tra
} }
/* }}} */ /* }}} */
static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ */ static void zend_do_traits_method_binding(zend_class_entry *ce) /* {{{ */
{ {
uint32_t i; uint32_t i;
HashTable *overriden = NULL; HashTable *overriden = NULL;
@ -1359,13 +1358,13 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
/* copies functions, applies defined aliasing, and excludes unused trait methods */ /* copies functions, applies defined aliasing, and excludes unused trait methods */
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->traits[i]->function_table, key, fn) { ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->traits[i]->function_table, key, fn) {
zend_traits_copy_functions(key, fn, ce, &overriden, &exclude_table TSRMLS_CC); zend_traits_copy_functions(key, fn, ce, &overriden, &exclude_table);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&exclude_table); zend_hash_destroy(&exclude_table);
} else { } else {
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->traits[i]->function_table, key, fn) { ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->traits[i]->function_table, key, fn) {
zend_traits_copy_functions(key, fn, ce, &overriden, NULL TSRMLS_CC); zend_traits_copy_functions(key, fn, ce, &overriden, NULL);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
} }
} }
@ -1397,7 +1396,7 @@ static zend_class_entry* find_first_definition(zend_class_entry *ce, size_t curr
} }
/* }}} */ /* }}} */
static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ */ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
{ {
size_t i; size_t i;
zend_property_info *property_info; zend_property_info *property_info;
@ -1445,12 +1444,12 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
if (flags & ZEND_ACC_STATIC) { if (flags & ZEND_ACC_STATIC) {
not_compatible = (FAILURE == compare_function(&compare_result, not_compatible = (FAILURE == compare_function(&compare_result,
&ce->default_static_members_table[coliding_prop->offset], &ce->default_static_members_table[coliding_prop->offset],
&ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC)) &ce->traits[i]->default_static_members_table[property_info->offset]))
|| (Z_LVAL(compare_result) != 0); || (Z_LVAL(compare_result) != 0);
} else { } else {
not_compatible = (FAILURE == compare_function(&compare_result, not_compatible = (FAILURE == compare_function(&compare_result,
&ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)], &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)],
&ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)] TSRMLS_CC)) &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]))
|| (Z_LVAL(compare_result) != 0); || (Z_LVAL(compare_result) != 0);
} }
} else { } else {
@ -1489,14 +1488,14 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL; doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL;
zend_declare_property_ex(ce, prop_name, zend_declare_property_ex(ce, prop_name,
prop_value, flags, prop_value, flags,
doc_comment TSRMLS_CC); doc_comment);
zend_string_release(prop_name); zend_string_release(prop_name);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
} }
} }
/* }}} */ /* }}} */
static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce TSRMLS_DC) /* {{{ */ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce) /* {{{ */
{ {
int i = 0; int i = 0;
zend_trait_alias* cur_alias; zend_trait_alias* cur_alias;
@ -1549,7 +1548,7 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce
} }
/* }}} */ /* }}} */
ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC) /* {{{ */ ZEND_API void zend_do_bind_traits(zend_class_entry *ce) /* {{{ */
{ {
if (ce->num_traits <= 0) { if (ce->num_traits <= 0) {
@ -1557,19 +1556,19 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC) /* {{{ */
} }
/* complete initialization of trait strutures in ce */ /* complete initialization of trait strutures in ce */
zend_traits_init_trait_structures(ce TSRMLS_CC); zend_traits_init_trait_structures(ce);
/* first care about all methods to be flattened into the class */ /* first care about all methods to be flattened into the class */
zend_do_traits_method_binding(ce TSRMLS_CC); zend_do_traits_method_binding(ce);
/* Aliases which have not been applied indicate typos/bugs. */ /* Aliases which have not been applied indicate typos/bugs. */
zend_do_check_for_inconsistent_traits_aliasing(ce TSRMLS_CC); zend_do_check_for_inconsistent_traits_aliasing(ce);
/* then flatten the properties into it, to, mostly to notfiy developer about problems */ /* then flatten the properties into it, to, mostly to notfiy developer about problems */
zend_do_traits_property_binding(ce TSRMLS_CC); zend_do_traits_property_binding(ce);
/* verify that all abstract methods from traits have been implemented */ /* verify that all abstract methods from traits have been implemented */
zend_verify_abstract_class(ce TSRMLS_CC); zend_verify_abstract_class(ce);
/* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */ /* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */
if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) { if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) {

View file

@ -24,14 +24,14 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC); ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface);
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC); ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface);
ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC); ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait);
ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC); ZEND_API void zend_do_bind_traits(zend_class_entry *ce);
ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC); ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
void zend_do_early_binding(TSRMLS_D); void zend_do_early_binding(void);
END_EXTERN_C() END_EXTERN_C()

View file

@ -34,7 +34,7 @@ static HashTable *registered_zend_ini_directives;
/* /*
* hash_apply functions * hash_apply functions
*/ */
static int zend_remove_ini_entries(zval *el, void *arg TSRMLS_DC) /* {{{ */ static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
{ {
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el); zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
int module_number = *(int *)arg; int module_number = *(int *)arg;
@ -46,7 +46,7 @@ static int zend_remove_ini_entries(zval *el, void *arg TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS_DC) /* {{{ */ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */
{ {
int result = FAILURE; int result = FAILURE;
@ -56,7 +56,7 @@ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS
/* even if on_modify bails out, we have to continue on with restoring, /* even if on_modify bails out, we have to continue on with restoring,
since there can be allocated variables that would be freed on MM shutdown since there can be allocated variables that would be freed on MM shutdown
and would lead to memory corruption later ini entry is modified again */ and would lead to memory corruption later ini entry is modified again */
result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC); result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
} zend_end_try(); } zend_end_try();
} }
if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) { if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
@ -76,10 +76,10 @@ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS
} }
/* }}} */ /* }}} */
static int zend_restore_ini_entry_wrapper(zval *el TSRMLS_DC) /* {{{ */ static int zend_restore_ini_entry_wrapper(zval *el) /* {{{ */
{ {
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el); zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC); zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE);
return 1; return 1;
} }
/* }}} */ /* }}} */
@ -102,7 +102,7 @@ static void free_ini_entry(zval *zv) /* {{{ */
/* /*
* Startup / shutdown * Startup / shutdown
*/ */
ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */ ZEND_API int zend_ini_startup(void) /* {{{ */
{ {
registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable)); registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
@ -114,7 +114,7 @@ ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int zend_ini_shutdown(TSRMLS_D) /* {{{ */ ZEND_API int zend_ini_shutdown(void) /* {{{ */
{ {
zend_hash_destroy(EG(ini_directives)); zend_hash_destroy(EG(ini_directives));
free(EG(ini_directives)); free(EG(ini_directives));
@ -122,7 +122,7 @@ ZEND_API int zend_ini_shutdown(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int zend_ini_global_shutdown(TSRMLS_D) /* {{{ */ ZEND_API int zend_ini_global_shutdown(void) /* {{{ */
{ {
zend_hash_destroy(registered_zend_ini_directives); zend_hash_destroy(registered_zend_ini_directives);
free(registered_zend_ini_directives); free(registered_zend_ini_directives);
@ -130,10 +130,10 @@ ZEND_API int zend_ini_global_shutdown(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int zend_ini_deactivate(TSRMLS_D) /* {{{ */ ZEND_API int zend_ini_deactivate(void) /* {{{ */
{ {
if (EG(modified_ini_directives)) { if (EG(modified_ini_directives)) {
zend_hash_apply(EG(modified_ini_directives), zend_restore_ini_entry_wrapper TSRMLS_CC); zend_hash_apply(EG(modified_ini_directives), zend_restore_ini_entry_wrapper);
zend_hash_destroy(EG(modified_ini_directives)); zend_hash_destroy(EG(modified_ini_directives));
FREE_HASHTABLE(EG(modified_ini_directives)); FREE_HASHTABLE(EG(modified_ini_directives));
EG(modified_ini_directives) = NULL; EG(modified_ini_directives) = NULL;
@ -162,7 +162,7 @@ static void copy_ini_entry(zval *zv) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */ ZEND_API int zend_copy_ini_directives(void) /* {{{ */
{ {
EG(modified_ini_directives) = NULL; EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL; EG(error_reporting_ini_entry) = NULL;
@ -174,7 +174,7 @@ ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */
/* }}} */ /* }}} */
#endif #endif
static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */ static int ini_key_compare(const void *a, const void *b) /* {{{ */
{ {
const Bucket *f; const Bucket *f;
const Bucket *s; const Bucket *s;
@ -194,16 +194,16 @@ static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_ini_sort_entries(TSRMLS_D) /* {{{ */ ZEND_API void zend_ini_sort_entries(void) /* {{{ */
{ {
zend_hash_sort(EG(ini_directives), zend_qsort, ini_key_compare, 0 TSRMLS_CC); zend_hash_sort(EG(ini_directives), zend_qsort, ini_key_compare, 0);
} }
/* }}} */ /* }}} */
/* /*
* Registration / unregistration * Registration / unregistration
*/ */
ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number TSRMLS_DC) /* {{{ */ ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */
{ {
zend_ini_entry *p; zend_ini_entry *p;
zval *default_value; zval *default_value;
@ -243,11 +243,11 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int
if (p->name) { if (p->name) {
zend_string_release(p->name); zend_string_release(p->name);
} }
zend_unregister_ini_entries(module_number TSRMLS_CC); zend_unregister_ini_entries(module_number);
return FAILURE; return FAILURE;
} }
if (((default_value = zend_get_configuration_directive(p->name)) != NULL) && if (((default_value = zend_get_configuration_directive(p->name)) != NULL) &&
(!p->on_modify || p->on_modify(p, Z_STR_P(default_value), p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC) == SUCCESS)) { (!p->on_modify || p->on_modify(p, Z_STR_P(default_value), p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP) == SUCCESS)) {
p->value = zend_string_copy(Z_STR_P(default_value)); p->value = zend_string_copy(Z_STR_P(default_value));
} else { } else {
@ -255,7 +255,7 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int
zend_string_init(ini_entry->value, ini_entry->value_length, 1) : NULL; zend_string_init(ini_entry->value, ini_entry->value_length, 1) : NULL;
if (p->on_modify) { if (p->on_modify) {
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC); p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
} }
} }
ini_entry++; ini_entry++;
@ -264,37 +264,36 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int
} }
/* }}} */ /* }}} */
ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */ ZEND_API void zend_unregister_ini_entries(int module_number) /* {{{ */
{ {
zend_hash_apply_with_argument(registered_zend_ini_directives, zend_remove_ini_entries, (void *) &module_number TSRMLS_CC); zend_hash_apply_with_argument(registered_zend_ini_directives, zend_remove_ini_entries, (void *) &module_number);
} }
/* }}} */ /* }}} */
#ifdef ZTS #ifdef ZTS
static int zend_ini_refresh_cache(zval *el, void *arg TSRMLS_DC) /* {{{ */ static int zend_ini_refresh_cache(zval *el, void *arg) /* {{{ */
{ {
zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el); zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el);
int stage = (int)(zend_intptr_t)arg; int stage = (int)(zend_intptr_t)arg;
if (p->on_modify) { if (p->on_modify) {
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC); p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
} }
return 0; return 0;
} }
/* }}} */ /* }}} */
ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */
{ {
zend_hash_apply_with_argument(EG(ini_directives), zend_ini_refresh_cache, (void *)(zend_intptr_t) stage TSRMLS_CC); zend_hash_apply_with_argument(EG(ini_directives), zend_ini_refresh_cache, (void *)(zend_intptr_t) stage);
} }
/* }}} */ /* }}} */
#endif #endif
ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */
{ {
TSRMLS_FETCH();
return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0 TSRMLS_CC); return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
} }
/* }}} */ /* }}} */
@ -302,28 +301,27 @@ ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, si
{ {
int ret; int ret;
zend_string *new_value; zend_string *new_value;
TSRMLS_FETCH();
new_value = zend_string_init(value, value_length, stage != ZEND_INI_STAGE_RUNTIME); new_value = zend_string_init(value, value_length, stage != ZEND_INI_STAGE_RUNTIME);
ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0 TSRMLS_CC); ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
zend_string_release(new_value); zend_string_release(new_value);
return ret; return ret;
} }
/* }}} */ /* }}} */
ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change TSRMLS_DC) /* {{{ */ ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
{ {
int ret; int ret;
zend_string *new_value; zend_string *new_value;
new_value = zend_string_init(value, value_length, stage != ZEND_INI_STAGE_RUNTIME); new_value = zend_string_init(value, value_length, stage != ZEND_INI_STAGE_RUNTIME);
ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, force_change TSRMLS_CC); ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, force_change);
zend_string_release(new_value); zend_string_release(new_value);
return ret; return ret;
} }
/* }}} */ /* }}} */
ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change TSRMLS_DC) /* {{{ */ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
zend_string *duplicate; zend_string *duplicate;
@ -361,7 +359,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value,
duplicate = zend_string_copy(new_value); duplicate = zend_string_copy(new_value);
if (!ini_entry->on_modify if (!ini_entry->on_modify
|| ini_entry->on_modify(ini_entry, duplicate, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) { || ini_entry->on_modify(ini_entry, duplicate, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage) == SUCCESS) {
if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */ if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
zend_string_release(ini_entry->value); zend_string_release(ini_entry->value);
} }
@ -378,7 +376,6 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value,
ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
TSRMLS_FETCH();
if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL || if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL ||
(stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) { (stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
@ -386,7 +383,7 @@ ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */
} }
if (EG(modified_ini_directives)) { if (EG(modified_ini_directives)) {
if (zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC) == 0) { if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
zend_hash_del(EG(modified_ini_directives), name); zend_hash_del(EG(modified_ini_directives), name);
} else { } else {
return FAILURE; return FAILURE;
@ -418,7 +415,6 @@ ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*di
ZEND_API zend_long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */ ZEND_API zend_long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
TSRMLS_FETCH();
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length); ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) { if (ini_entry) {
@ -436,7 +432,6 @@ ZEND_API zend_long zend_ini_long(char *name, uint name_length, int orig) /* {{{
ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ */ ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
TSRMLS_FETCH();
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length); ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) { if (ini_entry) {
@ -454,7 +449,6 @@ ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ *
ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists) /* {{{ */ ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
TSRMLS_FETCH();
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length); ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) { if (ini_entry) {

View file

@ -27,7 +27,7 @@
#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM) #define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage TSRMLS_DC) #define ZEND_INI_MH(name) int name(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type) #define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
typedef struct _zend_ini_entry_def { typedef struct _zend_ini_entry_def {
@ -61,22 +61,22 @@ struct _zend_ini_entry {
}; };
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_ini_startup(TSRMLS_D); ZEND_API int zend_ini_startup(void);
ZEND_API int zend_ini_shutdown(TSRMLS_D); ZEND_API int zend_ini_shutdown(void);
ZEND_API int zend_ini_global_shutdown(TSRMLS_D); ZEND_API int zend_ini_global_shutdown(void);
ZEND_API int zend_ini_deactivate(TSRMLS_D); ZEND_API int zend_ini_deactivate(void);
ZEND_API int zend_copy_ini_directives(TSRMLS_D); ZEND_API int zend_copy_ini_directives(void);
ZEND_API void zend_ini_sort_entries(TSRMLS_D); ZEND_API void zend_ini_sort_entries(void);
ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number TSRMLS_DC); ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number);
ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC); ZEND_API void zend_unregister_ini_entries(int module_number);
ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC); ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage);
ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change TSRMLS_DC); ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change);
ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage);
ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change TSRMLS_DC); ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change);
ZEND_API int zend_restore_ini_entry(zend_string *name, int stage); ZEND_API int zend_restore_ini_entry(zend_string *name, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module); ZEND_API void display_ini_entries(zend_module_entry *module);
@ -145,8 +145,8 @@ END_EXTERN_C()
#define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name)-1, 1) #define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name)-1, 1)
#define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name)) #define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
#define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC) #define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number)
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC) #define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number)
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module) #define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
#define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name)-1, displayer) #define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name)-1, displayer)
@ -173,10 +173,10 @@ END_EXTERN_C()
#define ZEND_INI_STAGE_HTACCESS (1<<5) #define ZEND_INI_STAGE_HTACCESS (1<<5)
/* INI parsing engine */ /* INI parsing engine */
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC); typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC); ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC); ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
END_EXTERN_C() END_EXTERN_C()
/* INI entries */ /* INI entries */

View file

@ -113,17 +113,17 @@ static void zend_ini_add_string(zval *result, zval *op1, zval *op2)
/* {{{ zend_ini_get_constant() /* {{{ zend_ini_get_constant()
*/ */
static void zend_ini_get_constant(zval *result, zval *name TSRMLS_DC) static void zend_ini_get_constant(zval *result, zval *name)
{ {
zval *c, tmp; zval *c, tmp;
/* If name contains ':' it is not a constant. Bug #26893. */ /* If name contains ':' it is not a constant. Bug #26893. */
if (!memchr(Z_STRVAL_P(name), ':', Z_STRLEN_P(name)) if (!memchr(Z_STRVAL_P(name), ':', Z_STRLEN_P(name))
&& (c = zend_get_constant(Z_STR_P(name) TSRMLS_CC)) != 0) { && (c = zend_get_constant(Z_STR_P(name))) != 0) {
if (Z_TYPE_P(c) != IS_STRING) { if (Z_TYPE_P(c) != IS_STRING) {
ZVAL_COPY_VALUE(&tmp, c); ZVAL_COPY_VALUE(&tmp, c);
if (Z_OPT_CONSTANT(tmp)) { if (Z_OPT_CONSTANT(tmp)) {
zval_update_constant_ex(&tmp, 1, NULL TSRMLS_CC); zval_update_constant_ex(&tmp, 1, NULL);
} }
zval_opt_copy_ctor(&tmp); zval_opt_copy_ctor(&tmp);
convert_to_string(&tmp); convert_to_string(&tmp);
@ -142,7 +142,7 @@ static void zend_ini_get_constant(zval *result, zval *name TSRMLS_DC)
/* {{{ zend_ini_get_var() /* {{{ zend_ini_get_var()
*/ */
static void zend_ini_get_var(zval *result, zval *name TSRMLS_DC) static void zend_ini_get_var(zval *result, zval *name)
{ {
zval *curval; zval *curval;
char *envvar; char *envvar;
@ -151,7 +151,7 @@ static void zend_ini_get_var(zval *result, zval *name TSRMLS_DC)
if ((curval = zend_get_configuration_directive(Z_STR_P(name))) != NULL) { if ((curval = zend_get_configuration_directive(Z_STR_P(name))) != NULL) {
ZVAL_PSTRINGL(result, Z_STRVAL_P(curval), Z_STRLEN_P(curval)); ZVAL_PSTRINGL(result, Z_STRVAL_P(curval), Z_STRLEN_P(curval));
/* ..or if not found, try ENV */ /* ..or if not found, try ENV */
} else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRLEN_P(name) TSRMLS_CC)) != NULL || } else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRLEN_P(name))) != NULL ||
(envvar = getenv(Z_STRVAL_P(name))) != NULL) { (envvar = getenv(Z_STRVAL_P(name))) != NULL) {
ZVAL_PSTRING(result, envvar); ZVAL_PSTRING(result, envvar);
} else { } else {
@ -167,14 +167,13 @@ static void ini_error(const char *msg)
char *error_buf; char *error_buf;
int error_buf_len; int error_buf_len;
char *currently_parsed_filename; char *currently_parsed_filename;
TSRMLS_FETCH();
currently_parsed_filename = zend_ini_scanner_get_filename(TSRMLS_C); currently_parsed_filename = zend_ini_scanner_get_filename();
if (currently_parsed_filename) { if (currently_parsed_filename) {
error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */ error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */
error_buf = (char *) emalloc(error_buf_len); error_buf = (char *) emalloc(error_buf_len);
sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno(TSRMLS_C)); sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno());
} else { } else {
error_buf = estrdup("Invalid configuration directive\n"); error_buf = estrdup("Invalid configuration directive\n");
} }
@ -193,7 +192,7 @@ static void ini_error(const char *msg)
/* {{{ zend_parse_ini_file() /* {{{ zend_parse_ini_file()
*/ */
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC) ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
{ {
int retval; int retval;
zend_ini_parser_param ini_parser_param; zend_ini_parser_param ini_parser_param;
@ -202,15 +201,15 @@ ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_erro
ini_parser_param.arg = arg; ini_parser_param.arg = arg;
CG(ini_parser_param) = &ini_parser_param; CG(ini_parser_param) = &ini_parser_param;
if (zend_ini_open_file_for_scanning(fh, scanner_mode TSRMLS_CC) == FAILURE) { if (zend_ini_open_file_for_scanning(fh, scanner_mode) == FAILURE) {
return FAILURE; return FAILURE;
} }
CG(ini_parser_unbuffered_errors) = unbuffered_errors; CG(ini_parser_unbuffered_errors) = unbuffered_errors;
retval = ini_parse(TSRMLS_C); retval = ini_parse();
zend_file_handle_dtor(fh TSRMLS_CC); zend_file_handle_dtor(fh);
shutdown_ini_scanner(TSRMLS_C); shutdown_ini_scanner();
if (retval == 0) { if (retval == 0) {
return SUCCESS; return SUCCESS;
@ -222,7 +221,7 @@ ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_erro
/* {{{ zend_parse_ini_string() /* {{{ zend_parse_ini_string()
*/ */
ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC) ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
{ {
int retval; int retval;
zend_ini_parser_param ini_parser_param; zend_ini_parser_param ini_parser_param;
@ -231,14 +230,14 @@ ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int s
ini_parser_param.arg = arg; ini_parser_param.arg = arg;
CG(ini_parser_param) = &ini_parser_param; CG(ini_parser_param) = &ini_parser_param;
if (zend_ini_prepare_string_for_scanning(str, scanner_mode TSRMLS_CC) == FAILURE) { if (zend_ini_prepare_string_for_scanning(str, scanner_mode) == FAILURE) {
return FAILURE; return FAILURE;
} }
CG(ini_parser_unbuffered_errors) = unbuffered_errors; CG(ini_parser_unbuffered_errors) = unbuffered_errors;
retval = ini_parse(TSRMLS_C); retval = ini_parse();
shutdown_ini_scanner(TSRMLS_C); shutdown_ini_scanner();
if (retval == 0) { if (retval == 0) {
return SUCCESS; return SUCCESS;
@ -284,14 +283,14 @@ statement:
#if DEBUG_CFG_PARSER #if DEBUG_CFG_PARSER
printf("SECTION: [%s]\n", Z_STRVAL($2)); printf("SECTION: [%s]\n", Z_STRVAL($2));
#endif #endif
ZEND_INI_PARSER_CB(&$2, NULL, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG TSRMLS_CC); ZEND_INI_PARSER_CB(&$2, NULL, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG);
zend_string_release(Z_STR($2)); zend_string_release(Z_STR($2));
} }
| TC_LABEL '=' string_or_value { | TC_LABEL '=' string_or_value {
#if DEBUG_CFG_PARSER #if DEBUG_CFG_PARSER
printf("NORMAL: '%s' = '%s'\n", Z_STRVAL($1), Z_STRVAL($3)); printf("NORMAL: '%s' = '%s'\n", Z_STRVAL($1), Z_STRVAL($3));
#endif #endif
ZEND_INI_PARSER_CB(&$1, &$3, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); ZEND_INI_PARSER_CB(&$1, &$3, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG);
zend_string_release(Z_STR($1)); zend_string_release(Z_STR($1));
zval_ptr_dtor(&$3); zval_ptr_dtor(&$3);
} }
@ -299,12 +298,12 @@ statement:
#if DEBUG_CFG_PARSER #if DEBUG_CFG_PARSER
printf("OFFSET: '%s'[%s] = '%s'\n", Z_STRVAL($1), Z_STRVAL($2), Z_STRVAL($5)); printf("OFFSET: '%s'[%s] = '%s'\n", Z_STRVAL($1), Z_STRVAL($2), Z_STRVAL($5));
#endif #endif
ZEND_INI_PARSER_CB(&$1, &$5, &$2, ZEND_INI_PARSER_POP_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); ZEND_INI_PARSER_CB(&$1, &$5, &$2, ZEND_INI_PARSER_POP_ENTRY, ZEND_INI_PARSER_ARG);
zend_string_release(Z_STR($1)); zend_string_release(Z_STR($1));
zend_string_release(Z_STR($2)); zend_string_release(Z_STR($2));
zval_ptr_dtor(&$5); zval_ptr_dtor(&$5);
} }
| TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); zend_string_release(Z_STR($1)); } | TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG); zend_string_release(Z_STR($1)); }
| END_OF_LINE | END_OF_LINE
; ;
@ -361,7 +360,7 @@ expr:
; ;
cfg_var_ref: cfg_var_ref:
TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2 TSRMLS_CC); zend_string_free(Z_STR($2)); } TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2); zend_string_free(Z_STR($2)); }
; ;
constant_literal: constant_literal:
@ -373,7 +372,7 @@ constant_literal:
; ;
constant_string: constant_string:
TC_CONSTANT { zend_ini_get_constant(&$$, &$1 TSRMLS_CC); } TC_CONSTANT { zend_ini_get_constant(&$$, &$1); }
| TC_RAW { $$ = $1; /*printf("TC_RAW: '%s'\n", Z_STRVAL($1));*/ } | TC_RAW { $$ = $1; /*printf("TC_RAW: '%s'\n", Z_STRVAL($1));*/ }
| TC_NUMBER { $$ = $1; /*printf("TC_NUMBER: '%s'\n", Z_STRVAL($1));*/ } | TC_NUMBER { $$ = $1; /*printf("TC_NUMBER: '%s'\n", Z_STRVAL($1));*/ }
| TC_STRING { $$ = $1; /*printf("TC_STRING: '%s'\n", Z_STRVAL($1));*/ } | TC_STRING { $$ = $1; /*printf("TC_STRING: '%s'\n", Z_STRVAL($1));*/ }

View file

@ -189,7 +189,7 @@ static void zend_ini_copy_typed_value(zval *retval, const int type, const char *
} }
} }
static void _yy_push_state(int new_state TSRMLS_DC) static void _yy_push_state(int new_state)
{ {
zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION()); zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
YYSETCONDITION(new_state); YYSETCONDITION(new_state);
@ -197,14 +197,14 @@ static void _yy_push_state(int new_state TSRMLS_DC)
#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
static void yy_pop_state(TSRMLS_D) static void yy_pop_state(void)
{ {
int *stack_state = zend_stack_top(&SCNG(state_stack)); int *stack_state = zend_stack_top(&SCNG(state_stack));
YYSETCONDITION(*stack_state); YYSETCONDITION(*stack_state);
zend_stack_del_top(&SCNG(state_stack)); zend_stack_del_top(&SCNG(state_stack));
} }
static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) static void yy_scan_buffer(char *str, unsigned int len)
{ {
YYCURSOR = (YYCTYPE*)str; YYCURSOR = (YYCTYPE*)str;
SCNG(yy_start) = YYCURSOR; SCNG(yy_start) = YYCURSOR;
@ -215,7 +215,7 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
/* {{{ init_ini_scanner() /* {{{ init_ini_scanner()
*/ */
static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC) static int init_ini_scanner(int scanner_mode, zend_file_handle *fh)
{ {
/* Sanity check */ /* Sanity check */
if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) {
@ -242,7 +242,7 @@ static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC)
/* {{{ shutdown_ini_scanner() /* {{{ shutdown_ini_scanner()
*/ */
void shutdown_ini_scanner(TSRMLS_D) void shutdown_ini_scanner(void)
{ {
zend_stack_destroy(&SCNG(state_stack)); zend_stack_destroy(&SCNG(state_stack));
if (ini_filename) { if (ini_filename) {
@ -253,7 +253,7 @@ void shutdown_ini_scanner(TSRMLS_D)
/* {{{ zend_ini_scanner_get_lineno() /* {{{ zend_ini_scanner_get_lineno()
*/ */
int zend_ini_scanner_get_lineno(TSRMLS_D) int zend_ini_scanner_get_lineno(void)
{ {
return SCNG(lineno); return SCNG(lineno);
} }
@ -261,7 +261,7 @@ int zend_ini_scanner_get_lineno(TSRMLS_D)
/* {{{ zend_ini_scanner_get_filename() /* {{{ zend_ini_scanner_get_filename()
*/ */
char *zend_ini_scanner_get_filename(TSRMLS_D) char *zend_ini_scanner_get_filename(void)
{ {
return ini_filename ? ini_filename : "Unknown"; return ini_filename ? ini_filename : "Unknown";
} }
@ -269,21 +269,21 @@ char *zend_ini_scanner_get_filename(TSRMLS_D)
/* {{{ zend_ini_open_file_for_scanning() /* {{{ zend_ini_open_file_for_scanning()
*/ */
int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC) int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode)
{ {
char *buf; char *buf;
size_t size; size_t size;
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) { if (zend_stream_fixup(fh, &buf, &size) == FAILURE) {
return FAILURE; return FAILURE;
} }
if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) { if (init_ini_scanner(scanner_mode, fh) == FAILURE) {
zend_file_handle_dtor(fh TSRMLS_CC); zend_file_handle_dtor(fh);
return FAILURE; return FAILURE;
} }
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
return SUCCESS; return SUCCESS;
} }
@ -291,15 +291,15 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML
/* {{{ zend_ini_prepare_string_for_scanning() /* {{{ zend_ini_prepare_string_for_scanning()
*/ */
int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode)
{ {
int len = (int)strlen(str); int len = (int)strlen(str);
if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) { if (init_ini_scanner(scanner_mode, NULL) == FAILURE) {
return FAILURE; return FAILURE;
} }
yy_scan_buffer(str, len TSRMLS_CC); yy_scan_buffer(str, len);
return SUCCESS; return SUCCESS;
} }
@ -307,7 +307,7 @@ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC)
/* {{{ zend_ini_escape_string() /* {{{ zend_ini_escape_string()
*/ */
static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type TSRMLS_DC) static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type)
{ {
register char *s, *t; register char *s, *t;
char *end; char *end;
@ -354,7 +354,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty
} }
/* }}} */ /* }}} */
int ini_lex(zval *ini_lval TSRMLS_DC) int ini_lex(zval *ini_lval)
{ {
restart: restart:
SCNG(yy_text) = YYCURSOR; SCNG(yy_text) = YYCURSOR;
@ -614,9 +614,9 @@ yy17:
#line 487 "Zend/zend_ini_scanner.l" #line 487 "Zend/zend_ini_scanner.l"
{ /* Start option value */ { /* Start option value */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_RAW TSRMLS_CC); yy_push_state(ST_RAW);
} else { } else {
yy_push_state(ST_VALUE TSRMLS_CC); yy_push_state(ST_VALUE);
} }
return '='; return '=';
} }
@ -680,9 +680,9 @@ yy23:
{ /* Section start */ { /* Section start */
/* Enter section data lookup state */ /* Enter section data lookup state */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_SECTION_RAW TSRMLS_CC); yy_push_state(ST_SECTION_RAW);
} else { } else {
yy_push_state(ST_SECTION_VALUE TSRMLS_CC); yy_push_state(ST_SECTION_VALUE);
} }
return TC_SECTION; return TC_SECTION;
} }
@ -725,7 +725,7 @@ yy28:
EAT_TRAILING_WHITESPACE_EX('['); EAT_TRAILING_WHITESPACE_EX('[');
/* Enter offset lookup state */ /* Enter offset lookup state */
yy_push_state(ST_OFFSET TSRMLS_CC); yy_push_state(ST_OFFSET);
RETURN_TOKEN(TC_OFFSET, yytext, yyleng); RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
} }
@ -1114,7 +1114,7 @@ yy70:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 639 "Zend/zend_ini_scanner.l" #line 639 "Zend/zend_ini_scanner.l"
{ /* #Comment */ { /* #Comment */
zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno)); zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(), SCNG(lineno));
BEGIN(INITIAL); BEGIN(INITIAL);
SCNG(lineno)++; SCNG(lineno)++;
return END_OF_LINE; return END_OF_LINE;
@ -1292,7 +1292,7 @@ yy81:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC); zend_ini_escape_string(ini_lval, yytext, yyleng, '"');
return TC_QUOTED_STRING; return TC_QUOTED_STRING;
} }
#line 1299 "Zend/zend_ini_scanner.c" #line 1299 "Zend/zend_ini_scanner.c"
@ -1306,7 +1306,7 @@ yy83:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 578 "Zend/zend_ini_scanner.l" #line 578 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string ends */ { /* Double quoted '"' string ends */
yy_pop_state(TSRMLS_C); yy_pop_state();
return '"'; return '"';
} }
#line 1313 "Zend/zend_ini_scanner.c" #line 1313 "Zend/zend_ini_scanner.c"
@ -1320,7 +1320,7 @@ yy84:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 445 "Zend/zend_ini_scanner.l" #line 445 "Zend/zend_ini_scanner.l"
{ /* Variable start */ { /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC); yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY; return TC_DOLLAR_CURLY;
} }
#line 1327 "Zend/zend_ini_scanner.c" #line 1327 "Zend/zend_ini_scanner.c"
@ -1457,7 +1457,7 @@ yy97:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 573 "Zend/zend_ini_scanner.l" #line 573 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */ { /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); yy_push_state(ST_DOUBLE_QUOTES);
return '"'; return '"';
} }
#line 1464 "Zend/zend_ini_scanner.c" #line 1464 "Zend/zend_ini_scanner.c"
@ -1879,7 +1879,7 @@ yy134:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 445 "Zend/zend_ini_scanner.l" #line 445 "Zend/zend_ini_scanner.l"
{ /* Variable start */ { /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC); yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY; return TC_DOLLAR_CURLY;
} }
#line 1886 "Zend/zend_ini_scanner.c" #line 1886 "Zend/zend_ini_scanner.c"
@ -2382,7 +2382,7 @@ yy183:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 573 "Zend/zend_ini_scanner.l" #line 573 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */ { /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); yy_push_state(ST_DOUBLE_QUOTES);
return '"'; return '"';
} }
#line 2389 "Zend/zend_ini_scanner.c" #line 2389 "Zend/zend_ini_scanner.c"
@ -2829,7 +2829,7 @@ yy224:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 445 "Zend/zend_ini_scanner.l" #line 445 "Zend/zend_ini_scanner.l"
{ /* Variable start */ { /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC); yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY; return TC_DOLLAR_CURLY;
} }
#line 2836 "Zend/zend_ini_scanner.c" #line 2836 "Zend/zend_ini_scanner.c"
@ -3084,7 +3084,7 @@ yy243:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 573 "Zend/zend_ini_scanner.l" #line 573 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */ { /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); yy_push_state(ST_DOUBLE_QUOTES);
return '"'; return '"';
} }
#line 3091 "Zend/zend_ini_scanner.c" #line 3091 "Zend/zend_ini_scanner.c"
@ -4641,7 +4641,7 @@ yy309:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 445 "Zend/zend_ini_scanner.l" #line 445 "Zend/zend_ini_scanner.l"
{ /* Variable start */ { /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC); yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY; return TC_DOLLAR_CURLY;
} }
#line 4648 "Zend/zend_ini_scanner.c" #line 4648 "Zend/zend_ini_scanner.c"
@ -4803,7 +4803,7 @@ yy324:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 460 "Zend/zend_ini_scanner.l" #line 460 "Zend/zend_ini_scanner.l"
{ /* Variable end */ { /* Variable end */
yy_pop_state(TSRMLS_C); yy_pop_state();
return '}'; return '}';
} }
#line 4810 "Zend/zend_ini_scanner.c" #line 4810 "Zend/zend_ini_scanner.c"

View file

@ -28,12 +28,12 @@
#define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */ #define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int zend_ini_scanner_get_lineno(TSRMLS_D); int zend_ini_scanner_get_lineno(void);
char *zend_ini_scanner_get_filename(TSRMLS_D); char *zend_ini_scanner_get_filename(void);
int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC); int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode);
int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC); int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode);
int ini_lex(zval *ini_lval TSRMLS_DC); int ini_lex(zval *ini_lval);
void shutdown_ini_scanner(TSRMLS_D); void shutdown_ini_scanner(void);
END_EXTERN_C() END_EXTERN_C()
#endif /* _ZEND_INI_SCANNER_H */ #endif /* _ZEND_INI_SCANNER_H */

View file

@ -187,7 +187,7 @@ static void zend_ini_copy_typed_value(zval *retval, const int type, const char *
} }
} }
static void _yy_push_state(int new_state TSRMLS_DC) static void _yy_push_state(int new_state)
{ {
zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION()); zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
YYSETCONDITION(new_state); YYSETCONDITION(new_state);
@ -195,14 +195,14 @@ static void _yy_push_state(int new_state TSRMLS_DC)
#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
static void yy_pop_state(TSRMLS_D) static void yy_pop_state(void)
{ {
int *stack_state = zend_stack_top(&SCNG(state_stack)); int *stack_state = zend_stack_top(&SCNG(state_stack));
YYSETCONDITION(*stack_state); YYSETCONDITION(*stack_state);
zend_stack_del_top(&SCNG(state_stack)); zend_stack_del_top(&SCNG(state_stack));
} }
static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) static void yy_scan_buffer(char *str, unsigned int len)
{ {
YYCURSOR = (YYCTYPE*)str; YYCURSOR = (YYCTYPE*)str;
SCNG(yy_start) = YYCURSOR; SCNG(yy_start) = YYCURSOR;
@ -213,7 +213,7 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
/* {{{ init_ini_scanner() /* {{{ init_ini_scanner()
*/ */
static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC) static int init_ini_scanner(int scanner_mode, zend_file_handle *fh)
{ {
/* Sanity check */ /* Sanity check */
if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) {
@ -240,7 +240,7 @@ static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC)
/* {{{ shutdown_ini_scanner() /* {{{ shutdown_ini_scanner()
*/ */
void shutdown_ini_scanner(TSRMLS_D) void shutdown_ini_scanner(void)
{ {
zend_stack_destroy(&SCNG(state_stack)); zend_stack_destroy(&SCNG(state_stack));
if (ini_filename) { if (ini_filename) {
@ -251,7 +251,7 @@ void shutdown_ini_scanner(TSRMLS_D)
/* {{{ zend_ini_scanner_get_lineno() /* {{{ zend_ini_scanner_get_lineno()
*/ */
int zend_ini_scanner_get_lineno(TSRMLS_D) int zend_ini_scanner_get_lineno(void)
{ {
return SCNG(lineno); return SCNG(lineno);
} }
@ -259,7 +259,7 @@ int zend_ini_scanner_get_lineno(TSRMLS_D)
/* {{{ zend_ini_scanner_get_filename() /* {{{ zend_ini_scanner_get_filename()
*/ */
char *zend_ini_scanner_get_filename(TSRMLS_D) char *zend_ini_scanner_get_filename(void)
{ {
return ini_filename ? ini_filename : "Unknown"; return ini_filename ? ini_filename : "Unknown";
} }
@ -267,21 +267,21 @@ char *zend_ini_scanner_get_filename(TSRMLS_D)
/* {{{ zend_ini_open_file_for_scanning() /* {{{ zend_ini_open_file_for_scanning()
*/ */
int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC) int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode)
{ {
char *buf; char *buf;
size_t size; size_t size;
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) { if (zend_stream_fixup(fh, &buf, &size) == FAILURE) {
return FAILURE; return FAILURE;
} }
if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) { if (init_ini_scanner(scanner_mode, fh) == FAILURE) {
zend_file_handle_dtor(fh TSRMLS_CC); zend_file_handle_dtor(fh);
return FAILURE; return FAILURE;
} }
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
return SUCCESS; return SUCCESS;
} }
@ -289,15 +289,15 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML
/* {{{ zend_ini_prepare_string_for_scanning() /* {{{ zend_ini_prepare_string_for_scanning()
*/ */
int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode)
{ {
int len = (int)strlen(str); int len = (int)strlen(str);
if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) { if (init_ini_scanner(scanner_mode, NULL) == FAILURE) {
return FAILURE; return FAILURE;
} }
yy_scan_buffer(str, len TSRMLS_CC); yy_scan_buffer(str, len);
return SUCCESS; return SUCCESS;
} }
@ -305,7 +305,7 @@ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC)
/* {{{ zend_ini_escape_string() /* {{{ zend_ini_escape_string()
*/ */
static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type TSRMLS_DC) static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type)
{ {
register char *s, *t; register char *s, *t;
char *end; char *end;
@ -352,7 +352,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty
} }
/* }}} */ /* }}} */
int ini_lex(zval *ini_lval TSRMLS_DC) int ini_lex(zval *ini_lval)
{ {
restart: restart:
SCNG(yy_text) = YYCURSOR; SCNG(yy_text) = YYCURSOR;
@ -402,9 +402,9 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
<INITIAL>"[" { /* Section start */ <INITIAL>"[" { /* Section start */
/* Enter section data lookup state */ /* Enter section data lookup state */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_SECTION_RAW TSRMLS_CC); yy_push_state(ST_SECTION_RAW);
} else { } else {
yy_push_state(ST_SECTION_VALUE TSRMLS_CC); yy_push_state(ST_SECTION_VALUE);
} }
return TC_SECTION; return TC_SECTION;
} }
@ -432,7 +432,7 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
EAT_TRAILING_WHITESPACE_EX('['); EAT_TRAILING_WHITESPACE_EX('[');
/* Enter offset lookup state */ /* Enter offset lookup state */
yy_push_state(ST_OFFSET TSRMLS_CC); yy_push_state(ST_OFFSET);
RETURN_TOKEN(TC_OFFSET, yytext, yyleng); RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
} }
@ -443,7 +443,7 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
} }
<ST_DOUBLE_QUOTES,ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{DOLLAR_CURLY} { /* Variable start */ <ST_DOUBLE_QUOTES,ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{DOLLAR_CURLY} { /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC); yy_push_state(ST_VARNAME);
return TC_DOLLAR_CURLY; return TC_DOLLAR_CURLY;
} }
@ -458,7 +458,7 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
} }
<ST_VARNAME>"}" { /* Variable end */ <ST_VARNAME>"}" { /* Variable end */
yy_pop_state(TSRMLS_C); yy_pop_state();
return '}'; return '}';
} }
@ -486,9 +486,9 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
<INITIAL>{TABS_AND_SPACES}*[=]{TABS_AND_SPACES}* { /* Start option value */ <INITIAL>{TABS_AND_SPACES}*[=]{TABS_AND_SPACES}* { /* Start option value */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_RAW TSRMLS_CC); yy_push_state(ST_RAW);
} else { } else {
yy_push_state(ST_VALUE TSRMLS_CC); yy_push_state(ST_VALUE);
} }
return '='; return '=';
} }
@ -571,12 +571,12 @@ end_raw_value_chars:
} }
<ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{TABS_AND_SPACES}*["] { /* Double quoted '"' string start */ <ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{TABS_AND_SPACES}*["] { /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); yy_push_state(ST_DOUBLE_QUOTES);
return '"'; return '"';
} }
<ST_DOUBLE_QUOTES>["]{TABS_AND_SPACES}* { /* Double quoted '"' string ends */ <ST_DOUBLE_QUOTES>["]{TABS_AND_SPACES}* { /* Double quoted '"' string ends */
yy_pop_state(TSRMLS_C); yy_pop_state();
return '"'; return '"';
} }
@ -612,7 +612,7 @@ end_raw_value_chars:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC); zend_ini_escape_string(ini_lval, yytext, yyleng, '"');
return TC_QUOTED_STRING; return TC_QUOTED_STRING;
} }
@ -637,7 +637,7 @@ end_raw_value_chars:
} }
<INITIAL>{TABS_AND_SPACES}*[#][^\r\n]*{NEWLINE} { /* #Comment */ <INITIAL>{TABS_AND_SPACES}*[#][^\r\n]*{NEWLINE} { /* #Comment */
zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno)); zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(), SCNG(lineno));
BEGIN(INITIAL); BEGIN(INITIAL);
SCNG(lineno)++; SCNG(lineno)++;
return END_OF_LINE; return END_OF_LINE;

View file

@ -31,7 +31,7 @@ ZEND_API zend_class_entry *zend_ce_serializable;
/* {{{ zend_call_method /* {{{ zend_call_method
Only returns the returned zval if retval_ptr != NULL */ Only returns the returned zval if retval_ptr != NULL */
ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2)
{ {
int result; int result;
zend_fcall_info fci; zend_fcall_info fci;
@ -61,7 +61,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
/* no interest in caching and no information already present that is /* no interest in caching and no information already present that is
* needed later inside zend_call_function. */ * needed later inside zend_call_function. */
fci.function_table = !object ? EG(function_table) : NULL; fci.function_table = !object ? EG(function_table) : NULL;
result = zend_call_function(&fci, NULL TSRMLS_CC); result = zend_call_function(&fci, NULL);
zval_ptr_dtor(&fci.function_name); zval_ptr_dtor(&fci.function_name);
} else { } else {
zend_fcall_info_cache fcic; zend_fcall_info_cache fcic;
@ -92,13 +92,13 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
} else if (obj_ce && } else if (obj_ce &&
!(EG(current_execute_data) && !(EG(current_execute_data) &&
EG(current_execute_data)->called_scope && EG(current_execute_data)->called_scope &&
instanceof_function(EG(current_execute_data)->called_scope, obj_ce TSRMLS_CC))) { instanceof_function(EG(current_execute_data)->called_scope, obj_ce))) {
fcic.called_scope = obj_ce; fcic.called_scope = obj_ce;
} else { } else {
fcic.called_scope = EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL; fcic.called_scope = EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL;
} }
fcic.object = object ? Z_OBJ_P(object) : NULL; fcic.object = object ? Z_OBJ_P(object) : NULL;
result = zend_call_function(&fci, &fcic TSRMLS_CC); result = zend_call_function(&fci, &fcic);
zval_ptr_dtor(&fci.function_name); zval_ptr_dtor(&fci.function_name);
} }
if (result == FAILURE) { if (result == FAILURE) {
@ -128,14 +128,14 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
/* iterator interface, c-level functions used by engine */ /* iterator interface, c-level functions used by engine */
/* {{{ zend_user_it_new_iterator */ /* {{{ zend_user_it_new_iterator */
ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *retval TSRMLS_DC) ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *retval)
{ {
zend_call_method_with_0_params(object, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", retval); zend_call_method_with_0_params(object, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", retval);
} }
/* }}} */ /* }}} */
/* {{{ zend_user_it_invalidate_current */ /* {{{ zend_user_it_invalidate_current */
ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS_DC) ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
@ -147,18 +147,18 @@ ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS
/* }}} */ /* }}} */
/* {{{ zend_user_it_dtor */ /* {{{ zend_user_it_dtor */
static void zend_user_it_dtor(zend_object_iterator *_iter TSRMLS_DC) static void zend_user_it_dtor(zend_object_iterator *_iter)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data; zval *object = &iter->it.data;
zend_user_it_invalidate_current(_iter TSRMLS_CC); zend_user_it_invalidate_current(_iter);
zval_ptr_dtor(object); zval_ptr_dtor(object);
} }
/* }}} */ /* }}} */
/* {{{ zend_user_it_valid */ /* {{{ zend_user_it_valid */
ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC) ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
{ {
if (_iter) { if (_iter) {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
@ -168,7 +168,7 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC)
zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more); zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more);
if (Z_TYPE(more) != IS_UNDEF) { if (Z_TYPE(more) != IS_UNDEF) {
result = i_zend_is_true(&more TSRMLS_CC); result = i_zend_is_true(&more);
zval_ptr_dtor(&more); zval_ptr_dtor(&more);
return result ? SUCCESS : FAILURE; return result ? SUCCESS : FAILURE;
} }
@ -178,7 +178,7 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC)
/* }}} */ /* }}} */
/* {{{ zend_user_it_get_current_data */ /* {{{ zend_user_it_get_current_data */
ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter TSRMLS_DC) ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data; zval *object = &iter->it.data;
@ -192,7 +192,7 @@ ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter TSRMLS_
/* {{{ zend_user_it_get_current_key_default */ /* {{{ zend_user_it_get_current_key_default */
#if 0 #if 0
static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key)
{ {
*int_key = _iter->index; *int_key = _iter->index;
return HASH_KEY_IS_LONG; return HASH_KEY_IS_LONG;
@ -201,7 +201,7 @@ static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, cha
/* }}} */ /* }}} */
/* {{{ zend_user_it_get_current_key */ /* {{{ zend_user_it_get_current_key */
ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key TSRMLS_DC) ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data; zval *object = &iter->it.data;
@ -222,23 +222,23 @@ ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *ke
/* }}} */ /* }}} */
/* {{{ zend_user_it_move_forward */ /* {{{ zend_user_it_move_forward */
ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter TSRMLS_DC) ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data; zval *object = &iter->it.data;
zend_user_it_invalidate_current(_iter TSRMLS_CC); zend_user_it_invalidate_current(_iter);
zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_next, "next", NULL); zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_next, "next", NULL);
} }
/* }}} */ /* }}} */
/* {{{ zend_user_it_rewind */ /* {{{ zend_user_it_rewind */
ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter TSRMLS_DC) ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter)
{ {
zend_user_iterator *iter = (zend_user_iterator*)_iter; zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data; zval *object = &iter->it.data;
zend_user_it_invalidate_current(_iter TSRMLS_CC); zend_user_it_invalidate_current(_iter);
zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_rewind, "rewind", NULL); zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_rewind, "rewind", NULL);
} }
/* }}} */ /* }}} */
@ -254,7 +254,7 @@ zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = {
}; };
/* {{{ zend_user_it_get_iterator */ /* {{{ zend_user_it_get_iterator */
static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref)
{ {
zend_user_iterator *iterator; zend_user_iterator *iterator;
@ -264,7 +264,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
iterator = emalloc(sizeof(zend_user_iterator)); iterator = emalloc(sizeof(zend_user_iterator));
zend_iterator_init((zend_object_iterator*)iterator TSRMLS_CC); zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->it.data, object); ZVAL_COPY(&iterator->it.data, object);
iterator->it.funcs = ce->iterator_funcs.funcs; iterator->it.funcs = ce->iterator_funcs.funcs;
@ -275,31 +275,31 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
/* }}} */ /* }}} */
/* {{{ zend_user_it_get_new_iterator */ /* {{{ zend_user_it_get_new_iterator */
ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref)
{ {
zval iterator; zval iterator;
zend_object_iterator *new_iterator; zend_object_iterator *new_iterator;
zend_class_entry *ce_it; zend_class_entry *ce_it;
zend_user_it_new_iterator(ce, object, &iterator TSRMLS_CC); zend_user_it_new_iterator(ce, object, &iterator);
ce_it = (Z_TYPE(iterator) == IS_OBJECT) ? Z_OBJCE(iterator) : NULL; ce_it = (Z_TYPE(iterator) == IS_OBJECT) ? Z_OBJCE(iterator) : NULL;
if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && Z_OBJ(iterator) == Z_OBJ_P(object))) { if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && Z_OBJ(iterator) == Z_OBJ_P(object))) {
if (!EG(exception)) { if (!EG(exception)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ce->name->val : Z_OBJCE_P(object)->name->val); zend_throw_exception_ex(NULL, 0, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ce->name->val : Z_OBJCE_P(object)->name->val);
} }
zval_ptr_dtor(&iterator); zval_ptr_dtor(&iterator);
return NULL; return NULL;
} }
new_iterator = ce_it->get_iterator(ce_it, &iterator, by_ref TSRMLS_CC); new_iterator = ce_it->get_iterator(ce_it, &iterator, by_ref);
zval_ptr_dtor(&iterator); zval_ptr_dtor(&iterator);
return new_iterator; return new_iterator;
} }
/* }}} */ /* }}} */
/* {{{ zend_implement_traversable */ /* {{{ zend_implement_traversable */
static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC) static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type)
{ {
/* check that class_type is traversable at c-level or implements at least one of 'aggregate' and 'Iterator' */ /* check that class_type is traversable at c-level or implements at least one of 'aggregate' and 'Iterator' */
uint32_t i; uint32_t i;
@ -322,7 +322,7 @@ static int zend_implement_traversable(zend_class_entry *interface, zend_class_en
/* }}} */ /* }}} */
/* {{{ zend_implement_aggregate */ /* {{{ zend_implement_aggregate */
static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC) static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type)
{ {
uint32_t i; uint32_t i;
int t = -1; int t = -1;
@ -359,7 +359,7 @@ static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entr
/* }}} */ /* }}} */
/* {{{ zend_implement_iterator */ /* {{{ zend_implement_iterator */
static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC) static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type)
{ {
if (class_type->get_iterator && class_type->get_iterator != zend_user_it_get_iterator) { if (class_type->get_iterator && class_type->get_iterator != zend_user_it_get_iterator) {
if (class_type->type == ZEND_INTERNAL_CLASS) { if (class_type->type == ZEND_INTERNAL_CLASS) {
@ -390,7 +390,7 @@ static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry
/* }}} */ /* }}} */
/* {{{ zend_implement_arrayaccess */ /* {{{ zend_implement_arrayaccess */
static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC) static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_entry *class_type)
{ {
#if 0 #if 0
/* get ht from ce */ /* get ht from ce */
@ -406,7 +406,7 @@ static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_en
/* }}}*/ /* }}}*/
/* {{{ zend_user_serialize */ /* {{{ zend_user_serialize */
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data TSRMLS_DC) ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data)
{ {
zend_class_entry * ce = Z_OBJCE_P(object); zend_class_entry * ce = Z_OBJCE_P(object);
zval retval; zval retval;
@ -436,14 +436,14 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *b
} }
if (result == FAILURE && !EG(exception)) { if (result == FAILURE && !EG(exception)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%s::serialize() must return a string or NULL", ce->name->val); zend_throw_exception_ex(NULL, 0, "%s::serialize() must return a string or NULL", ce->name->val);
} }
return result; return result;
} }
/* }}} */ /* }}} */
/* {{{ zend_user_unserialize */ /* {{{ zend_user_unserialize */
ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data TSRMLS_DC) ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data)
{ {
zval zdata; zval zdata;
@ -463,27 +463,27 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns
} }
/* }}} */ /* }}} */
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */ ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Serialization of '%s' is not allowed", ce->name->val); zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ce->name->val);
return FAILURE; return FAILURE;
} }
/* }}} */ /* }}} */
ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */ ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */
{ {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Unserialization of '%s' is not allowed", ce->name->val); zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ce->name->val);
return FAILURE; return FAILURE;
} }
/* }}} */ /* }}} */
/* {{{ zend_implement_serializable */ /* {{{ zend_implement_serializable */
static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC) static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type)
{ {
if (class_type->parent if (class_type->parent
&& (class_type->parent->serialize || class_type->parent->unserialize) && (class_type->parent->serialize || class_type->parent->unserialize)
&& !instanceof_function_ex(class_type->parent, zend_ce_serializable, 1 TSRMLS_CC)) { && !instanceof_function_ex(class_type->parent, zend_ce_serializable, 1)) {
return FAILURE; return FAILURE;
} }
if (!class_type->serialize) { if (!class_type->serialize) {
@ -549,15 +549,15 @@ const zend_function_entry zend_funcs_serializable[] = {
{\ {\
zend_class_entry ce;\ zend_class_entry ce;\
INIT_CLASS_ENTRY(ce, # class_name_str, zend_funcs_ ## class_name) \ INIT_CLASS_ENTRY(ce, # class_name_str, zend_funcs_ ## class_name) \
zend_ce_ ## class_name = zend_register_internal_interface(&ce TSRMLS_CC);\ zend_ce_ ## class_name = zend_register_internal_interface(&ce);\
zend_ce_ ## class_name->interface_gets_implemented = zend_implement_ ## class_name;\ zend_ce_ ## class_name->interface_gets_implemented = zend_implement_ ## class_name;\
} }
#define REGISTER_ITERATOR_IMPLEMENT(class_name, interface_name) \ #define REGISTER_ITERATOR_IMPLEMENT(class_name, interface_name) \
zend_class_implements(zend_ce_ ## class_name TSRMLS_CC, 1, zend_ce_ ## interface_name) zend_class_implements(zend_ce_ ## class_name, 1, zend_ce_ ## interface_name)
/* {{{ zend_register_interfaces */ /* {{{ zend_register_interfaces */
ZEND_API void zend_register_interfaces(TSRMLS_D) ZEND_API void zend_register_interfaces(void)
{ {
REGISTER_ITERATOR_INTERFACE(traversable, Traversable); REGISTER_ITERATOR_INTERFACE(traversable, Traversable);

View file

@ -38,34 +38,34 @@ typedef struct _zend_user_iterator {
zval value; zval value;
} zend_user_iterator; } zend_user_iterator;
ZEND_API zval* zend_call_method(zval *object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); ZEND_API zval* zend_call_method(zval *object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2);
#define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \ #define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \
zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC) zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL)
#define zend_call_method_with_1_params(obj, obj_ce, fn_proxy, function_name, retval, arg1) \ #define zend_call_method_with_1_params(obj, obj_ce, fn_proxy, function_name, retval, arg1) \
zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 1, arg1, NULL TSRMLS_CC) zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 1, arg1, NULL)
#define zend_call_method_with_2_params(obj, obj_ce, fn_proxy, function_name, retval, arg1, arg2) \ #define zend_call_method_with_2_params(obj, obj_ce, fn_proxy, function_name, retval, arg1, arg2) \
zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 2, arg1, arg2 TSRMLS_CC) zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 2, arg1, arg2)
ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter TSRMLS_DC); ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter);
ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC); ZEND_API int zend_user_it_valid(zend_object_iterator *_iter);
ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key TSRMLS_DC); ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key);
ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter TSRMLS_DC); ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter);
ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter TSRMLS_DC); ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter);
ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS_DC); ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter);
ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *iterator TSRMLS_DC); ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *iterator);
ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC); ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref);
ZEND_API void zend_register_interfaces(TSRMLS_D); ZEND_API void zend_register_interfaces(void);
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data TSRMLS_DC); ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data TSRMLS_DC); ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data TSRMLS_DC); ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data TSRMLS_DC); ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
END_EXTERN_C() END_EXTERN_C()

View file

@ -24,8 +24,8 @@
static zend_class_entry zend_iterator_class_entry; static zend_class_entry zend_iterator_class_entry;
static void iter_wrapper_free(zend_object *object TSRMLS_DC); static void iter_wrapper_free(zend_object *object);
static void iter_wrapper_dtor(zend_object *object TSRMLS_DC); static void iter_wrapper_dtor(zend_object *object);
static zend_object_handlers iterator_object_handlers = { static zend_object_handlers iterator_object_handlers = {
0, 0,
@ -58,37 +58,37 @@ static zend_object_handlers iterator_object_handlers = {
NULL /* compare */ NULL /* compare */
}; };
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D) ZEND_API void zend_register_iterator_wrapper(void)
{ {
INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL); INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
} }
static void iter_wrapper_free(zend_object *object TSRMLS_DC) static void iter_wrapper_free(zend_object *object)
{ {
zend_object_iterator *iter = (zend_object_iterator*)object; zend_object_iterator *iter = (zend_object_iterator*)object;
iter->funcs->dtor(iter TSRMLS_CC); iter->funcs->dtor(iter);
} }
static void iter_wrapper_dtor(zend_object *object TSRMLS_DC) static void iter_wrapper_dtor(zend_object *object)
{ {
} }
ZEND_API void zend_iterator_init(zend_object_iterator *iter TSRMLS_DC) ZEND_API void zend_iterator_init(zend_object_iterator *iter)
{ {
zend_object_std_init(&iter->std, &zend_iterator_class_entry TSRMLS_CC); zend_object_std_init(&iter->std, &zend_iterator_class_entry);
iter->std.handlers = &iterator_object_handlers; iter->std.handlers = &iterator_object_handlers;
} }
ZEND_API void zend_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) ZEND_API void zend_iterator_dtor(zend_object_iterator *iter)
{ {
if (--GC_REFCOUNT(iter) > 0) { if (--GC_REFCOUNT(iter) > 0) {
return; return;
} }
zend_objects_store_del(&iter->std TSRMLS_CC); zend_objects_store_del(&iter->std);
} }
ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr TSRMLS_DC) ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr)
{ {
if (Z_TYPE_P(array_ptr) && if (Z_TYPE_P(array_ptr) &&
Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) { Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {

View file

@ -30,28 +30,28 @@ typedef struct _zend_object_iterator zend_object_iterator;
typedef struct _zend_object_iterator_funcs { typedef struct _zend_object_iterator_funcs {
/* release all resources associated with this iterator instance */ /* release all resources associated with this iterator instance */
void (*dtor)(zend_object_iterator *iter TSRMLS_DC); void (*dtor)(zend_object_iterator *iter);
/* check for end of iteration (FAILURE or SUCCESS if data is valid) */ /* check for end of iteration (FAILURE or SUCCESS if data is valid) */
int (*valid)(zend_object_iterator *iter TSRMLS_DC); int (*valid)(zend_object_iterator *iter);
/* fetch the item data for the current element */ /* fetch the item data for the current element */
zval *(*get_current_data)(zend_object_iterator *iter TSRMLS_DC); zval *(*get_current_data)(zend_object_iterator *iter);
/* fetch the key for the current element (optional, may be NULL). The key /* fetch the key for the current element (optional, may be NULL). The key
* should be written into the provided zval* using the ZVAL_* macros. If * should be written into the provided zval* using the ZVAL_* macros. If
* this handler is not provided auto-incrementing integer keys will be * this handler is not provided auto-incrementing integer keys will be
* used. */ * used. */
void (*get_current_key)(zend_object_iterator *iter, zval *key TSRMLS_DC); void (*get_current_key)(zend_object_iterator *iter, zval *key);
/* step forwards to next element */ /* step forwards to next element */
void (*move_forward)(zend_object_iterator *iter TSRMLS_DC); void (*move_forward)(zend_object_iterator *iter);
/* rewind to start of data (optional, may be NULL) */ /* rewind to start of data (optional, may be NULL) */
void (*rewind)(zend_object_iterator *iter TSRMLS_DC); void (*rewind)(zend_object_iterator *iter);
/* invalidate current value/key (optional, may be NULL) */ /* invalidate current value/key (optional, may be NULL) */
void (*invalidate_current)(zend_object_iterator *iter TSRMLS_DC); void (*invalidate_current)(zend_object_iterator *iter);
} zend_object_iterator_funcs; } zend_object_iterator_funcs;
struct _zend_object_iterator { struct _zend_object_iterator {
@ -73,13 +73,13 @@ typedef struct _zend_class_iterator_funcs {
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
/* given a zval, returns stuff that can be used to iterate it. */ /* given a zval, returns stuff that can be used to iterate it. */
ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr TSRMLS_DC); ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr);
/* given an iterator, wrap it up as a zval for use by the engine opcodes */ /* given an iterator, wrap it up as a zval for use by the engine opcodes */
ZEND_API void zend_iterator_init(zend_object_iterator *iter TSRMLS_DC); ZEND_API void zend_iterator_init(zend_object_iterator *iter);
ZEND_API void zend_iterator_dtor(zend_object_iterator *iter TSRMLS_DC); ZEND_API void zend_iterator_dtor(zend_object_iterator *iter);
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D); ZEND_API void zend_register_iterator_wrapper(void);
END_EXTERN_C() END_EXTERN_C()
/* /*

View file

@ -283,8 +283,8 @@ top_statement:
| class_declaration_statement { $$ = $1; } | class_declaration_statement { $$ = $1; }
| T_HALT_COMPILER '(' ')' ';' | T_HALT_COMPILER '(' ')' ';'
{ $$ = zend_ast_create(ZEND_AST_HALT_COMPILER, { $$ = zend_ast_create(ZEND_AST_HALT_COMPILER,
zend_ast_create_zval_from_long(zend_get_scanned_file_offset(TSRMLS_C))); zend_ast_create_zval_from_long(zend_get_scanned_file_offset()));
zend_stop_lexing(TSRMLS_C); } zend_stop_lexing(); }
| T_NAMESPACE namespace_name ';' | T_NAMESPACE namespace_name ';'
{ $$ = zend_ast_create(ZEND_AST_NAMESPACE, $2, NULL); { $$ = zend_ast_create(ZEND_AST_NAMESPACE, $2, NULL);
RESET_DOC_COMMENT(); } RESET_DOC_COMMENT(); }
@ -368,7 +368,7 @@ statement:
foreach_statement foreach_statement
{ $$ = zend_ast_create(ZEND_AST_FOREACH, $3, $7, $5, $9); } { $$ = zend_ast_create(ZEND_AST_FOREACH, $3, $7, $5, $9); }
| T_DECLARE '(' const_list ')' | T_DECLARE '(' const_list ')'
{ zend_handle_encoding_declaration($3 TSRMLS_CC); } { zend_handle_encoding_declaration($3); }
declare_statement declare_statement
{ $$ = zend_ast_create(ZEND_AST_DECLARE, $3, $6); } { $$ = zend_ast_create(ZEND_AST_DECLARE, $3, $6); }
| ';' /* empty statement */ { $$ = NULL; } | ';' /* empty statement */ { $$ = NULL; }
@ -606,7 +606,7 @@ class_statement_list:
class_statement: class_statement:
variable_modifiers property_list ';' variable_modifiers property_list ';'
{ $$ = zend_ast_append_doc_comment($2 TSRMLS_CC); $$->attr = $1; } { $$ = zend_ast_append_doc_comment($2); $$->attr = $1; }
| T_CONST class_const_list ';' | T_CONST class_const_list ';'
{ $$ = $2; RESET_DOC_COMMENT(); } { $$ = $2; RESET_DOC_COMMENT(); }
| T_USE name_list trait_adaptations | T_USE name_list trait_adaptations
@ -1171,8 +1171,7 @@ static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
return yystrlen(yystr); return yystrlen(yystr);
} }
{ {
TSRMLS_FETCH(); if (CG(parse_error) == 0) {
if (CG(parse_error) == 0) {
char buffer[120]; char buffer[120];
const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL; const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL;
unsigned int len = 0, toklen = 0, yystr_len; unsigned int len = 0, toklen = 0, yystr_len;

View file

@ -125,34 +125,34 @@ do { \
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
ZEND_ASSERT(internal_encoding); ZEND_ASSERT(internal_encoding);
return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding) TSRMLS_CC); return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding));
} }
static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding) TSRMLS_CC); return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding));
} }
static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
return zend_multibyte_encoding_converter(to, to_length, from, from_length, return zend_multibyte_encoding_converter(to, to_length, from, from_length,
LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8 TSRMLS_CC); LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8);
} }
static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
ZEND_ASSERT(internal_encoding); ZEND_ASSERT(internal_encoding);
return zend_multibyte_encoding_converter(to, to_length, from, from_length, return zend_multibyte_encoding_converter(to, to_length, from, from_length,
internal_encoding, zend_multibyte_encoding_utf8 TSRMLS_CC); internal_encoding, zend_multibyte_encoding_utf8);
} }
static void _yy_push_state(int new_state TSRMLS_DC) static void _yy_push_state(int new_state)
{ {
zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION()); zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
YYSETCONDITION(new_state); YYSETCONDITION(new_state);
@ -160,14 +160,14 @@ static void _yy_push_state(int new_state TSRMLS_DC)
#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
static void yy_pop_state(TSRMLS_D) static void yy_pop_state(void)
{ {
int *stack_state = zend_stack_top(&SCNG(state_stack)); int *stack_state = zend_stack_top(&SCNG(state_stack));
YYSETCONDITION(*stack_state); YYSETCONDITION(*stack_state);
zend_stack_del_top(&SCNG(state_stack)); zend_stack_del_top(&SCNG(state_stack));
} }
static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) static void yy_scan_buffer(char *str, unsigned int len)
{ {
YYCURSOR = (YYCTYPE*)str; YYCURSOR = (YYCTYPE*)str;
YYLIMIT = YYCURSOR + len; YYLIMIT = YYCURSOR + len;
@ -176,7 +176,7 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
} }
} }
void startup_scanner(TSRMLS_D) void startup_scanner(void)
{ {
CG(parse_error) = 0; CG(parse_error) = 0;
CG(doc_comment) = NULL; CG(doc_comment) = NULL;
@ -188,7 +188,7 @@ static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) {
efree(heredoc_label->label); efree(heredoc_label->label);
} }
void shutdown_scanner(TSRMLS_D) void shutdown_scanner(void)
{ {
CG(parse_error) = 0; CG(parse_error) = 0;
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
@ -197,7 +197,7 @@ void shutdown_scanner(TSRMLS_D)
zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); zend_ptr_stack_destroy(&SCNG(heredoc_label_stack));
} }
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state)
{ {
lex_state->yy_leng = SCNG(yy_leng); lex_state->yy_leng = SCNG(yy_leng);
lex_state->yy_start = SCNG(yy_start); lex_state->yy_start = SCNG(yy_start);
@ -214,7 +214,7 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
lex_state->in = SCNG(yy_in); lex_state->in = SCNG(yy_in);
lex_state->yy_state = YYSTATE; lex_state->yy_state = YYSTATE;
lex_state->filename = zend_get_compiled_filename(TSRMLS_C); lex_state->filename = zend_get_compiled_filename();
lex_state->lineno = CG(zend_lineno); lex_state->lineno = CG(zend_lineno);
lex_state->script_org = SCNG(script_org); lex_state->script_org = SCNG(script_org);
@ -226,7 +226,7 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
lex_state->script_encoding = SCNG(script_encoding); lex_state->script_encoding = SCNG(script_encoding);
} }
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state)
{ {
SCNG(yy_leng) = lex_state->yy_leng; SCNG(yy_leng) = lex_state->yy_leng;
SCNG(yy_start) = lex_state->yy_start; SCNG(yy_start) = lex_state->yy_start;
@ -245,7 +245,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
SCNG(yy_in) = lex_state->in; SCNG(yy_in) = lex_state->in;
YYSETCONDITION(lex_state->yy_state); YYSETCONDITION(lex_state->yy_state);
CG(zend_lineno) = lex_state->lineno; CG(zend_lineno) = lex_state->lineno;
zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); zend_restore_compiled_filename(lex_state->filename);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
@ -262,7 +262,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
} }
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
{ {
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles); zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
/* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */ /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
@ -278,7 +278,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
#define BOM_UTF16_LE "\xff\xfe" #define BOM_UTF16_LE "\xff\xfe"
#define BOM_UTF8 "\xef\xbb\xbf" #define BOM_UTF8 "\xef\xbb\xbf"
static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size TSRMLS_DC) static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size)
{ {
const unsigned char *p; const unsigned char *p;
int wchar_size = 2; int wchar_size = 2;
@ -326,7 +326,7 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch
return NULL; return NULL;
} }
static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D) static const zend_encoding* zend_multibyte_detect_unicode(void)
{ {
const zend_encoding *script_encoding = NULL; const zend_encoding *script_encoding = NULL;
int bom_size; int bom_size;
@ -403,19 +403,19 @@ static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D)
} }
} }
/* make best effort if BOM is missing */ /* make best effort if BOM is missing */
return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size) TSRMLS_CC); return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size));
} }
return NULL; return NULL;
} }
static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D) static const zend_encoding* zend_multibyte_find_script_encoding(void)
{ {
const zend_encoding *script_encoding; const zend_encoding *script_encoding;
if (CG(detect_unicode)) { if (CG(detect_unicode)) {
/* check out bom(byte order mark) and see if containing wchars */ /* check out bom(byte order mark) and see if containing wchars */
script_encoding = zend_multibyte_detect_unicode(TSRMLS_C); script_encoding = zend_multibyte_detect_unicode();
if (script_encoding != NULL) { if (script_encoding != NULL) {
/* bom or wchar detection is prior to 'script_encoding' option */ /* bom or wchar detection is prior to 'script_encoding' option */
return script_encoding; return script_encoding;
@ -429,16 +429,16 @@ static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D)
/* if multiple encodings specified, detect automagically */ /* if multiple encodings specified, detect automagically */
if (CG(script_encoding_list_size) > 1) { if (CG(script_encoding_list_size) > 1) {
return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size) TSRMLS_CC); return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size));
} }
return CG(script_encoding_list)[0]; return CG(script_encoding_list)[0];
} }
ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC) ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(TSRMLS_C); const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding();
if (!script_encoding) { if (!script_encoding) {
return FAILURE; return FAILURE;
@ -476,7 +476,7 @@ ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSR
return 0; return 0;
} }
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
{ {
const char *file_path = NULL; const char *file_path = NULL;
char *buf; char *buf;
@ -490,7 +490,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
} }
if (zend_stream_fixup(file_handle, &buf, &size TSRMLS_CC) == FAILURE) { if (zend_stream_fixup(file_handle, &buf, &size) == FAILURE) {
return FAILURE; return FAILURE;
} }
@ -512,10 +512,10 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
SCNG(script_org_size) = size; SCNG(script_org_size) = size;
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
zend_multibyte_set_filter(NULL TSRMLS_CC); zend_multibyte_set_filter(NULL);
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -524,7 +524,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
} }
SCNG(yy_start) = (unsigned char *)buf - offset; SCNG(yy_start) = (unsigned char *)buf - offset;
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
} else { } else {
zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
} }
@ -538,7 +538,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
compiled_filename = zend_string_init(file_path, strlen(file_path), 0); compiled_filename = zend_string_init(file_path, strlen(file_path), 0);
zend_set_compiled_filename(compiled_filename TSRMLS_CC); zend_set_compiled_filename(compiled_filename);
zend_string_release(compiled_filename); zend_string_release(compiled_filename);
if (CG(start_lineno)) { if (CG(start_lineno)) {
@ -555,7 +555,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
END_EXTERN_C() END_EXTERN_C()
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
@ -567,51 +567,51 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR
ZVAL_LONG(&retval_zv, 1); ZVAL_LONG(&retval_zv, 1);
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) { if (open_file_for_scanning(file_handle)==FAILURE) {
if (type==ZEND_REQUIRE) { if (type==ZEND_REQUIRE) {
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
zend_bailout(); zend_bailout();
} else { } else {
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
} }
compilation_successful=0; compilation_successful=0;
} else { } else {
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE);
CG(in_compilation) = 1; CG(in_compilation) = 1;
CG(active_op_array) = op_array; CG(active_op_array) = op_array;
zend_stack_push(&CG(context_stack), (void *) &CG(context)); zend_stack_push(&CG(context_stack), (void *) &CG(context));
zend_init_compiler_context(TSRMLS_C); zend_init_compiler_context();
CG(ast_arena) = zend_arena_create(1024 * 32); CG(ast_arena) = zend_arena_create(1024 * 32);
compiler_result = zendparse(TSRMLS_C); compiler_result = zendparse();
if (compiler_result != 0) { /* parser error */ if (compiler_result != 0) { /* parser error */
zend_bailout(); zend_bailout();
} }
zend_compile_top_stmt(CG(ast) TSRMLS_CC); zend_compile_top_stmt(CG(ast));
zend_ast_destroy(CG(ast)); zend_ast_destroy(CG(ast));
zend_arena_destroy(CG(ast_arena)); zend_arena_destroy(CG(ast_arena));
zend_do_end_compilation(TSRMLS_C); zend_do_end_compilation();
zend_emit_final_return(&retval_zv TSRMLS_CC); zend_emit_final_return(&retval_zv);
CG(in_compilation) = original_in_compilation; CG(in_compilation) = original_in_compilation;
compilation_successful=1; compilation_successful=1;
} }
CG(active_op_array) = original_active_op_array; CG(active_op_array) = original_active_op_array;
if (compilation_successful) { if (compilation_successful) {
pass_two(op_array TSRMLS_CC); pass_two(op_array);
zend_release_labels(0 TSRMLS_CC); zend_release_labels(0);
} else { } else {
efree_size(op_array, sizeof(zend_op_array)); efree_size(op_array, sizeof(zend_op_array));
op_array = NULL; op_array = NULL;
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return op_array; return op_array;
} }
zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) zend_op_array *compile_filename(int type, zval *filename)
{ {
zend_file_handle file_handle; zend_file_handle file_handle;
zval tmp; zval tmp;
@ -630,7 +630,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
file_handle.opened_path = NULL; file_handle.opened_path = NULL;
file_handle.handle.fp = NULL; file_handle.handle.fp = NULL;
retval = zend_compile_file(&file_handle, type TSRMLS_CC); retval = zend_compile_file(&file_handle, type);
if (retval && file_handle.handle.stream.handle) { if (retval && file_handle.handle.stream.handle) {
if (!file_handle.opened_path) { if (!file_handle.opened_path) {
file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename)); file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename));
@ -642,7 +642,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
efree(opened_path); efree(opened_path);
} }
} }
zend_destroy_file_handle(&file_handle TSRMLS_CC); zend_destroy_file_handle(&file_handle);
if (filename==&tmp) { if (filename==&tmp) {
zval_dtor(&tmp); zval_dtor(&tmp);
@ -650,7 +650,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
return retval; return retval;
} }
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename)
{ {
char *buf; char *buf;
size_t size, old_len; size_t size, old_len;
@ -673,10 +673,10 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
SCNG(script_org_size) = size; SCNG(script_org_size) = size;
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
zend_multibyte_set_filter(zend_multibyte_get_internal_encoding(TSRMLS_C) TSRMLS_CC); zend_multibyte_set_filter(zend_multibyte_get_internal_encoding());
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -685,10 +685,10 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
} }
} }
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
new_compiled_filename = zend_string_init(filename, strlen(filename), 0); new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
zend_set_compiled_filename(new_compiled_filename TSRMLS_CC); zend_set_compiled_filename(new_compiled_filename);
zend_string_release(new_compiled_filename); zend_string_release(new_compiled_filename);
CG(zend_lineno) = 1; CG(zend_lineno) = 1;
CG(increment_lineno) = 0; CG(increment_lineno) = 0;
@ -697,14 +697,14 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
} }
ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D) ZEND_API size_t zend_get_scanned_file_offset(void)
{ {
size_t offset = SCNG(yy_cursor) - SCNG(yy_start); size_t offset = SCNG(yy_cursor) - SCNG(yy_start);
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
size_t original_offset = offset, length = 0; size_t original_offset = offset, length = 0;
do { do {
unsigned char *p = NULL; unsigned char *p = NULL;
if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset)) {
return (size_t)-1; return (size_t)-1;
} }
efree(p); efree(p);
@ -719,7 +719,7 @@ ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D)
} }
zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) zend_op_array *compile_string(zval *source_string, char *filename)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_op_array *op_array = NULL; zend_op_array *op_array = NULL;
@ -735,25 +735,25 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
source_string = &tmp; source_string = &tmp;
CG(in_compilation) = 1; CG(in_compilation) = 1;
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC) == SUCCESS) { if (zend_prepare_string_for_scanning(source_string, filename) == SUCCESS) {
CG(ast) = NULL; CG(ast) = NULL;
CG(ast_arena) = zend_arena_create(1024 * 32); CG(ast_arena) = zend_arena_create(1024 * 32);
BEGIN(ST_IN_SCRIPTING); BEGIN(ST_IN_SCRIPTING);
if (!zendparse(TSRMLS_C)) { if (!zendparse()) {
zend_op_array *original_active_op_array = CG(active_op_array); zend_op_array *original_active_op_array = CG(active_op_array);
op_array = emalloc(sizeof(zend_op_array)); op_array = emalloc(sizeof(zend_op_array));
init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE);
CG(active_op_array) = op_array; CG(active_op_array) = op_array;
zend_stack_push(&CG(context_stack), (void *) &CG(context)); zend_stack_push(&CG(context_stack), (void *) &CG(context));
zend_init_compiler_context(TSRMLS_C); zend_init_compiler_context();
zend_compile_top_stmt(CG(ast) TSRMLS_CC); zend_compile_top_stmt(CG(ast));
zend_do_end_compilation(TSRMLS_C); zend_do_end_compilation();
zend_emit_final_return(NULL TSRMLS_CC); zend_emit_final_return(NULL);
pass_two(op_array TSRMLS_CC); pass_two(op_array);
zend_release_labels(0 TSRMLS_CC); zend_release_labels(0);
CG(active_op_array) = original_active_op_array; CG(active_op_array) = original_active_op_array;
} }
@ -762,7 +762,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
zend_arena_destroy(CG(ast_arena)); zend_arena_destroy(CG(ast_arena));
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
zval_dtor(&tmp); zval_dtor(&tmp);
CG(in_compilation) = original_in_compilation; CG(in_compilation) = original_in_compilation;
return op_array; return op_array;
@ -770,7 +770,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_file_handle file_handle; zend_file_handle file_handle;
@ -779,46 +779,46 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
file_handle.filename = filename; file_handle.filename = filename;
file_handle.free_filename = 0; file_handle.free_filename = 0;
file_handle.opened_path = NULL; file_handle.opened_path = NULL;
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) { if (open_file_for_scanning(&file_handle)==FAILURE) {
zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return FAILURE; return FAILURE;
} }
zend_highlight(syntax_highlighter_ini TSRMLS_CC); zend_highlight(syntax_highlighter_ini);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
} }
zend_destroy_file_handle(&file_handle TSRMLS_CC); zend_destroy_file_handle(&file_handle);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return SUCCESS; return SUCCESS;
} }
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC) int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zval tmp = *str; zval tmp = *str;
str = &tmp; str = &tmp;
zval_copy_ctor(str); zval_copy_ctor(str);
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (zend_prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) { if (zend_prepare_string_for_scanning(str, str_name)==FAILURE) {
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return FAILURE; return FAILURE;
} }
BEGIN(INITIAL); BEGIN(INITIAL);
zend_highlight(syntax_highlighter_ini TSRMLS_CC); zend_highlight(syntax_highlighter_ini);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
zval_dtor(str); zval_dtor(str);
return SUCCESS; return SUCCESS;
} }
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC) ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding)
{ {
size_t length; size_t length;
unsigned char *new_yy_start; unsigned char *new_yy_start;
@ -833,7 +833,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
length = SCNG(script_org_size); length = SCNG(script_org_size);
new_yy_start = SCNG(script_org); new_yy_start = SCNG(script_org);
} else { } else {
if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -858,14 +858,14 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
if (SCNG(output_filter)) { \ if (SCNG(output_filter)) { \
size_t sz = 0; \ size_t sz = 0; \
char *s = NULL; \ char *s = NULL; \
SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); \ SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng); \
ZVAL_STRINGL(zendlval, s, sz); \ ZVAL_STRINGL(zendlval, s, sz); \
efree(s); \ efree(s); \
} else { \ } else { \
ZVAL_STRINGL(zendlval, yytext, yyleng); \ ZVAL_STRINGL(zendlval, yytext, yyleng); \
} }
static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type)
{ {
register char *s, *t; register char *s, *t;
char *end; char *end;
@ -980,7 +980,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
unsigned char *str; unsigned char *str;
// TODO: avoid realocation ??? // TODO: avoid realocation ???
s = Z_STRVAL_P(zendlval); s = Z_STRVAL_P(zendlval);
SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
zval_ptr_dtor(zendlval); zval_ptr_dtor(zendlval);
ZVAL_STRINGL(zendlval, (char *) str, sz); ZVAL_STRINGL(zendlval, (char *) str, sz);
efree(str); efree(str);
@ -988,7 +988,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
} }
int lex_scan(zval *zendlval TSRMLS_DC) int lex_scan(zval *zendlval)
{ {
restart: restart:
SCNG(yy_text) = YYCURSOR; SCNG(yy_text) = YYCURSOR;
@ -1081,7 +1081,7 @@ inline_char_handler:
char *s = NULL; char *s = NULL;
size_t sz = 0; size_t sz = 0;
// TODO: avoid reallocation ??? // TODO: avoid reallocation ???
readsize = SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); readsize = SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng);
ZVAL_STRINGL(zendlval, s, sz); ZVAL_STRINGL(zendlval, s, sz);
efree(s); efree(s);
if (readsize < yyleng) { if (readsize < yyleng) {
@ -1276,7 +1276,7 @@ yy19:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng, '`');
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
#line 1283 "Zend/zend_language_scanner.c" #line 1283 "Zend/zend_language_scanner.c"
@ -1308,7 +1308,7 @@ yy24:
#line 1975 "Zend/zend_language_scanner.l" #line 1975 "Zend/zend_language_scanner.l"
{ {
Z_LVAL_P(zendlval) = (zend_long) '{'; Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
yyless(1); yyless(1);
return T_CURLY_OPEN; return T_CURLY_OPEN;
} }
@ -1341,7 +1341,7 @@ yy29:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1464 "Zend/zend_language_scanner.l" #line 1464 "Zend/zend_language_scanner.l"
{ {
yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_VARNAME);
return T_DOLLAR_OPEN_CURLY_BRACES; return T_DOLLAR_OPEN_CURLY_BRACES;
} }
#line 1348 "Zend/zend_language_scanner.c" #line 1348 "Zend/zend_language_scanner.c"
@ -1361,7 +1361,7 @@ yy33:
#line 1691 "Zend/zend_language_scanner.l" #line 1691 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 1); yyless(yyleng - 1);
yy_push_state(ST_VAR_OFFSET TSRMLS_CC); yy_push_state(ST_VAR_OFFSET);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1386,7 +1386,7 @@ yy36:
#line 1682 "Zend/zend_language_scanner.l" #line 1682 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 3); yyless(yyleng - 3);
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1504,7 +1504,7 @@ yy41:
double_quotes_scan_done: double_quotes_scan_done:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng, '"');
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
#line 1511 "Zend/zend_language_scanner.c" #line 1511 "Zend/zend_language_scanner.c"
@ -1536,7 +1536,7 @@ yy46:
#line 1975 "Zend/zend_language_scanner.l" #line 1975 "Zend/zend_language_scanner.l"
{ {
Z_LVAL_P(zendlval) = (zend_long) '{'; Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
yyless(1); yyless(1);
return T_CURLY_OPEN; return T_CURLY_OPEN;
} }
@ -1569,7 +1569,7 @@ yy51:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1464 "Zend/zend_language_scanner.l" #line 1464 "Zend/zend_language_scanner.l"
{ {
yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_VARNAME);
return T_DOLLAR_OPEN_CURLY_BRACES; return T_DOLLAR_OPEN_CURLY_BRACES;
} }
#line 1576 "Zend/zend_language_scanner.c" #line 1576 "Zend/zend_language_scanner.c"
@ -1589,7 +1589,7 @@ yy55:
#line 1691 "Zend/zend_language_scanner.l" #line 1691 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 1); yyless(yyleng - 1);
yy_push_state(ST_VAR_OFFSET TSRMLS_CC); yy_push_state(ST_VAR_OFFSET);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1614,7 +1614,7 @@ yy58:
#line 1682 "Zend/zend_language_scanner.l" #line 1682 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 3); yyless(yyleng - 3);
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1774,7 +1774,7 @@ yy67:
heredoc_scan_done: heredoc_scan_done:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0);
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
#line 1781 "Zend/zend_language_scanner.c" #line 1781 "Zend/zend_language_scanner.c"
@ -1795,7 +1795,7 @@ yy70:
#line 1975 "Zend/zend_language_scanner.l" #line 1975 "Zend/zend_language_scanner.l"
{ {
Z_LVAL_P(zendlval) = (zend_long) '{'; Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
yyless(1); yyless(1);
return T_CURLY_OPEN; return T_CURLY_OPEN;
} }
@ -1828,7 +1828,7 @@ yy75:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1464 "Zend/zend_language_scanner.l" #line 1464 "Zend/zend_language_scanner.l"
{ {
yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_VARNAME);
return T_DOLLAR_OPEN_CURLY_BRACES; return T_DOLLAR_OPEN_CURLY_BRACES;
} }
#line 1835 "Zend/zend_language_scanner.c" #line 1835 "Zend/zend_language_scanner.c"
@ -1848,7 +1848,7 @@ yy79:
#line 1691 "Zend/zend_language_scanner.l" #line 1691 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 1); yyless(yyleng - 1);
yy_push_state(ST_VAR_OFFSET TSRMLS_CC); yy_push_state(ST_VAR_OFFSET);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1873,7 +1873,7 @@ yy82:
#line 1682 "Zend/zend_language_scanner.l" #line 1682 "Zend/zend_language_scanner.l"
{ {
yyless(yyleng - 3); yyless(yyleng - 3);
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -2561,7 +2561,7 @@ yy131:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1458 "Zend/zend_language_scanner.l" #line 1458 "Zend/zend_language_scanner.l"
{ {
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
return '{'; return '{';
} }
#line 2568 "Zend/zend_language_scanner.c" #line 2568 "Zend/zend_language_scanner.c"
@ -2574,7 +2574,7 @@ yy133:
{ {
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
if (!zend_stack_is_empty(&SCNG(state_stack))) { if (!zend_stack_is_empty(&SCNG(state_stack))) {
yy_pop_state(TSRMLS_C); yy_pop_state();
} }
return '}'; return '}';
} }
@ -2751,7 +2751,7 @@ yy142:
char *str = NULL; char *str = NULL;
s = Z_STRVAL_P(zendlval); s = Z_STRVAL_P(zendlval);
// TODO: avoid reallocation ??? // TODO: avoid reallocation ???
SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
ZVAL_STRINGL(zendlval, str, sz); ZVAL_STRINGL(zendlval, str, sz);
efree(s); efree(s);
} }
@ -2772,7 +2772,7 @@ yy144:
switch (*YYCURSOR++) { switch (*YYCURSOR++) {
case '"': case '"':
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"');
return T_CONSTANT_ENCAPSED_STRING; return T_CONSTANT_ENCAPSED_STRING;
case '$': case '$':
if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
@ -4768,7 +4768,7 @@ yy450:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1167 "Zend/zend_language_scanner.l" #line 1167 "Zend/zend_language_scanner.l"
{ {
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
return T_OBJECT_OPERATOR; return T_OBJECT_OPERATOR;
} }
#line 4775 "Zend/zend_language_scanner.c" #line 4775 "Zend/zend_language_scanner.c"
@ -6821,7 +6821,7 @@ yy765:
#line 1187 "Zend/zend_language_scanner.l" #line 1187 "Zend/zend_language_scanner.l"
{ {
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
goto restart; goto restart;
} }
#line 6828 "Zend/zend_language_scanner.c" #line 6828 "Zend/zend_language_scanner.c"
@ -6835,7 +6835,7 @@ yy767:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1181 "Zend/zend_language_scanner.l" #line 1181 "Zend/zend_language_scanner.l"
{ {
yy_pop_state(TSRMLS_C); yy_pop_state();
zend_copy_value(zendlval, yytext, yyleng); zend_copy_value(zendlval, yytext, yyleng);
return T_STRING; return T_STRING;
} }
@ -6952,8 +6952,8 @@ yy778:
#line 1488 "Zend/zend_language_scanner.l" #line 1488 "Zend/zend_language_scanner.l"
{ {
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
goto restart; goto restart;
} }
#line 6960 "Zend/zend_language_scanner.c" #line 6960 "Zend/zend_language_scanner.c"
@ -6985,8 +6985,8 @@ yy783:
{ {
yyless(yyleng - 1); yyless(yyleng - 1);
zend_copy_value(zendlval, yytext, yyleng); zend_copy_value(zendlval, yytext, yyleng);
yy_pop_state(TSRMLS_C); yy_pop_state();
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
return T_STRING_VARNAME; return T_STRING_VARNAME;
} }
#line 6993 "Zend/zend_language_scanner.c" #line 6993 "Zend/zend_language_scanner.c"
@ -7205,7 +7205,7 @@ yy796:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
#line 1703 "Zend/zend_language_scanner.l" #line 1703 "Zend/zend_language_scanner.l"
{ {
yy_pop_state(TSRMLS_C); yy_pop_state();
return ']'; return ']';
} }
#line 7212 "Zend/zend_language_scanner.c" #line 7212 "Zend/zend_language_scanner.c"
@ -7222,7 +7222,7 @@ yy799:
{ {
/* Invalid rule to return a more explicit parse error with proper line number */ /* Invalid rule to return a more explicit parse error with proper line number */
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
ZVAL_NULL(zendlval); ZVAL_NULL(zendlval);
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }

View file

@ -58,11 +58,11 @@ typedef struct _zend_heredoc_label {
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC); ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state);
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC); ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state);
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC); ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename);
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC); ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding);
ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC); ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding);
END_EXTERN_C() END_EXTERN_C()

View file

@ -123,34 +123,34 @@ do { \
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
ZEND_ASSERT(internal_encoding); ZEND_ASSERT(internal_encoding);
return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding) TSRMLS_CC); return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding));
} }
static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding) TSRMLS_CC); return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding));
} }
static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
return zend_multibyte_encoding_converter(to, to_length, from, from_length, return zend_multibyte_encoding_converter(to, to_length, from, from_length,
LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8 TSRMLS_CC); LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8);
} }
static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
ZEND_ASSERT(internal_encoding); ZEND_ASSERT(internal_encoding);
return zend_multibyte_encoding_converter(to, to_length, from, from_length, return zend_multibyte_encoding_converter(to, to_length, from, from_length,
internal_encoding, zend_multibyte_encoding_utf8 TSRMLS_CC); internal_encoding, zend_multibyte_encoding_utf8);
} }
static void _yy_push_state(int new_state TSRMLS_DC) static void _yy_push_state(int new_state)
{ {
zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION()); zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
YYSETCONDITION(new_state); YYSETCONDITION(new_state);
@ -158,14 +158,14 @@ static void _yy_push_state(int new_state TSRMLS_DC)
#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
static void yy_pop_state(TSRMLS_D) static void yy_pop_state(void)
{ {
int *stack_state = zend_stack_top(&SCNG(state_stack)); int *stack_state = zend_stack_top(&SCNG(state_stack));
YYSETCONDITION(*stack_state); YYSETCONDITION(*stack_state);
zend_stack_del_top(&SCNG(state_stack)); zend_stack_del_top(&SCNG(state_stack));
} }
static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) static void yy_scan_buffer(char *str, unsigned int len)
{ {
YYCURSOR = (YYCTYPE*)str; YYCURSOR = (YYCTYPE*)str;
YYLIMIT = YYCURSOR + len; YYLIMIT = YYCURSOR + len;
@ -174,7 +174,7 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
} }
} }
void startup_scanner(TSRMLS_D) void startup_scanner(void)
{ {
CG(parse_error) = 0; CG(parse_error) = 0;
CG(doc_comment) = NULL; CG(doc_comment) = NULL;
@ -186,7 +186,7 @@ static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) {
efree(heredoc_label->label); efree(heredoc_label->label);
} }
void shutdown_scanner(TSRMLS_D) void shutdown_scanner(void)
{ {
CG(parse_error) = 0; CG(parse_error) = 0;
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
@ -195,7 +195,7 @@ void shutdown_scanner(TSRMLS_D)
zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); zend_ptr_stack_destroy(&SCNG(heredoc_label_stack));
} }
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state)
{ {
lex_state->yy_leng = SCNG(yy_leng); lex_state->yy_leng = SCNG(yy_leng);
lex_state->yy_start = SCNG(yy_start); lex_state->yy_start = SCNG(yy_start);
@ -212,7 +212,7 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
lex_state->in = SCNG(yy_in); lex_state->in = SCNG(yy_in);
lex_state->yy_state = YYSTATE; lex_state->yy_state = YYSTATE;
lex_state->filename = zend_get_compiled_filename(TSRMLS_C); lex_state->filename = zend_get_compiled_filename();
lex_state->lineno = CG(zend_lineno); lex_state->lineno = CG(zend_lineno);
lex_state->script_org = SCNG(script_org); lex_state->script_org = SCNG(script_org);
@ -224,7 +224,7 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
lex_state->script_encoding = SCNG(script_encoding); lex_state->script_encoding = SCNG(script_encoding);
} }
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state)
{ {
SCNG(yy_leng) = lex_state->yy_leng; SCNG(yy_leng) = lex_state->yy_leng;
SCNG(yy_start) = lex_state->yy_start; SCNG(yy_start) = lex_state->yy_start;
@ -243,7 +243,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
SCNG(yy_in) = lex_state->in; SCNG(yy_in) = lex_state->in;
YYSETCONDITION(lex_state->yy_state); YYSETCONDITION(lex_state->yy_state);
CG(zend_lineno) = lex_state->lineno; CG(zend_lineno) = lex_state->lineno;
zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); zend_restore_compiled_filename(lex_state->filename);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
@ -260,7 +260,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
} }
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
{ {
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles); zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
/* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */ /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
@ -276,7 +276,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
#define BOM_UTF16_LE "\xff\xfe" #define BOM_UTF16_LE "\xff\xfe"
#define BOM_UTF8 "\xef\xbb\xbf" #define BOM_UTF8 "\xef\xbb\xbf"
static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size TSRMLS_DC) static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size)
{ {
const unsigned char *p; const unsigned char *p;
int wchar_size = 2; int wchar_size = 2;
@ -324,7 +324,7 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch
return NULL; return NULL;
} }
static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D) static const zend_encoding* zend_multibyte_detect_unicode(void)
{ {
const zend_encoding *script_encoding = NULL; const zend_encoding *script_encoding = NULL;
int bom_size; int bom_size;
@ -401,19 +401,19 @@ static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D)
} }
} }
/* make best effort if BOM is missing */ /* make best effort if BOM is missing */
return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size) TSRMLS_CC); return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size));
} }
return NULL; return NULL;
} }
static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D) static const zend_encoding* zend_multibyte_find_script_encoding(void)
{ {
const zend_encoding *script_encoding; const zend_encoding *script_encoding;
if (CG(detect_unicode)) { if (CG(detect_unicode)) {
/* check out bom(byte order mark) and see if containing wchars */ /* check out bom(byte order mark) and see if containing wchars */
script_encoding = zend_multibyte_detect_unicode(TSRMLS_C); script_encoding = zend_multibyte_detect_unicode();
if (script_encoding != NULL) { if (script_encoding != NULL) {
/* bom or wchar detection is prior to 'script_encoding' option */ /* bom or wchar detection is prior to 'script_encoding' option */
return script_encoding; return script_encoding;
@ -427,16 +427,16 @@ static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D)
/* if multiple encodings specified, detect automagically */ /* if multiple encodings specified, detect automagically */
if (CG(script_encoding_list_size) > 1) { if (CG(script_encoding_list_size) > 1) {
return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size) TSRMLS_CC); return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size));
} }
return CG(script_encoding_list)[0]; return CG(script_encoding_list)[0];
} }
ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC) ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding)
{ {
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(TSRMLS_C); const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding();
if (!script_encoding) { if (!script_encoding) {
return FAILURE; return FAILURE;
@ -474,7 +474,7 @@ ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSR
return 0; return 0;
} }
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
{ {
const char *file_path = NULL; const char *file_path = NULL;
char *buf; char *buf;
@ -488,7 +488,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
} }
if (zend_stream_fixup(file_handle, &buf, &size TSRMLS_CC) == FAILURE) { if (zend_stream_fixup(file_handle, &buf, &size) == FAILURE) {
return FAILURE; return FAILURE;
} }
@ -510,10 +510,10 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
SCNG(script_org_size) = size; SCNG(script_org_size) = size;
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
zend_multibyte_set_filter(NULL TSRMLS_CC); zend_multibyte_set_filter(NULL);
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -522,7 +522,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
} }
SCNG(yy_start) = (unsigned char *)buf - offset; SCNG(yy_start) = (unsigned char *)buf - offset;
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
} else { } else {
zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
} }
@ -536,7 +536,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
} }
compiled_filename = zend_string_init(file_path, strlen(file_path), 0); compiled_filename = zend_string_init(file_path, strlen(file_path), 0);
zend_set_compiled_filename(compiled_filename TSRMLS_CC); zend_set_compiled_filename(compiled_filename);
zend_string_release(compiled_filename); zend_string_release(compiled_filename);
if (CG(start_lineno)) { if (CG(start_lineno)) {
@ -553,7 +553,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
END_EXTERN_C() END_EXTERN_C()
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
@ -565,51 +565,51 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR
ZVAL_LONG(&retval_zv, 1); ZVAL_LONG(&retval_zv, 1);
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) { if (open_file_for_scanning(file_handle)==FAILURE) {
if (type==ZEND_REQUIRE) { if (type==ZEND_REQUIRE) {
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
zend_bailout(); zend_bailout();
} else { } else {
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
} }
compilation_successful=0; compilation_successful=0;
} else { } else {
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE);
CG(in_compilation) = 1; CG(in_compilation) = 1;
CG(active_op_array) = op_array; CG(active_op_array) = op_array;
zend_stack_push(&CG(context_stack), (void *) &CG(context)); zend_stack_push(&CG(context_stack), (void *) &CG(context));
zend_init_compiler_context(TSRMLS_C); zend_init_compiler_context();
CG(ast_arena) = zend_arena_create(1024 * 32); CG(ast_arena) = zend_arena_create(1024 * 32);
compiler_result = zendparse(TSRMLS_C); compiler_result = zendparse();
if (compiler_result != 0) { /* parser error */ if (compiler_result != 0) { /* parser error */
zend_bailout(); zend_bailout();
} }
zend_compile_top_stmt(CG(ast) TSRMLS_CC); zend_compile_top_stmt(CG(ast));
zend_ast_destroy(CG(ast)); zend_ast_destroy(CG(ast));
zend_arena_destroy(CG(ast_arena)); zend_arena_destroy(CG(ast_arena));
zend_do_end_compilation(TSRMLS_C); zend_do_end_compilation();
zend_emit_final_return(&retval_zv TSRMLS_CC); zend_emit_final_return(&retval_zv);
CG(in_compilation) = original_in_compilation; CG(in_compilation) = original_in_compilation;
compilation_successful=1; compilation_successful=1;
} }
CG(active_op_array) = original_active_op_array; CG(active_op_array) = original_active_op_array;
if (compilation_successful) { if (compilation_successful) {
pass_two(op_array TSRMLS_CC); pass_two(op_array);
zend_release_labels(0 TSRMLS_CC); zend_release_labels(0);
} else { } else {
efree_size(op_array, sizeof(zend_op_array)); efree_size(op_array, sizeof(zend_op_array));
op_array = NULL; op_array = NULL;
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return op_array; return op_array;
} }
zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) zend_op_array *compile_filename(int type, zval *filename)
{ {
zend_file_handle file_handle; zend_file_handle file_handle;
zval tmp; zval tmp;
@ -628,7 +628,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
file_handle.opened_path = NULL; file_handle.opened_path = NULL;
file_handle.handle.fp = NULL; file_handle.handle.fp = NULL;
retval = zend_compile_file(&file_handle, type TSRMLS_CC); retval = zend_compile_file(&file_handle, type);
if (retval && file_handle.handle.stream.handle) { if (retval && file_handle.handle.stream.handle) {
if (!file_handle.opened_path) { if (!file_handle.opened_path) {
file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename)); file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename));
@ -640,7 +640,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
efree(opened_path); efree(opened_path);
} }
} }
zend_destroy_file_handle(&file_handle TSRMLS_CC); zend_destroy_file_handle(&file_handle);
if (filename==&tmp) { if (filename==&tmp) {
zval_dtor(&tmp); zval_dtor(&tmp);
@ -648,7 +648,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
return retval; return retval;
} }
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename)
{ {
char *buf; char *buf;
size_t size, old_len; size_t size, old_len;
@ -671,10 +671,10 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
SCNG(script_org_size) = size; SCNG(script_org_size) = size;
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
zend_multibyte_set_filter(zend_multibyte_get_internal_encoding(TSRMLS_C) TSRMLS_CC); zend_multibyte_set_filter(zend_multibyte_get_internal_encoding());
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -683,10 +683,10 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
} }
} }
yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); yy_scan_buffer(buf, (unsigned int)size);
new_compiled_filename = zend_string_init(filename, strlen(filename), 0); new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
zend_set_compiled_filename(new_compiled_filename TSRMLS_CC); zend_set_compiled_filename(new_compiled_filename);
zend_string_release(new_compiled_filename); zend_string_release(new_compiled_filename);
CG(zend_lineno) = 1; CG(zend_lineno) = 1;
CG(increment_lineno) = 0; CG(increment_lineno) = 0;
@ -695,14 +695,14 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
} }
ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D) ZEND_API size_t zend_get_scanned_file_offset(void)
{ {
size_t offset = SCNG(yy_cursor) - SCNG(yy_start); size_t offset = SCNG(yy_cursor) - SCNG(yy_start);
if (SCNG(input_filter)) { if (SCNG(input_filter)) {
size_t original_offset = offset, length = 0; size_t original_offset = offset, length = 0;
do { do {
unsigned char *p = NULL; unsigned char *p = NULL;
if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset)) {
return (size_t)-1; return (size_t)-1;
} }
efree(p); efree(p);
@ -717,7 +717,7 @@ ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D)
} }
zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) zend_op_array *compile_string(zval *source_string, char *filename)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_op_array *op_array = NULL; zend_op_array *op_array = NULL;
@ -733,25 +733,25 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
source_string = &tmp; source_string = &tmp;
CG(in_compilation) = 1; CG(in_compilation) = 1;
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC) == SUCCESS) { if (zend_prepare_string_for_scanning(source_string, filename) == SUCCESS) {
CG(ast) = NULL; CG(ast) = NULL;
CG(ast_arena) = zend_arena_create(1024 * 32); CG(ast_arena) = zend_arena_create(1024 * 32);
BEGIN(ST_IN_SCRIPTING); BEGIN(ST_IN_SCRIPTING);
if (!zendparse(TSRMLS_C)) { if (!zendparse()) {
zend_op_array *original_active_op_array = CG(active_op_array); zend_op_array *original_active_op_array = CG(active_op_array);
op_array = emalloc(sizeof(zend_op_array)); op_array = emalloc(sizeof(zend_op_array));
init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE);
CG(active_op_array) = op_array; CG(active_op_array) = op_array;
zend_stack_push(&CG(context_stack), (void *) &CG(context)); zend_stack_push(&CG(context_stack), (void *) &CG(context));
zend_init_compiler_context(TSRMLS_C); zend_init_compiler_context();
zend_compile_top_stmt(CG(ast) TSRMLS_CC); zend_compile_top_stmt(CG(ast));
zend_do_end_compilation(TSRMLS_C); zend_do_end_compilation();
zend_emit_final_return(NULL TSRMLS_CC); zend_emit_final_return(NULL);
pass_two(op_array TSRMLS_CC); pass_two(op_array);
zend_release_labels(0 TSRMLS_CC); zend_release_labels(0);
CG(active_op_array) = original_active_op_array; CG(active_op_array) = original_active_op_array;
} }
@ -760,7 +760,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
zend_arena_destroy(CG(ast_arena)); zend_arena_destroy(CG(ast_arena));
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
zval_dtor(&tmp); zval_dtor(&tmp);
CG(in_compilation) = original_in_compilation; CG(in_compilation) = original_in_compilation;
return op_array; return op_array;
@ -768,7 +768,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zend_file_handle file_handle; zend_file_handle file_handle;
@ -777,46 +777,46 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
file_handle.filename = filename; file_handle.filename = filename;
file_handle.free_filename = 0; file_handle.free_filename = 0;
file_handle.opened_path = NULL; file_handle.opened_path = NULL;
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) { if (open_file_for_scanning(&file_handle)==FAILURE) {
zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename TSRMLS_CC); zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return FAILURE; return FAILURE;
} }
zend_highlight(syntax_highlighter_ini TSRMLS_CC); zend_highlight(syntax_highlighter_ini);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
} }
zend_destroy_file_handle(&file_handle TSRMLS_CC); zend_destroy_file_handle(&file_handle);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return SUCCESS; return SUCCESS;
} }
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC) int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name)
{ {
zend_lex_state original_lex_state; zend_lex_state original_lex_state;
zval tmp = *str; zval tmp = *str;
str = &tmp; str = &tmp;
zval_copy_ctor(str); zval_copy_ctor(str);
zend_save_lexical_state(&original_lex_state TSRMLS_CC); zend_save_lexical_state(&original_lex_state);
if (zend_prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) { if (zend_prepare_string_for_scanning(str, str_name)==FAILURE) {
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
return FAILURE; return FAILURE;
} }
BEGIN(INITIAL); BEGIN(INITIAL);
zend_highlight(syntax_highlighter_ini TSRMLS_CC); zend_highlight(syntax_highlighter_ini);
if (SCNG(script_filtered)) { if (SCNG(script_filtered)) {
efree(SCNG(script_filtered)); efree(SCNG(script_filtered));
SCNG(script_filtered) = NULL; SCNG(script_filtered) = NULL;
} }
zend_restore_lexical_state(&original_lex_state TSRMLS_CC); zend_restore_lexical_state(&original_lex_state);
zval_dtor(str); zval_dtor(str);
return SUCCESS; return SUCCESS;
} }
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC) ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding)
{ {
size_t length; size_t length;
unsigned char *new_yy_start; unsigned char *new_yy_start;
@ -831,7 +831,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
length = SCNG(script_org_size); length = SCNG(script_org_size);
new_yy_start = SCNG(script_org); new_yy_start = SCNG(script_org);
} else { } else {
if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size))) {
zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
"encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
} }
@ -856,14 +856,14 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
if (SCNG(output_filter)) { \ if (SCNG(output_filter)) { \
size_t sz = 0; \ size_t sz = 0; \
char *s = NULL; \ char *s = NULL; \
SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); \ SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng); \
ZVAL_STRINGL(zendlval, s, sz); \ ZVAL_STRINGL(zendlval, s, sz); \
efree(s); \ efree(s); \
} else { \ } else { \
ZVAL_STRINGL(zendlval, yytext, yyleng); \ ZVAL_STRINGL(zendlval, yytext, yyleng); \
} }
static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type)
{ {
register char *s, *t; register char *s, *t;
char *end; char *end;
@ -978,7 +978,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
unsigned char *str; unsigned char *str;
// TODO: avoid realocation ??? // TODO: avoid realocation ???
s = Z_STRVAL_P(zendlval); s = Z_STRVAL_P(zendlval);
SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
zval_ptr_dtor(zendlval); zval_ptr_dtor(zendlval);
ZVAL_STRINGL(zendlval, (char *) str, sz); ZVAL_STRINGL(zendlval, (char *) str, sz);
efree(str); efree(str);
@ -986,7 +986,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
} }
int lex_scan(zval *zendlval TSRMLS_DC) int lex_scan(zval *zendlval)
{ {
restart: restart:
SCNG(yy_text) = YYCURSOR; SCNG(yy_text) = YYCURSOR;
@ -1165,7 +1165,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
} }
<ST_IN_SCRIPTING>"->" { <ST_IN_SCRIPTING>"->" {
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
return T_OBJECT_OPERATOR; return T_OBJECT_OPERATOR;
} }
@ -1179,14 +1179,14 @@ NEWLINE ("\r"|"\n"|"\r\n")
} }
<ST_LOOKING_FOR_PROPERTY>{LABEL} { <ST_LOOKING_FOR_PROPERTY>{LABEL} {
yy_pop_state(TSRMLS_C); yy_pop_state();
zend_copy_value(zendlval, yytext, yyleng); zend_copy_value(zendlval, yytext, yyleng);
return T_STRING; return T_STRING;
} }
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} { <ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
goto restart; goto restart;
} }
@ -1456,13 +1456,13 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>"{" { <ST_IN_SCRIPTING>"{" {
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
return '{'; return '{';
} }
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" { <ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" {
yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_VARNAME);
return T_DOLLAR_OPEN_CURLY_BRACES; return T_DOLLAR_OPEN_CURLY_BRACES;
} }
@ -1470,7 +1470,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>"}" { <ST_IN_SCRIPTING>"}" {
RESET_DOC_COMMENT(); RESET_DOC_COMMENT();
if (!zend_stack_is_empty(&SCNG(state_stack))) { if (!zend_stack_is_empty(&SCNG(state_stack))) {
yy_pop_state(TSRMLS_C); yy_pop_state();
} }
return '}'; return '}';
} }
@ -1479,16 +1479,16 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_LOOKING_FOR_VARNAME>{LABEL}[[}] { <ST_LOOKING_FOR_VARNAME>{LABEL}[[}] {
yyless(yyleng - 1); yyless(yyleng - 1);
zend_copy_value(zendlval, yytext, yyleng); zend_copy_value(zendlval, yytext, yyleng);
yy_pop_state(TSRMLS_C); yy_pop_state();
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
return T_STRING_VARNAME; return T_STRING_VARNAME;
} }
<ST_LOOKING_FOR_VARNAME>{ANY_CHAR} { <ST_LOOKING_FOR_VARNAME>{ANY_CHAR} {
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
goto restart; goto restart;
} }
@ -1662,7 +1662,7 @@ inline_char_handler:
char *s = NULL; char *s = NULL;
size_t sz = 0; size_t sz = 0;
// TODO: avoid reallocation ??? // TODO: avoid reallocation ???
readsize = SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); readsize = SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng);
ZVAL_STRINGL(zendlval, s, sz); ZVAL_STRINGL(zendlval, s, sz);
efree(s); efree(s);
if (readsize < yyleng) { if (readsize < yyleng) {
@ -1681,7 +1681,7 @@ inline_char_handler:
*/ */
<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"->"[a-zA-Z_\x7f-\xff] { <ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"->"[a-zA-Z_\x7f-\xff] {
yyless(yyleng - 3); yyless(yyleng - 3);
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); yy_push_state(ST_LOOKING_FOR_PROPERTY);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1690,7 +1690,7 @@ inline_char_handler:
*/ */
<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"[" { <ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"[" {
yyless(yyleng - 1); yyless(yyleng - 1);
yy_push_state(ST_VAR_OFFSET TSRMLS_CC); yy_push_state(ST_VAR_OFFSET);
zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zend_copy_value(zendlval, (yytext+1), (yyleng-1));
return T_VARIABLE; return T_VARIABLE;
} }
@ -1701,7 +1701,7 @@ inline_char_handler:
} }
<ST_VAR_OFFSET>"]" { <ST_VAR_OFFSET>"]" {
yy_pop_state(TSRMLS_C); yy_pop_state();
return ']'; return ']';
} }
@ -1713,7 +1713,7 @@ inline_char_handler:
<ST_VAR_OFFSET>[ \n\r\t\\'#] { <ST_VAR_OFFSET>[ \n\r\t\\'#] {
/* Invalid rule to return a more explicit parse error with proper line number */ /* Invalid rule to return a more explicit parse error with proper line number */
yyless(0); yyless(0);
yy_pop_state(TSRMLS_C); yy_pop_state();
ZVAL_NULL(zendlval); ZVAL_NULL(zendlval);
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
@ -1854,7 +1854,7 @@ inline_char_handler:
char *str = NULL; char *str = NULL;
s = Z_STRVAL_P(zendlval); s = Z_STRVAL_P(zendlval);
// TODO: avoid reallocation ??? // TODO: avoid reallocation ???
SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
ZVAL_STRINGL(zendlval, str, sz); ZVAL_STRINGL(zendlval, str, sz);
efree(s); efree(s);
} }
@ -1869,7 +1869,7 @@ inline_char_handler:
switch (*YYCURSOR++) { switch (*YYCURSOR++) {
case '"': case '"':
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"');
return T_CONSTANT_ENCAPSED_STRING; return T_CONSTANT_ENCAPSED_STRING;
case '$': case '$':
if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
@ -1974,7 +1974,7 @@ inline_char_handler:
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" { <ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" {
Z_LVAL_P(zendlval) = (zend_long) '{'; Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yy_push_state(ST_IN_SCRIPTING);
yyless(1); yyless(1);
return T_CURLY_OPEN; return T_CURLY_OPEN;
} }
@ -2036,7 +2036,7 @@ inline_char_handler:
double_quotes_scan_done: double_quotes_scan_done:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng, '"');
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
@ -2078,7 +2078,7 @@ double_quotes_scan_done:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng, '`');
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }
@ -2152,7 +2152,7 @@ double_quotes_scan_done:
heredoc_scan_done: heredoc_scan_done:
yyleng = YYCURSOR - SCNG(yy_text); yyleng = YYCURSOR - SCNG(yy_text);
zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0);
return T_ENCAPSED_AND_WHITESPACE; return T_ENCAPSED_AND_WHITESPACE;
} }

View file

@ -31,7 +31,7 @@ ZEND_API int le_index_ptr;
/* true global */ /* true global */
static HashTable list_destructors; static HashTable list_destructors;
ZEND_API zval *zend_list_insert(void *ptr, int type TSRMLS_DC) ZEND_API zval *zend_list_insert(void *ptr, int type)
{ {
int index; int index;
zval zv; zval zv;
@ -44,7 +44,7 @@ ZEND_API zval *zend_list_insert(void *ptr, int type TSRMLS_DC)
return zend_hash_index_add_new(&EG(regular_list), index, &zv); return zend_hash_index_add_new(&EG(regular_list), index, &zv);
} }
ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC) ZEND_API int _zend_list_delete(zend_resource *res)
{ {
if (--GC_REFCOUNT(res) <= 0) { if (--GC_REFCOUNT(res) <= 0) {
return zend_hash_index_del(&EG(regular_list), res->handle); return zend_hash_index_del(&EG(regular_list), res->handle);
@ -53,7 +53,7 @@ ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC)
} }
} }
ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC) ZEND_API int _zend_list_free(zend_resource *res)
{ {
if (GC_REFCOUNT(res) <= 0) { if (GC_REFCOUNT(res) <= 0) {
return zend_hash_index_del(&EG(regular_list), res->handle); return zend_hash_index_del(&EG(regular_list), res->handle);
@ -62,14 +62,14 @@ ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC)
} }
} }
static void zend_resource_dtor(zend_resource *res TSRMLS_DC) static void zend_resource_dtor(zend_resource *res)
{ {
zend_rsrc_list_dtors_entry *ld; zend_rsrc_list_dtors_entry *ld;
ld = zend_hash_index_find_ptr(&list_destructors, res->type); ld = zend_hash_index_find_ptr(&list_destructors, res->type);
if (ld) { if (ld) {
if (ld->list_dtor_ex) { if (ld->list_dtor_ex) {
ld->list_dtor_ex(res TSRMLS_CC); ld->list_dtor_ex(res);
} }
} else { } else {
zend_error(E_WARNING,"Unknown list entry type (%d)", res->type); zend_error(E_WARNING,"Unknown list entry type (%d)", res->type);
@ -79,21 +79,21 @@ static void zend_resource_dtor(zend_resource *res TSRMLS_DC)
} }
ZEND_API int _zend_list_close(zend_resource *res TSRMLS_DC) ZEND_API int _zend_list_close(zend_resource *res)
{ {
if (GC_REFCOUNT(res) <= 0) { if (GC_REFCOUNT(res) <= 0) {
return zend_list_delete(res); return zend_list_delete(res);
} else if (res->type >= 0) { } else if (res->type >= 0) {
zend_resource_dtor(res TSRMLS_CC); zend_resource_dtor(res);
} }
return SUCCESS; return SUCCESS;
} }
ZEND_API zend_resource* zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC) ZEND_API zend_resource* zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type)
{ {
zval *zv; zval *zv;
zv = zend_list_insert(rsrc_pointer, rsrc_type TSRMLS_CC); zv = zend_list_insert(rsrc_pointer, rsrc_type);
if (rsrc_result) { if (rsrc_result) {
ZVAL_COPY_VALUE(rsrc_result, zv); ZVAL_COPY_VALUE(rsrc_result, zv);
@ -103,7 +103,7 @@ ZEND_API zend_resource* zend_register_resource(zval *rsrc_result, void *rsrc_poi
} }
} }
ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...) ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...)
{ {
int actual_resource_type; int actual_resource_type;
// void *resource; // void *resource;
@ -116,14 +116,14 @@ ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, co
if (default_id==-1) { /* use id */ if (default_id==-1) { /* use id */
if (!passed_id) { if (!passed_id) {
if (resource_type_name) { if (resource_type_name) {
class_name = get_active_class_name(&space TSRMLS_CC); class_name = get_active_class_name(&space);
zend_error(E_WARNING, "%s%s%s(): no %s resource supplied", class_name, space, get_active_function_name(TSRMLS_C), resource_type_name); zend_error(E_WARNING, "%s%s%s(): no %s resource supplied", class_name, space, get_active_function_name(), resource_type_name);
} }
return NULL; return NULL;
} else if (Z_TYPE_P(passed_id) != IS_RESOURCE) { } else if (Z_TYPE_P(passed_id) != IS_RESOURCE) {
if (resource_type_name) { if (resource_type_name) {
class_name = get_active_class_name(&space TSRMLS_CC); class_name = get_active_class_name(&space);
zend_error(E_WARNING, "%s%s%s(): supplied argument is not a valid %s resource", class_name, space, get_active_function_name(TSRMLS_C), resource_type_name); zend_error(E_WARNING, "%s%s%s(): supplied argument is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
} }
return NULL; return NULL;
} }
@ -131,8 +131,8 @@ ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, co
passed_id = zend_hash_index_find(&EG(regular_list), default_id); passed_id = zend_hash_index_find(&EG(regular_list), default_id);
if (!passed_id) { if (!passed_id) {
if (resource_type_name) { if (resource_type_name) {
class_name = get_active_class_name(&space TSRMLS_CC); class_name = get_active_class_name(&space);
zend_error(E_WARNING, "%s%s%s(): %d is not a valid %s resource", class_name, space, get_active_function_name(TSRMLS_C), default_id, resource_type_name); zend_error(E_WARNING, "%s%s%s(): %d is not a valid %s resource", class_name, space, get_active_function_name(), default_id, resource_type_name);
} }
return NULL; return NULL;
} }
@ -153,8 +153,8 @@ ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, co
va_end(resource_types); va_end(resource_types);
if (resource_type_name) { if (resource_type_name) {
class_name = get_active_class_name(&space TSRMLS_CC); class_name = get_active_class_name(&space);
zend_error(E_WARNING, "%s%s%s(): supplied resource is not a valid %s resource", class_name, space, get_active_function_name(TSRMLS_C), resource_type_name); zend_error(E_WARNING, "%s%s%s(): supplied resource is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
} }
return NULL; return NULL;
@ -165,9 +165,8 @@ void list_entry_destructor(zval *zv)
zend_resource *res = Z_RES_P(zv); zend_resource *res = Z_RES_P(zv);
if (res->type >= 0) { if (res->type >= 0) {
TSRMLS_FETCH();
zend_resource_dtor(res);
zend_resource_dtor(res TSRMLS_CC);
} }
efree_size(res, sizeof(zend_resource)); efree_size(res, sizeof(zend_resource));
} }
@ -178,12 +177,11 @@ void plist_entry_destructor(zval *zv)
if (res->type >= 0) { if (res->type >= 0) {
zend_rsrc_list_dtors_entry *ld; zend_rsrc_list_dtors_entry *ld;
TSRMLS_FETCH();
ld = zend_hash_index_find_ptr(&list_destructors, res->type); ld = zend_hash_index_find_ptr(&list_destructors, res->type);
if (ld) { if (ld) {
if (ld->plist_dtor_ex) { if (ld->plist_dtor_ex) {
ld->plist_dtor_ex(res TSRMLS_CC); ld->plist_dtor_ex(res);
} }
} else { } else {
zend_error(E_WARNING,"Unknown list entry type (%d)", res->type); zend_error(E_WARNING,"Unknown list entry type (%d)", res->type);
@ -192,43 +190,43 @@ void plist_entry_destructor(zval *zv)
free(res); free(res);
} }
int zend_init_rsrc_list(TSRMLS_D) int zend_init_rsrc_list(void)
{ {
zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0); zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0);
return SUCCESS; return SUCCESS;
} }
int zend_init_rsrc_plist(TSRMLS_D) int zend_init_rsrc_plist(void)
{ {
zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0); zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0);
return SUCCESS; return SUCCESS;
} }
static int zend_close_rsrc(zval *zv TSRMLS_DC) static int zend_close_rsrc(zval *zv)
{ {
zend_resource *res = Z_PTR_P(zv); zend_resource *res = Z_PTR_P(zv);
if (res->type >= 0) { if (res->type >= 0) {
zend_resource_dtor(res TSRMLS_CC); zend_resource_dtor(res);
} }
return ZEND_HASH_APPLY_KEEP; return ZEND_HASH_APPLY_KEEP;
} }
void zend_close_rsrc_list(HashTable *ht TSRMLS_DC) void zend_close_rsrc_list(HashTable *ht)
{ {
zend_hash_reverse_apply(ht, zend_close_rsrc TSRMLS_CC); zend_hash_reverse_apply(ht, zend_close_rsrc);
} }
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC) void zend_destroy_rsrc_list(HashTable *ht)
{ {
zend_hash_graceful_reverse_destroy(ht); zend_hash_graceful_reverse_destroy(ht);
} }
static int clean_module_resource(zval *zv, void *arg TSRMLS_DC) static int clean_module_resource(zval *zv, void *arg)
{ {
int resource_id = *(int *)arg; int resource_id = *(int *)arg;
if (Z_RES_TYPE_P(zv) == resource_id) { if (Z_RES_TYPE_P(zv) == resource_id) {
@ -239,12 +237,12 @@ static int clean_module_resource(zval *zv, void *arg TSRMLS_DC)
} }
static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg TSRMLS_DC) static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg)
{ {
zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv); zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv);
int module_number = *(int *)arg; int module_number = *(int *)arg;
if (ld->module_number == module_number) { if (ld->module_number == module_number) {
zend_hash_apply_with_argument(&EG(persistent_list), clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); zend_hash_apply_with_argument(&EG(persistent_list), clean_module_resource, (void *) &(ld->resource_id));
return 1; return 1;
} else { } else {
return 0; return 0;
@ -252,9 +250,9 @@ static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg TSRMLS_DC)
} }
void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC) void zend_clean_module_rsrc_dtors(int module_number)
{ {
zend_hash_apply_with_argument(&list_destructors, zend_clean_module_rsrc_dtors_cb, (void *) &module_number TSRMLS_CC); zend_hash_apply_with_argument(&list_destructors, zend_clean_module_rsrc_dtors_cb, (void *) &module_number);
} }
@ -309,7 +307,7 @@ void zend_destroy_rsrc_list_dtors(void)
} }
const char *zend_rsrc_list_get_rsrc_type(zend_resource *res TSRMLS_DC) const char *zend_rsrc_list_get_rsrc_type(zend_resource *res)
{ {
zend_rsrc_list_dtors_entry *lde; zend_rsrc_list_dtors_entry *lde;

View file

@ -27,8 +27,8 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
typedef void (*rsrc_dtor_func_t)(zend_resource *res TSRMLS_DC); typedef void (*rsrc_dtor_func_t)(zend_resource *res);
#define ZEND_RSRC_DTOR_FUNC(name) void name(zend_resource *res TSRMLS_DC) #define ZEND_RSRC_DTOR_FUNC(name) void name(zend_resource *res)
typedef struct _zend_rsrc_list_dtors_entry { typedef struct _zend_rsrc_list_dtors_entry {
rsrc_dtor_func_t list_dtor_ex; rsrc_dtor_func_t list_dtor_ex;
@ -46,27 +46,27 @@ ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_fu
void list_entry_destructor(zval *ptr); void list_entry_destructor(zval *ptr);
void plist_entry_destructor(zval *ptr); void plist_entry_destructor(zval *ptr);
void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC); void zend_clean_module_rsrc_dtors(int module_number);
int zend_init_rsrc_list(TSRMLS_D); int zend_init_rsrc_list(void);
int zend_init_rsrc_plist(TSRMLS_D); int zend_init_rsrc_plist(void);
void zend_close_rsrc_list(HashTable *ht TSRMLS_DC); void zend_close_rsrc_list(HashTable *ht);
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC); void zend_destroy_rsrc_list(HashTable *ht);
int zend_init_rsrc_list_dtors(void); int zend_init_rsrc_list_dtors(void);
void zend_destroy_rsrc_list_dtors(void); void zend_destroy_rsrc_list_dtors(void);
ZEND_API zval *zend_list_insert(void *ptr, int type TSRMLS_DC); ZEND_API zval *zend_list_insert(void *ptr, int type);
ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC); ZEND_API int _zend_list_free(zend_resource *res);
ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC); ZEND_API int _zend_list_delete(zend_resource *res);
ZEND_API int _zend_list_close(zend_resource *res TSRMLS_DC); ZEND_API int _zend_list_close(zend_resource *res);
#define zend_list_free(res) _zend_list_free(res TSRMLS_CC) #define zend_list_free(res) _zend_list_free(res)
#define zend_list_delete(res) _zend_list_delete(res TSRMLS_CC) #define zend_list_delete(res) _zend_list_delete(res)
#define zend_list_close(res) _zend_list_close(res TSRMLS_CC) #define zend_list_close(res) _zend_list_close(res)
ZEND_API zend_resource *zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC); ZEND_API zend_resource *zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...); ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
ZEND_API const char *zend_rsrc_list_get_rsrc_type(zend_resource *res TSRMLS_DC); ZEND_API const char *zend_rsrc_list_get_rsrc_type(zend_resource *res);
ZEND_API int zend_fetch_list_dtor_id(const char *type_name); ZEND_API int zend_fetch_list_dtor_id(const char *type_name);
extern ZEND_API int le_index_ptr; /* list entry type for index pointers */ extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
@ -77,21 +77,21 @@ extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
} }
#define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \ #define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type); \ rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type); \
ZEND_VERIFY_RESOURCE(rsrc); ZEND_VERIFY_RESOURCE(rsrc);
#define ZEND_FETCH_RESOURCE_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \ #define ZEND_FETCH_RESOURCE_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
(rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type)) (rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type))
#define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \ #define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2); \ rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2); \
ZEND_VERIFY_RESOURCE(rsrc); ZEND_VERIFY_RESOURCE(rsrc);
#define ZEND_FETCH_RESOURCE2_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \ #define ZEND_FETCH_RESOURCE2_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \
(rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2)) (rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2))
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) \ #define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) \
zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type TSRMLS_CC); zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
#define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \ #define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
if (le_id == 0) { \ if (le_id == 0) { \

View file

@ -177,16 +177,16 @@ ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data))
} }
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC) ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func)
{ {
zend_llist_element *element; zend_llist_element *element;
for (element=l->head; element; element=element->next) { for (element=l->head; element; element=element->next) {
func(element->data TSRMLS_CC); func(element->data);
} }
} }
ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC) ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func)
{ {
size_t i; size_t i;
@ -205,7 +205,7 @@ ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRM
*ptr++ = element; *ptr++ = element;
} }
zend_qsort(elements, l->count, sizeof(zend_llist_element *), (compare_func_t) comp_func TSRMLS_CC); zend_qsort(elements, l->count, sizeof(zend_llist_element *), (compare_func_t) comp_func);
l->head = elements[0]; l->head = elements[0];
elements[0]->prev = NULL; elements[0]->prev = NULL;
@ -220,24 +220,24 @@ ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRM
} }
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC) ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg)
{ {
zend_llist_element *element; zend_llist_element *element;
for (element=l->head; element; element=element->next) { for (element=l->head; element; element=element->next) {
func(element->data, arg TSRMLS_CC); func(element->data, arg);
} }
} }
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...) ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...)
{ {
zend_llist_element *element; zend_llist_element *element;
va_list args; va_list args;
va_start(args, num_args); va_start(args, num_args);
for (element=l->head; element; element=element->next) { for (element=l->head; element; element=element->next) {
func(element->data, num_args, args TSRMLS_CC); func(element->data, num_args, args);
} }
va_end(args); va_end(args);
} }

View file

@ -29,10 +29,10 @@ typedef struct _zend_llist_element {
} zend_llist_element; } zend_llist_element;
typedef void (*llist_dtor_func_t)(void *); typedef void (*llist_dtor_func_t)(void *);
typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element ** TSRMLS_DC); typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **);
typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args TSRMLS_DC); typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args);
typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg TSRMLS_DC); typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg);
typedef void (*llist_apply_func_t)(void * TSRMLS_DC); typedef void (*llist_apply_func_t)(void *);
typedef struct _zend_llist { typedef struct _zend_llist {
zend_llist_element *head; zend_llist_element *head;
@ -55,12 +55,12 @@ ZEND_API void zend_llist_destroy(zend_llist *l);
ZEND_API void zend_llist_clean(zend_llist *l); ZEND_API void zend_llist_clean(zend_llist *l);
ZEND_API void zend_llist_remove_tail(zend_llist *l); ZEND_API void zend_llist_remove_tail(zend_llist *l);
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src); ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC); ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func);
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)); ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC); ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg);
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...); ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...);
ZEND_API size_t zend_llist_count(zend_llist *l); ZEND_API size_t zend_llist_count(zend_llist *l);
ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC); ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func);
/* traversal */ /* traversal */
ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos); ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos);

View file

@ -91,8 +91,8 @@ struct _zend_module_entry {
#else #else
void* globals_ptr; void* globals_ptr;
#endif #endif
void (*globals_ctor)(void *global TSRMLS_DC); void (*globals_ctor)(void *global);
void (*globals_dtor)(void *global TSRMLS_DC); void (*globals_dtor)(void *global);
int (*post_deactivate_func)(void); int (*post_deactivate_func)(void);
int module_started; int module_started;
unsigned char type; unsigned char type;
@ -125,8 +125,8 @@ struct _zend_module_dep {
extern ZEND_API HashTable module_registry; extern ZEND_API HashTable module_registry;
void module_destructor(zend_module_entry *module); void module_destructor(zend_module_entry *module);
int module_registry_request_startup(zend_module_entry *module TSRMLS_DC); int module_registry_request_startup(zend_module_entry *module);
int module_registry_unload_temp(const zend_module_entry *module TSRMLS_DC); int module_registry_unload_temp(const zend_module_entry *module);
#endif #endif

View file

@ -25,7 +25,7 @@
#include "zend_multibyte.h" #include "zend_multibyte.h"
#include "zend_ini.h" #include "zend_ini.h"
static const zend_encoding *dummy_encoding_fetcher(const char *encoding_name TSRMLS_DC) static const zend_encoding *dummy_encoding_fetcher(const char *encoding_name)
{ {
return NULL; return NULL;
} }
@ -40,29 +40,29 @@ static int dummy_encoding_lexer_compatibility_checker(const zend_encoding *encod
return 0; return 0;
} }
static const zend_encoding *dummy_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC) static const zend_encoding *dummy_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size)
{ {
return NULL; return NULL;
} }
static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC) static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from)
{ {
return (size_t)-1; return (size_t)-1;
} }
static int dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC) static int dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent)
{ {
*return_list = pemalloc(0, persistent); *return_list = pemalloc(0, persistent);
*return_size = 0; *return_size = 0;
return SUCCESS; return SUCCESS;
} }
static const zend_encoding *dummy_internal_encoding_getter(TSRMLS_D) static const zend_encoding *dummy_internal_encoding_getter(void)
{ {
return NULL; return NULL;
} }
static int dummy_internal_encoding_setter(const zend_encoding *encoding TSRMLS_DC) static int dummy_internal_encoding_setter(const zend_encoding *encoding)
{ {
return FAILURE; return FAILURE;
} }
@ -85,25 +85,25 @@ ZEND_API const zend_encoding *zend_multibyte_encoding_utf16be = (const zend_enco
ZEND_API const zend_encoding *zend_multibyte_encoding_utf16le = (const zend_encoding*)"UTF-32LE"; ZEND_API const zend_encoding *zend_multibyte_encoding_utf16le = (const zend_encoding*)"UTF-32LE";
ZEND_API const zend_encoding *zend_multibyte_encoding_utf8 = (const zend_encoding*)"UTF-8"; ZEND_API const zend_encoding *zend_multibyte_encoding_utf8 = (const zend_encoding*)"UTF-8";
ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions TSRMLS_DC) ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions)
{ {
zend_multibyte_encoding_utf32be = functions->encoding_fetcher("UTF-32BE" TSRMLS_CC); zend_multibyte_encoding_utf32be = functions->encoding_fetcher("UTF-32BE");
if (!zend_multibyte_encoding_utf32be) { if (!zend_multibyte_encoding_utf32be) {
return FAILURE; return FAILURE;
} }
zend_multibyte_encoding_utf32le = functions->encoding_fetcher("UTF-32LE" TSRMLS_CC); zend_multibyte_encoding_utf32le = functions->encoding_fetcher("UTF-32LE");
if (!zend_multibyte_encoding_utf32le) { if (!zend_multibyte_encoding_utf32le) {
return FAILURE; return FAILURE;
} }
zend_multibyte_encoding_utf16be = functions->encoding_fetcher("UTF-16BE" TSRMLS_CC); zend_multibyte_encoding_utf16be = functions->encoding_fetcher("UTF-16BE");
if (!zend_multibyte_encoding_utf16be) { if (!zend_multibyte_encoding_utf16be) {
return FAILURE; return FAILURE;
} }
zend_multibyte_encoding_utf16le = functions->encoding_fetcher("UTF-16LE" TSRMLS_CC); zend_multibyte_encoding_utf16le = functions->encoding_fetcher("UTF-16LE");
if (!zend_multibyte_encoding_utf16le) { if (!zend_multibyte_encoding_utf16le) {
return FAILURE; return FAILURE;
} }
zend_multibyte_encoding_utf8 = functions->encoding_fetcher("UTF-8" TSRMLS_CC); zend_multibyte_encoding_utf8 = functions->encoding_fetcher("UTF-8");
if (!zend_multibyte_encoding_utf8) { if (!zend_multibyte_encoding_utf8) {
return FAILURE; return FAILURE;
} }
@ -115,19 +115,19 @@ ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functi
*/ */
{ {
const char *value = zend_ini_string("zend.script_encoding", sizeof("zend.script_encoding") - 1, 0); const char *value = zend_ini_string("zend.script_encoding", sizeof("zend.script_encoding") - 1, 0);
zend_multibyte_set_script_encoding_by_string(value, strlen(value) TSRMLS_CC); zend_multibyte_set_script_encoding_by_string(value, strlen(value));
} }
return SUCCESS; return SUCCESS;
} }
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(TSRMLS_D) ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void)
{ {
return multibyte_functions.provider_name ? &multibyte_functions: NULL; return multibyte_functions.provider_name ? &multibyte_functions: NULL;
} }
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name TSRMLS_DC) ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name)
{ {
return multibyte_functions.encoding_fetcher(name TSRMLS_CC); return multibyte_functions.encoding_fetcher(name);
} }
ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding) ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding)
@ -140,32 +140,32 @@ ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encod
return multibyte_functions.lexer_compatibility_checker(encoding); return multibyte_functions.lexer_compatibility_checker(encoding);
} }
ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC) ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size)
{ {
return multibyte_functions.encoding_detector(string, length, list, list_size TSRMLS_CC); return multibyte_functions.encoding_detector(string, length, list, list_size);
} }
ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC) ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from)
{ {
return multibyte_functions.encoding_converter(to, to_length, from, from_length, encoding_to, encoding_from TSRMLS_CC); return multibyte_functions.encoding_converter(to, to_length, from, from_length, encoding_to, encoding_from);
} }
ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC) ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent)
{ {
return multibyte_functions.encoding_list_parser(encoding_list, encoding_list_len, return_list, return_size, persistent TSRMLS_CC); return multibyte_functions.encoding_list_parser(encoding_list, encoding_list_len, return_list, return_size, persistent);
} }
ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(TSRMLS_D) ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void)
{ {
return multibyte_functions.internal_encoding_getter(TSRMLS_C); return multibyte_functions.internal_encoding_getter();
} }
ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(TSRMLS_D) ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void)
{ {
return LANG_SCNG(script_encoding); return LANG_SCNG(script_encoding);
} }
ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC) ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size)
{ {
if (CG(script_encoding_list)) { if (CG(script_encoding_list)) {
free((char*)CG(script_encoding_list)); free((char*)CG(script_encoding_list));
@ -175,22 +175,22 @@ ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_l
return SUCCESS; return SUCCESS;
} }
ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding TSRMLS_DC) ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding)
{ {
return multibyte_functions.internal_encoding_setter(encoding TSRMLS_CC); return multibyte_functions.internal_encoding_setter(encoding);
} }
ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length TSRMLS_DC) ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length)
{ {
const zend_encoding **list = 0; const zend_encoding **list = 0;
size_t size = 0; size_t size = 0;
if (!new_value) { if (!new_value) {
zend_multibyte_set_script_encoding(NULL, 0 TSRMLS_CC); zend_multibyte_set_script_encoding(NULL, 0);
return SUCCESS; return SUCCESS;
} }
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, 1 TSRMLS_CC)) { if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, 1)) {
return FAILURE; return FAILURE;
} }
@ -199,7 +199,7 @@ ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value,
return FAILURE; return FAILURE;
} }
if (FAILURE == zend_multibyte_set_script_encoding(list, size TSRMLS_CC)) { if (FAILURE == zend_multibyte_set_script_encoding(list, size)) {
return FAILURE; return FAILURE;
} }

View file

@ -24,16 +24,16 @@
typedef struct _zend_encoding zend_encoding; typedef struct _zend_encoding zend_encoding;
typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length TSRMLS_DC); typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length);
typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name TSRMLS_DC); typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name);
typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding); typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding);
typedef int (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); typedef int (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding);
typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC); typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC); typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
typedef int (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC); typedef int (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent);
typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(TSRMLS_D); typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void);
typedef int (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding TSRMLS_DC); typedef int (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding);
typedef struct _zend_multibyte_functions { typedef struct _zend_multibyte_functions {
const char *provider_name; const char *provider_name;
@ -59,21 +59,21 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le;
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8; ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
/* multibyte utility functions */ /* multibyte utility functions */
ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions TSRMLS_DC); ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions);
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(TSRMLS_D); ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name TSRMLS_DC); ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding); ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding); ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC); ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC); ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC); ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent);
ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(TSRMLS_D); ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void);
ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(TSRMLS_D); ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void);
ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC); ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size);
ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding TSRMLS_DC); ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length TSRMLS_DC); ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);
END_EXTERN_C() END_EXTERN_C()

View file

@ -106,7 +106,7 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC) /* {{{ */ ZEND_API HashTable *zend_std_get_properties(zval *object) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
zobj = Z_OBJ_P(object); zobj = Z_OBJ_P(object);
@ -117,12 +117,12 @@ ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n TSRMLS_DC) /* {{{ */ ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n) /* {{{ */
{ {
if (Z_OBJ_HANDLER_P(object, get_properties) != zend_std_get_properties) { if (Z_OBJ_HANDLER_P(object, get_properties) != zend_std_get_properties) {
*table = NULL; *table = NULL;
*n = 0; *n = 0;
return Z_OBJ_HANDLER_P(object, get_properties)(object TSRMLS_CC); return Z_OBJ_HANDLER_P(object, get_properties)(object);
} else { } else {
zend_object *zobj = Z_OBJ_P(object); zend_object *zobj = Z_OBJ_P(object);
@ -133,7 +133,7 @@ ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n TSRMLS_DC
} }
/* }}} */ /* }}} */
ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
zval retval; zval retval;
@ -142,7 +142,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC
if (!ce->__debugInfo) { if (!ce->__debugInfo) {
*is_temp = 0; *is_temp = 0;
return Z_OBJ_HANDLER_P(object, get_properties) return Z_OBJ_HANDLER_P(object, get_properties)
? Z_OBJ_HANDLER_P(object, get_properties)(object TSRMLS_CC) ? Z_OBJ_HANDLER_P(object, get_properties)(object)
: NULL; : NULL;
} }
@ -177,7 +177,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC
} }
/* }}} */ /* }}} */
static void zend_std_call_getter(zval *object, zval *member, zval *retval TSRMLS_DC) /* {{{ */ static void zend_std_call_getter(zval *object, zval *member, zval *retval) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
@ -194,7 +194,7 @@ static void zend_std_call_getter(zval *object, zval *member, zval *retval TSRMLS
} }
/* }}} */ /* }}} */
static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_DC) /* {{{ */ static int zend_std_call_setter(zval *object, zval *member, zval *value) /* {{{ */
{ {
zval retval; zval retval;
int result; int result;
@ -215,7 +215,7 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D
zval_ptr_dtor(value); zval_ptr_dtor(value);
if (Z_TYPE(retval) != IS_UNDEF) { if (Z_TYPE(retval) != IS_UNDEF) {
result = i_zend_is_true(&retval TSRMLS_CC) ? SUCCESS : FAILURE; result = i_zend_is_true(&retval) ? SUCCESS : FAILURE;
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
return result; return result;
} else { } else {
@ -224,7 +224,7 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D
} }
/* }}} */ /* }}} */
static void zend_std_call_unsetter(zval *object, zval *member TSRMLS_DC) /* {{{ */ static void zend_std_call_unsetter(zval *object, zval *member) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
@ -240,7 +240,7 @@ static void zend_std_call_unsetter(zval *object, zval *member TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
static void zend_std_call_issetter(zval *object, zval *member, zval *retval TSRMLS_DC) /* {{{ */ static void zend_std_call_issetter(zval *object, zval *member, zval *retval) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
@ -258,7 +258,7 @@ static void zend_std_call_issetter(zval *object, zval *member, zval *retval TSRM
} }
/* }}} */ /* }}} */
static zend_always_inline int zend_verify_property_access(zend_property_info *property_info, zend_class_entry *ce TSRMLS_DC) /* {{{ */ static zend_always_inline int zend_verify_property_access(zend_property_info *property_info, zend_class_entry *ce) /* {{{ */
{ {
switch (property_info->flags & ZEND_ACC_PPP_MASK) { switch (property_info->flags & ZEND_ACC_PPP_MASK) {
case ZEND_ACC_PUBLIC: case ZEND_ACC_PUBLIC:
@ -286,7 +286,7 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla
} }
/* }}} */ /* }}} */
static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, int allow_static, void **cache_slot TSRMLS_DC) /* {{{ */ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, int allow_static, void **cache_slot) /* {{{ */
{ {
zval *zv; zval *zv;
zend_property_info *property_info = NULL; zend_property_info *property_info = NULL;
@ -319,7 +319,7 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_
/* if it's a shadow - go to access it's private */ /* if it's a shadow - go to access it's private */
property_info = NULL; property_info = NULL;
} else { } else {
if (EXPECTED(zend_verify_property_access(property_info, ce TSRMLS_CC) != 0)) { if (EXPECTED(zend_verify_property_access(property_info, ce) != 0)) {
if (UNEXPECTED(!(flags & ZEND_ACC_CHANGED)) if (UNEXPECTED(!(flags & ZEND_ACC_CHANGED))
|| UNEXPECTED((flags & ZEND_ACC_PRIVATE))) { || UNEXPECTED((flags & ZEND_ACC_PRIVATE))) {
if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) { if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) {
@ -370,13 +370,13 @@ exit:
} }
/* }}} */ /* }}} */
ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent TSRMLS_DC) /* {{{ */ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
{ {
return zend_get_property_info_quick(ce, member, silent, 1, NULL TSRMLS_CC); return zend_get_property_info_quick(ce, member, silent, 1, NULL);
} }
/* }}} */ /* }}} */
ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name TSRMLS_DC) /* {{{ */ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name) /* {{{ */
{ {
zend_property_info *property_info; zend_property_info *property_info;
const char *class_name = NULL; const char *class_name = NULL;
@ -390,7 +390,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf
} else { } else {
member = zend_string_copy(prop_info_name); member = zend_string_copy(prop_info_name);
} }
property_info = zend_get_property_info_quick(zobj->ce, member, 1, 1, NULL TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, member, 1, 1, NULL);
zend_string_release(member); zend_string_release(member);
if (property_info == NULL) { if (property_info == NULL) {
/* undefined public property */ /* undefined public property */
@ -411,7 +411,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf
return FAILURE; return FAILURE;
} }
} }
return zend_verify_property_access(property_info, zobj->ce TSRMLS_CC) ? SUCCESS : FAILURE; return zend_verify_property_access(property_info, zobj->ce) ? SUCCESS : FAILURE;
} }
/* }}} */ /* }}} */
@ -432,7 +432,7 @@ static zend_long *zend_get_property_guard(zend_object *zobj, zend_string *member
} }
/* }}} */ /* }}} */
zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) /* {{{ */ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
zval tmp_member; zval tmp_member;
@ -453,7 +453,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
#endif #endif
/* make zend_get_property_info silent if we have getter - we may want to use it */ /* make zend_get_property_info silent if we have getter - we may want to use it */
property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), 0, cache_slot);
if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) {
if (EXPECTED(property_info != NULL)) { if (EXPECTED(property_info != NULL)) {
@ -476,7 +476,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
/* have getter - try with it! */ /* have getter - try with it! */
ZVAL_COPY(&tmp_object, object); ZVAL_COPY(&tmp_object, object);
*guard |= IN_GET; /* prevent circular getting */ *guard |= IN_GET; /* prevent circular getting */
zend_std_call_getter(&tmp_object, member, rv TSRMLS_CC); zend_std_call_getter(&tmp_object, member, rv);
*guard &= ~IN_GET; *guard &= ~IN_GET;
if (Z_TYPE_P(rv) != IS_UNDEF) { if (Z_TYPE_P(rv) != IS_UNDEF) {
@ -518,7 +518,7 @@ exit:
} }
/* }}} */ /* }}} */
ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) /* {{{ */ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
zval tmp_member; zval tmp_member;
@ -534,7 +534,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v
cache_slot = NULL; cache_slot = NULL;
} }
property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), 0, cache_slot TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), 0, cache_slot);
if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) {
if (EXPECTED(property_info != NULL)) { if (EXPECTED(property_info != NULL)) {
@ -545,7 +545,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v
} else if (EXPECTED(zobj->properties != NULL)) { } else if (EXPECTED(zobj->properties != NULL)) {
if ((variable_ptr = zend_hash_find(zobj->properties, Z_STR_P(member))) != NULL) { if ((variable_ptr = zend_hash_find(zobj->properties, Z_STR_P(member))) != NULL) {
found: found:
zend_assign_to_variable(variable_ptr, value, (IS_VAR|IS_TMP_VAR) TSRMLS_CC); zend_assign_to_variable(variable_ptr, value, (IS_VAR|IS_TMP_VAR));
goto exit; goto exit;
} }
} }
@ -560,7 +560,7 @@ found:
ZVAL_COPY(&tmp_object, object); ZVAL_COPY(&tmp_object, object);
(*guard) |= IN_SET; /* prevent circular setting */ (*guard) |= IN_SET; /* prevent circular setting */
if (zend_std_call_setter(&tmp_object, member, value TSRMLS_CC) != SUCCESS) { if (zend_std_call_setter(&tmp_object, member, value) != SUCCESS) {
/* for now, just ignore it - __set should take care of warnings, etc. */ /* for now, just ignore it - __set should take care of warnings, etc. */
} }
(*guard) &= ~IN_SET; (*guard) &= ~IN_SET;
@ -608,12 +608,12 @@ exit:
} }
/* }}} */ /* }}} */
zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv TSRMLS_DC) /* {{{ */ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
zval tmp; zval tmp;
if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC) != 0)) { if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) {
if(offset == NULL) { if(offset == NULL) {
/* [] construct */ /* [] construct */
ZVAL_UNDEF(&tmp); ZVAL_UNDEF(&tmp);
@ -639,12 +639,12 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv TSR
} }
/* }}} */ /* }}} */
static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) /* {{{ */ static void zend_std_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
zval tmp; zval tmp;
if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC) != 0)) { if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) {
if (!offset) { if (!offset) {
ZVAL_NULL(&tmp); ZVAL_NULL(&tmp);
offset = &tmp; offset = &tmp;
@ -659,22 +659,22 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSR
} }
/* }}} */ /* }}} */
static int zend_std_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC) /* {{{ */ static int zend_std_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
zval retval; zval retval;
int result; int result;
if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC) != 0)) { if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) {
SEPARATE_ARG_IF_REF(offset); SEPARATE_ARG_IF_REF(offset);
zend_call_method_with_1_params(object, ce, NULL, "offsetexists", &retval, offset); zend_call_method_with_1_params(object, ce, NULL, "offsetexists", &retval, offset);
if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) { if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) {
result = i_zend_is_true(&retval TSRMLS_CC); result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
if (check_empty && result && EXPECTED(!EG(exception))) { if (check_empty && result && EXPECTED(!EG(exception))) {
zend_call_method_with_1_params(object, ce, NULL, "offsetget", &retval, offset); zend_call_method_with_1_params(object, ce, NULL, "offsetget", &retval, offset);
if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) { if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) {
result = i_zend_is_true(&retval TSRMLS_CC); result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
} }
} }
@ -690,7 +690,7 @@ static int zend_std_has_dimension(zval *object, zval *offset, int check_empty TS
} }
/* }}} */ /* }}} */
static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot TSRMLS_DC) /* {{{ */ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
zend_string *name; zend_string *name;
@ -708,7 +708,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), name->val); fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), name->val);
#endif #endif
property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), 0, cache_slot);
if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) {
if (EXPECTED(property_info != NULL)) { if (EXPECTED(property_info != NULL)) {
@ -753,7 +753,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
} }
/* }}} */ /* }}} */
static void zend_std_unset_property(zval *object, zval *member, void **cache_slot TSRMLS_DC) /* {{{ */ static void zend_std_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
zval tmp_member; zval tmp_member;
@ -768,7 +768,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo
cache_slot = NULL; cache_slot = NULL;
} }
property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), 0, cache_slot TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), 0, cache_slot);
if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) {
if (EXPECTED(property_info != NULL)) { if (EXPECTED(property_info != NULL)) {
@ -794,7 +794,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo
/* have unseter - try with it! */ /* have unseter - try with it! */
ZVAL_COPY(&tmp_object, object); ZVAL_COPY(&tmp_object, object);
(*guard) |= IN_UNSET; /* prevent circular unsetting */ (*guard) |= IN_UNSET; /* prevent circular unsetting */
zend_std_call_unsetter(&tmp_object, member TSRMLS_CC); zend_std_call_unsetter(&tmp_object, member);
(*guard) &= ~IN_UNSET; (*guard) &= ~IN_UNSET;
zval_ptr_dtor(&tmp_object); zval_ptr_dtor(&tmp_object);
} else { } else {
@ -815,11 +815,11 @@ exit:
} }
/* }}} */ /* }}} */
static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC) /* {{{ */ static void zend_std_unset_dimension(zval *object, zval *offset) /* {{{ */
{ {
zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *ce = Z_OBJCE_P(object);
if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1)) {
SEPARATE_ARG_IF_REF(offset); SEPARATE_ARG_IF_REF(offset);
zend_call_method_with_1_params(object, ce, NULL, "offsetunset", NULL, offset); zend_call_method_with_1_params(object, ce, NULL, "offsetunset", NULL, offset);
zval_ptr_dtor(offset); zval_ptr_dtor(offset);
@ -838,7 +838,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
array_init_size(&method_args, ZEND_NUM_ARGS()); array_init_size(&method_args, ZEND_NUM_ARGS());
if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args TSRMLS_CC) == FAILURE)) { if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args) == FAILURE)) {
zval_dtor(&method_args); zval_dtor(&method_args);
zend_error_noreturn(E_ERROR, "Cannot get arguments for __call"); zend_error_noreturn(E_ERROR, "Cannot get arguments for __call");
RETURN_FALSE; RETURN_FALSE;
@ -871,7 +871,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
* Returns the function address that should be called, or NULL * Returns the function address that should be called, or NULL
* if no such function exists. * if no such function exists.
*/ */
static inline zend_function *zend_check_private_int(zend_function *fbc, zend_class_entry *ce, zend_string *function_name TSRMLS_DC) /* {{{ */ static inline zend_function *zend_check_private_int(zend_function *fbc, zend_class_entry *ce, zend_string *function_name) /* {{{ */
{ {
zval *func; zval *func;
@ -910,9 +910,9 @@ static inline zend_function *zend_check_private_int(zend_function *fbc, zend_cla
} }
/* }}} */ /* }}} */
ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, zend_string *function_name TSRMLS_DC) /* {{{ */ ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, zend_string *function_name) /* {{{ */
{ {
return zend_check_private_int(fbc, ce, function_name TSRMLS_CC) != NULL; return zend_check_private_int(fbc, ce, function_name) != NULL;
} }
/* }}} */ /* }}} */
@ -967,7 +967,7 @@ static inline union _zend_function *zend_get_user_call_function(zend_class_entry
} }
/* }}} */ /* }}} */
static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key TSRMLS_DC) /* {{{ */ static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key) /* {{{ */
{ {
zend_object *zobj = *obj_ptr; zend_object *zobj = *obj_ptr;
zval *func; zval *func;
@ -1001,7 +1001,7 @@ static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_str
/* Ensure that if we're calling a private function, we're allowed to do so. /* Ensure that if we're calling a private function, we're allowed to do so.
* If we're not and __call() handler exists, invoke it, otherwise error out. * If we're not and __call() handler exists, invoke it, otherwise error out.
*/ */
updated_fbc = zend_check_private_int(fbc, zobj->ce, lc_method_name TSRMLS_CC); updated_fbc = zend_check_private_int(fbc, zobj->ce, lc_method_name);
if (EXPECTED(updated_fbc != NULL)) { if (EXPECTED(updated_fbc != NULL)) {
fbc = updated_fbc; fbc = updated_fbc;
} else { } else {
@ -1056,7 +1056,7 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{
array_init_size(&method_args, ZEND_NUM_ARGS()); array_init_size(&method_args, ZEND_NUM_ARGS());
if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args TSRMLS_CC) == FAILURE)) { if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args) == FAILURE)) {
zval_dtor(&method_args); zval_dtor(&method_args);
zend_error_noreturn(E_ERROR, "Cannot get arguments for " ZEND_CALLSTATIC_FUNC_NAME); zend_error_noreturn(E_ERROR, "Cannot get arguments for " ZEND_CALLSTATIC_FUNC_NAME);
RETURN_FALSE; RETURN_FALSE;
@ -1108,7 +1108,7 @@ static inline union _zend_function *zend_get_user_callstatic_function(zend_class
/* This is not (yet?) in the API, but it belongs in the built-in objects callbacks */ /* This is not (yet?) in the API, but it belongs in the built-in objects callbacks */
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key TSRMLS_DC) /* {{{ */ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key) /* {{{ */
{ {
zend_function *fbc = NULL; zend_function *fbc = NULL;
char *lc_class_name; char *lc_class_name;
@ -1142,7 +1142,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
} }
if (ce->__call && if (ce->__call &&
Z_OBJ(EG(current_execute_data)->This) && Z_OBJ(EG(current_execute_data)->This) &&
instanceof_function(Z_OBJCE(EG(current_execute_data)->This), ce TSRMLS_CC)) { instanceof_function(Z_OBJCE(EG(current_execute_data)->This), ce)) {
return zend_get_user_call_function(ce, function_name); return zend_get_user_call_function(ce, function_name);
} else if (ce->__callstatic) { } else if (ce->__callstatic) {
return zend_get_user_callstatic_function(ce, function_name); return zend_get_user_callstatic_function(ce, function_name);
@ -1166,7 +1166,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
/* Ensure that if we're calling a private function, we're allowed to do so. /* Ensure that if we're calling a private function, we're allowed to do so.
*/ */
updated_fbc = zend_check_private_int(fbc, EG(scope), lc_function_name TSRMLS_CC); updated_fbc = zend_check_private_int(fbc, EG(scope), lc_function_name);
if (EXPECTED(updated_fbc != NULL)) { if (EXPECTED(updated_fbc != NULL)) {
fbc = updated_fbc; fbc = updated_fbc;
} else { } else {
@ -1196,7 +1196,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
} }
/* }}} */ /* }}} */
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent, void **cache_slot TSRMLS_DC) /* {{{ */ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent, void **cache_slot) /* {{{ */
{ {
zend_property_info *property_info; zend_property_info *property_info;
@ -1210,7 +1210,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
return NULL; return NULL;
} }
if (UNEXPECTED(!zend_verify_property_access(property_info, ce TSRMLS_CC))) { if (UNEXPECTED(!zend_verify_property_access(property_info, ce))) {
if (!silent) { if (!silent) {
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, property_name->val); zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, property_name->val);
} }
@ -1224,7 +1224,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
return NULL; return NULL;
} }
zend_update_class_constants(ce TSRMLS_CC); zend_update_class_constants(ce);
if (EXPECTED(cache_slot != NULL)) { if (EXPECTED(cache_slot != NULL)) {
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, property_info); CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, property_info);
@ -1243,14 +1243,14 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
} }
/* }}} */ /* }}} */
ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name, void **cache_slot TSRMLS_DC) /* {{{ */ ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name, void **cache_slot) /* {{{ */
{ {
zend_error_noreturn(E_ERROR, "Attempt to unset static property %s::$%s", ce->name->val, property_name->val); zend_error_noreturn(E_ERROR, "Attempt to unset static property %s::$%s", ce->name->val, property_name->val);
return 0; return 0;
} }
/* }}} */ /* }}} */
ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj TSRMLS_DC) /* {{{ */ ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj) /* {{{ */
{ {
zend_function *constructor = zobj->ce->constructor; zend_function *constructor = zobj->ce->constructor;
@ -1286,9 +1286,9 @@ ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj TSRMLS
} }
/* }}} */ /* }}} */
int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_DC); int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2);
static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ static int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
{ {
zend_object *zobj1, *zobj2; zend_object *zobj1, *zobj2;
@ -1310,7 +1310,7 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
zval *p1 = &zobj1->properties_table[i]; zval *p1 = &zobj1->properties_table[i];
zval *p2 = &zobj2->properties_table[i]; zval *p2 = &zobj2->properties_table[i];
if (compare_function(&result, p1, p2 TSRMLS_CC)==FAILURE) { if (compare_function(&result, p1, p2)==FAILURE) {
Z_OBJ_UNPROTECT_RECURSION(o1); Z_OBJ_UNPROTECT_RECURSION(o1);
Z_OBJ_UNPROTECT_RECURSION(o2); Z_OBJ_UNPROTECT_RECURSION(o2);
return 1; return 1;
@ -1343,12 +1343,12 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
if (!zobj2->properties) { if (!zobj2->properties) {
rebuild_object_properties(zobj2); rebuild_object_properties(zobj2);
} }
return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties TSRMLS_CC); return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties);
} }
} }
/* }}} */ /* }}} */
static int zend_std_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot TSRMLS_DC) /* {{{ */ static int zend_std_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */
{ {
zend_object *zobj; zend_object *zobj;
int result; int result;
@ -1365,7 +1365,7 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists,
cache_slot = NULL; cache_slot = NULL;
} }
property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, 0, cache_slot TSRMLS_CC); property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, 0, cache_slot);
if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) {
if (EXPECTED(property_info != NULL)) { if (EXPECTED(property_info != NULL)) {
@ -1382,7 +1382,7 @@ found:
result = (Z_TYPE_P(value) != IS_NULL); result = (Z_TYPE_P(value) != IS_NULL);
break; break;
default: default:
result = zend_is_true(value TSRMLS_CC); result = zend_is_true(value);
break; break;
case 2: case 2:
result = 1; result = 1;
@ -1403,17 +1403,17 @@ found:
/* have issetter - try with it! */ /* have issetter - try with it! */
ZVAL_COPY(&tmp_object, object); ZVAL_COPY(&tmp_object, object);
(*guard) |= IN_ISSET; /* prevent circular getting */ (*guard) |= IN_ISSET; /* prevent circular getting */
zend_std_call_issetter(&tmp_object, member, &rv TSRMLS_CC); zend_std_call_issetter(&tmp_object, member, &rv);
if (Z_TYPE(rv) != IS_UNDEF) { if (Z_TYPE(rv) != IS_UNDEF) {
result = zend_is_true(&rv TSRMLS_CC); result = zend_is_true(&rv);
zval_ptr_dtor(&rv); zval_ptr_dtor(&rv);
if (has_set_exists && result) { if (has_set_exists && result) {
if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) { if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) {
(*guard) |= IN_GET; (*guard) |= IN_GET;
zend_std_call_getter(&tmp_object, member, &rv TSRMLS_CC); zend_std_call_getter(&tmp_object, member, &rv);
(*guard) &= ~IN_GET; (*guard) &= ~IN_GET;
if (Z_TYPE(rv) != IS_UNDEF) { if (Z_TYPE(rv) != IS_UNDEF) {
result = i_zend_is_true(&rv TSRMLS_CC); result = i_zend_is_true(&rv);
zval_ptr_dtor(&rv); zval_ptr_dtor(&rv);
} else { } else {
result = 0; result = 0;
@ -1436,13 +1436,13 @@ exit:
} }
/* }}} */ /* }}} */
zend_string *zend_std_object_get_class_name(const zend_object *zobj TSRMLS_DC) /* {{{ */ zend_string *zend_std_object_get_class_name(const zend_object *zobj) /* {{{ */
{ {
return zend_string_copy(zobj->ce->name); return zend_string_copy(zobj->ce->name);
} }
/* }}} */ /* }}} */
ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC) /* {{{ */ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type) /* {{{ */
{ {
zval retval; zval retval;
zend_class_entry *ce; zend_class_entry *ce;
@ -1502,7 +1502,7 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
} }
/* }}} */ /* }}} */
int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC) /* {{{ */ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */
{ {
zval *func; zval *func;
zend_class_entry *ce; zend_class_entry *ce;

View file

@ -33,10 +33,10 @@ struct _zend_property_info;
symbol table, its reference count should be 0. symbol table, its reference count should be 0.
*/ */
/* Used to fetch property from the object, read-only */ /* Used to fetch property from the object, read-only */
typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC); typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, void **cache_slot, zval *rv);
/* Used to fetch dimension from the object, read-only */ /* Used to fetch dimension from the object, read-only */
typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type, zval *rv TSRMLS_DC); typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type, zval *rv);
/* The following rule applies to write_property() and write_dimension() implementations: /* The following rule applies to write_property() and write_dimension() implementations:
@ -45,23 +45,23 @@ typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int ty
any changes. You should NOT modify the reference count of the value passed to you. any changes. You should NOT modify the reference count of the value passed to you.
*/ */
/* Used to set property of the object */ /* Used to set property of the object */
typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC); typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot);
/* Used to set dimension of the object */ /* Used to set dimension of the object */
typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC); typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value);
/* Used to create pointer to the property of the object, for future direct r/w access */ /* Used to create pointer to the property of the object, for future direct r/w access */
typedef zval *(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, void **cache_slot TSRMLS_DC); typedef zval *(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, void **cache_slot);
/* Used to set object value. Can be used to override assignments and scalar /* Used to set object value. Can be used to override assignments and scalar
write ops (like ++, +=) on the object */ write ops (like ++, +=) on the object */
typedef void (*zend_object_set_t)(zval *object, zval *value TSRMLS_DC); typedef void (*zend_object_set_t)(zval *object, zval *value);
/* Used to get object value. Can be used when converting object value to /* Used to get object value. Can be used when converting object value to
* one of the basic types and when using scalar ops (like ++, +=) on the object * one of the basic types and when using scalar ops (like ++, +=) on the object
*/ */
typedef zval* (*zend_object_get_t)(zval *object, zval *rv TSRMLS_DC); typedef zval* (*zend_object_get_t)(zval *object, zval *rv);
/* Used to check if a property of the object exists */ /* Used to check if a property of the object exists */
/* param has_set_exists: /* param has_set_exists:
@ -69,55 +69,55 @@ typedef zval* (*zend_object_get_t)(zval *object, zval *rv TSRMLS_DC);
* 1 (set) whether property exists and is true * 1 (set) whether property exists and is true
* 2 (exists) whether property exists * 2 (exists) whether property exists
*/ */
typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, void **cache_slot TSRMLS_DC); typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, void **cache_slot);
/* Used to check if a dimension of the object exists */ /* Used to check if a dimension of the object exists */
typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC); typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty);
/* Used to remove a property of the object */ /* Used to remove a property of the object */
typedef void (*zend_object_unset_property_t)(zval *object, zval *member, void **cache_slot TSRMLS_DC); typedef void (*zend_object_unset_property_t)(zval *object, zval *member, void **cache_slot);
/* Used to remove a dimension of the object */ /* Used to remove a dimension of the object */
typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC); typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset);
/* Used to get hash of the properties of the object, as hash of zval's */ /* Used to get hash of the properties of the object, as hash of zval's */
typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC); typedef HashTable *(*zend_object_get_properties_t)(zval *object);
typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TSRMLS_DC); typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp);
/* Used to call methods */ /* Used to call methods */
/* args on stack! */ /* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this. /* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
*/ */
typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS); typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS);
typedef union _zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key TSRMLS_DC); typedef union _zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key);
typedef union _zend_function *(*zend_object_get_constructor_t)(zend_object *object TSRMLS_DC); typedef union _zend_function *(*zend_object_get_constructor_t)(zend_object *object);
/* Object maintenance/destruction */ /* Object maintenance/destruction */
typedef void (*zend_object_dtor_obj_t)(zend_object *object TSRMLS_DC); typedef void (*zend_object_dtor_obj_t)(zend_object *object);
typedef void (*zend_object_free_obj_t)(zend_object *object TSRMLS_DC); typedef void (*zend_object_free_obj_t)(zend_object *object);
typedef zend_object* (*zend_object_clone_obj_t)(zval *object TSRMLS_DC); typedef zend_object* (*zend_object_clone_obj_t)(zval *object);
/* Get class name for display in var_dump and other debugging functions. /* Get class name for display in var_dump and other debugging functions.
* Must be defined and must return a non-NULL value. */ * Must be defined and must return a non-NULL value. */
typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object TSRMLS_DC); typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC); typedef int (*zend_object_compare_t)(zval *object1, zval *object2);
typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2 TSRMLS_DC); typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2);
/* Cast an object to some other type /* Cast an object to some other type
*/ */
typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC); typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type);
/* updates *count to hold the number of elements present and returns SUCCESS. /* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */ * Returns FAILURE if the object does not have any sense of overloaded dimensions */
typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count TSRMLS_DC); typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count);
typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC); typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zend_object **obj_ptr);
typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n TSRMLS_DC); typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n);
typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC); typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2);
struct _zend_object_handlers { struct _zend_object_handlers {
/* offset of real object header (usually zero) */ /* offset of real object header (usually zero) */
@ -159,22 +159,22 @@ extern ZEND_API zend_object_handlers std_object_handlers;
((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope) ((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key TSRMLS_DC); ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent, void **cache_slot TSRMLS_DC); ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent, void **cache_slot);
ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name, void **cache_slot TSRMLS_DC); ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name, void **cache_slot);
ZEND_API union _zend_function *zend_std_get_constructor(zend_object *object TSRMLS_DC); ZEND_API union _zend_function *zend_std_get_constructor(zend_object *object);
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent TSRMLS_DC); ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent);
ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC); ZEND_API HashTable *zend_std_get_properties(zval *object);
ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC); ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp);
ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC); ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type);
ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC); ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot);
ZEND_API void rebuild_object_properties(zend_object *zobj); ZEND_API void rebuild_object_properties(zend_object *zobj);
ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, zend_string *function_name TSRMLS_DC); ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, zend_string *function_name);
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name TSRMLS_DC); ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name);
ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS); ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS);
END_EXTERN_C() END_EXTERN_C()

View file

@ -26,14 +26,14 @@
#include "zend_interfaces.h" #include "zend_interfaces.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC) ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce)
{ {
GC_REFCOUNT(object) = 1; GC_REFCOUNT(object) = 1;
GC_TYPE_INFO(object) = IS_OBJECT; GC_TYPE_INFO(object) = IS_OBJECT;
object->ce = ce; object->ce = ce;
object->properties = NULL; object->properties = NULL;
object->guards = NULL; object->guards = NULL;
zend_objects_store_put(object TSRMLS_CC); zend_objects_store_put(object);
if (EXPECTED(ce->default_properties_count != 0)) { if (EXPECTED(ce->default_properties_count != 0)) {
zval *p = object->properties_table; zval *p = object->properties_table;
zval *end = p + ce->default_properties_count; zval *end = p + ce->default_properties_count;
@ -45,7 +45,7 @@ ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSR
} }
} }
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC) ZEND_API void zend_object_std_dtor(zend_object *object)
{ {
int i, count; int i, count;
@ -54,16 +54,16 @@ ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)
FREE_HASHTABLE(object->guards); FREE_HASHTABLE(object->guards);
} }
if (object->properties) { if (object->properties) {
zend_array_destroy(object->properties TSRMLS_CC); zend_array_destroy(object->properties);
FREE_HASHTABLE(object->properties); FREE_HASHTABLE(object->properties);
} }
count = object->ce->default_properties_count; count = object->ce->default_properties_count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
i_zval_ptr_dtor(&object->properties_table[i] ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(&object->properties_table[i] ZEND_FILE_LINE_CC);
} }
} }
ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC) ZEND_API void zend_objects_destroy_object(zend_object *object)
{ {
zend_function *destructor = object ? object->ce->destructor : NULL; zend_function *destructor = object ? object->ce->destructor : NULL;
@ -120,7 +120,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC)
zend_call_method_with_0_params(&obj, object->ce, &destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL); zend_call_method_with_0_params(&obj, object->ce, &destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL);
if (old_exception) { if (old_exception) {
if (EG(exception)) { if (EG(exception)) {
zend_exception_set_previous(EG(exception), old_exception TSRMLS_CC); zend_exception_set_previous(EG(exception), old_exception);
} else { } else {
EG(exception) = old_exception; EG(exception) = old_exception;
} }
@ -129,16 +129,16 @@ ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC)
} }
} }
ZEND_API zend_object *zend_objects_new(zend_class_entry *ce TSRMLS_DC) ZEND_API zend_object *zend_objects_new(zend_class_entry *ce)
{ {
zend_object *object = emalloc(sizeof(zend_object) + sizeof(zval) * (ce->default_properties_count - 1)); zend_object *object = emalloc(sizeof(zend_object) + sizeof(zval) * (ce->default_properties_count - 1));
zend_object_std_init(object, ce TSRMLS_CC); zend_object_std_init(object, ce);
object->handlers = &std_object_handlers; object->handlers = &std_object_handlers;
return object; return object;
} }
ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *old_object TSRMLS_DC) ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *old_object)
{ {
int i; int i;
@ -184,7 +184,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
} }
} }
ZEND_API zend_object *zend_objects_clone_obj(zval *zobject TSRMLS_DC) ZEND_API zend_object *zend_objects_clone_obj(zval *zobject)
{ {
zend_object *old_object; zend_object *old_object;
zend_object *new_object; zend_object *new_object;
@ -192,9 +192,9 @@ ZEND_API zend_object *zend_objects_clone_obj(zval *zobject TSRMLS_DC)
/* assume that create isn't overwritten, so when clone depends on the /* assume that create isn't overwritten, so when clone depends on the
* overwritten one then it must itself be overwritten */ * overwritten one then it must itself be overwritten */
old_object = Z_OBJ_P(zobject); old_object = Z_OBJ_P(zobject);
new_object = zend_objects_new(old_object->ce TSRMLS_CC); new_object = zend_objects_new(old_object->ce);
zend_objects_clone_members(new_object, old_object TSRMLS_CC); zend_objects_clone_members(new_object, old_object);
return new_object; return new_object;
} }

View file

@ -25,12 +25,12 @@
#include "zend.h" #include "zend.h"
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC); ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce);
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC); ZEND_API void zend_object_std_dtor(zend_object *object);
ZEND_API zend_object *zend_objects_new(zend_class_entry *ce TSRMLS_DC); ZEND_API zend_object *zend_objects_new(zend_class_entry *ce);
ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC); ZEND_API void zend_objects_destroy_object(zend_object *object);
ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *old_object TSRMLS_DC); ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *old_object);
ZEND_API zend_object *zend_objects_clone_obj(zval *object TSRMLS_DC); ZEND_API zend_object *zend_objects_clone_obj(zval *object);
END_EXTERN_C() END_EXTERN_C()
#endif /* ZEND_OBJECTS_H */ #endif /* ZEND_OBJECTS_H */

View file

@ -40,7 +40,7 @@ ZEND_API void zend_objects_store_destroy(zend_objects_store *objects)
objects->object_buckets = NULL; objects->object_buckets = NULL;
} }
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC) ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects)
{ {
uint32_t i; uint32_t i;
@ -51,14 +51,14 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) { if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED; GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
GC_REFCOUNT(obj)++; GC_REFCOUNT(obj)++;
obj->handlers->dtor_obj(obj TSRMLS_CC); obj->handlers->dtor_obj(obj);
GC_REFCOUNT(obj)--; GC_REFCOUNT(obj)--;
} }
} }
} }
} }
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC) ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects)
{ {
uint32_t i; uint32_t i;
@ -74,7 +74,7 @@ ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSR
} }
} }
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC) ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects)
{ {
uint32_t i; uint32_t i;
@ -87,7 +87,7 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects
GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED; GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED;
if (obj->handlers->free_obj) { if (obj->handlers->free_obj) {
GC_REFCOUNT(obj)++; GC_REFCOUNT(obj)++;
obj->handlers->free_obj(obj TSRMLS_CC); obj->handlers->free_obj(obj);
GC_REFCOUNT(obj)--; GC_REFCOUNT(obj)--;
} }
} }
@ -110,7 +110,7 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects
/* Store objects API */ /* Store objects API */
ZEND_API void zend_objects_store_put(zend_object *object TSRMLS_DC) ZEND_API void zend_objects_store_put(zend_object *object)
{ {
int handle; int handle;
@ -132,7 +132,7 @@ ZEND_API void zend_objects_store_put(zend_object *object TSRMLS_DC)
SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \ SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \
EG(objects_store).free_list_head = handle; EG(objects_store).free_list_head = handle;
ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC) /* {{{ */ ZEND_API void zend_objects_store_free(zend_object *object) /* {{{ */
{ {
uint32_t handle = object->handle; uint32_t handle = object->handle;
void *ptr = ((char*)object) - object->handlers->offset; void *ptr = ((char*)object) - object->handlers->offset;
@ -143,7 +143,7 @@ ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
{ {
/* Make sure we hold a reference count during the destructor call /* Make sure we hold a reference count during the destructor call
otherwise, when the destructor ends the storage might be freed otherwise, when the destructor ends the storage might be freed
@ -160,7 +160,7 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */
if (object->handlers->dtor_obj) { if (object->handlers->dtor_obj) {
GC_REFCOUNT(object)++; GC_REFCOUNT(object)++;
zend_try { zend_try {
object->handlers->dtor_obj(object TSRMLS_CC); object->handlers->dtor_obj(object);
} zend_catch { } zend_catch {
failure = 1; failure = 1;
} zend_end_try(); } zend_end_try();
@ -178,7 +178,7 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */
if (object->handlers->free_obj) { if (object->handlers->free_obj) {
zend_try { zend_try {
GC_REFCOUNT(object)++; GC_REFCOUNT(object)++;
object->handlers->free_obj(object TSRMLS_CC); object->handlers->free_obj(object);
GC_REFCOUNT(object)--; GC_REFCOUNT(object)--;
} zend_catch { } zend_catch {
failure = 1; failure = 1;
@ -208,13 +208,13 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */
* from the constructor function. You MUST NOT use this function for any other * from the constructor function. You MUST NOT use this function for any other
* weird games, or call it at any other time after the object is constructed. * weird games, or call it at any other time after the object is constructed.
* */ * */
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object TSRMLS_DC) ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object)
{ {
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object; EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object;
} }
/* Called when the ctor was terminated by an exception */ /* Called when the ctor was terminated by an exception */
ZEND_API void zend_object_store_ctor_failed(zend_object *obj TSRMLS_DC) ZEND_API void zend_object_store_ctor_failed(zend_object *obj)
{ {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED; GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
} }

View file

@ -37,7 +37,7 @@
} while (0) } while (0)
#define OBJ_RELEASE(obj) zend_object_release(obj TSRMLS_CC) #define OBJ_RELEASE(obj) zend_object_release(obj)
typedef struct _zend_objects_store { typedef struct _zend_objects_store {
zend_object **object_buckets; zend_object **object_buckets;
@ -49,34 +49,34 @@ typedef struct _zend_objects_store {
/* Global store handling functions */ /* Global store handling functions */
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size); ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC); ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects);
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC); ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects);
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects); ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
/* Store API functions */ /* Store API functions */
ZEND_API void zend_objects_store_put(zend_object *object TSRMLS_DC); ZEND_API void zend_objects_store_put(zend_object *object);
ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC); ZEND_API void zend_objects_store_del(zend_object *object);
ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC); ZEND_API void zend_objects_store_free(zend_object *object);
/* See comment in zend_objects_API.c before you use this */ /* See comment in zend_objects_API.c before you use this */
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object TSRMLS_DC); ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object);
ZEND_API void zend_object_store_ctor_failed(zend_object *object TSRMLS_DC); ZEND_API void zend_object_store_ctor_failed(zend_object *object);
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC); ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects);
#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj #define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member TSRMLS_DC); ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member);
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void); ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
END_EXTERN_C() END_EXTERN_C()
static zend_always_inline void zend_object_release(zend_object *obj TSRMLS_DC) static zend_always_inline void zend_object_release(zend_object *obj)
{ {
if (--GC_REFCOUNT(obj) == 0) { if (--GC_REFCOUNT(obj) == 0) {
zend_objects_store_del(obj TSRMLS_CC); zend_objects_store_del(obj);
} else if (UNEXPECTED(!GC_INFO(obj))) { } else if (UNEXPECTED(!GC_INFO(obj))) {
gc_possible_root(&obj->gc TSRMLS_CC); gc_possible_root(&obj->gc);
} }
} }

View file

@ -29,14 +29,14 @@
#include "zend_vm.h" #include "zend_vm.h"
static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->op_array_ctor) { if (extension->op_array_ctor) {
extension->op_array_ctor(op_array); extension->op_array_ctor(op_array);
} }
} }
static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->op_array_dtor) { if (extension->op_array_dtor) {
extension->op_array_dtor(op_array); extension->op_array_dtor(op_array);
@ -48,7 +48,7 @@ static void op_array_alloc_ops(zend_op_array *op_array, uint32_t size)
op_array->opcodes = erealloc(op_array->opcodes, size * sizeof(zend_op)); op_array->opcodes = erealloc(op_array->opcodes, size * sizeof(zend_op));
} }
void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size TSRMLS_DC) void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size)
{ {
op_array->type = type; op_array->type = type;
@ -64,7 +64,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
op_array->T = 0; op_array->T = 0;
op_array->function_name = NULL; op_array->function_name = NULL;
op_array->filename = zend_get_compiled_filename(TSRMLS_C); op_array->filename = zend_get_compiled_filename();
op_array->doc_comment = NULL; op_array->doc_comment = NULL;
op_array->arg_info = NULL; op_array->arg_info = NULL;
@ -95,13 +95,13 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*)); memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*));
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_ctor_handler, op_array TSRMLS_CC); zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_ctor_handler, op_array);
} }
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC) ZEND_API void destroy_zend_function(zend_function *function)
{ {
if (function->type == ZEND_USER_FUNCTION) { if (function->type == ZEND_USER_FUNCTION) {
destroy_op_array(&function->op_array TSRMLS_CC); destroy_op_array(&function->op_array);
} else { } else {
ZEND_ASSERT(function->type == ZEND_INTERNAL_FUNCTION); ZEND_ASSERT(function->type == ZEND_INTERNAL_FUNCTION);
ZEND_ASSERT(function->common.function_name); ZEND_ASSERT(function->common.function_name);
@ -112,11 +112,10 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC)
ZEND_API void zend_function_dtor(zval *zv) ZEND_API void zend_function_dtor(zval *zv)
{ {
zend_function *function = Z_PTR_P(zv); zend_function *function = Z_PTR_P(zv);
TSRMLS_FETCH();
if (function->type == ZEND_USER_FUNCTION) { if (function->type == ZEND_USER_FUNCTION) {
ZEND_ASSERT(function->common.function_name); ZEND_ASSERT(function->common.function_name);
destroy_op_array(&function->op_array TSRMLS_CC); destroy_op_array(&function->op_array);
/* op_arrays are allocated on arena, so we don't have to free them */ /* op_arrays are allocated on arena, so we don't have to free them */
//??? efree_size(function, sizeof(zend_op_array)); //??? efree_size(function, sizeof(zend_op_array));
} else { } else {
@ -136,7 +135,7 @@ ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array)
} }
} }
ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC) ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce)
{ {
/* Clean all parts that can contain run-time data */ /* Clean all parts that can contain run-time data */
/* Note that only run-time accessed data need to be cleaned up, pre-defined data can /* Note that only run-time accessed data need to be cleaned up, pre-defined data can
@ -166,7 +165,7 @@ ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC)
} }
} }
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC) ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
{ {
if (CE_STATIC_MEMBERS(ce)) { if (CE_STATIC_MEMBERS(ce)) {
int i; int i;
@ -313,7 +312,7 @@ void zend_class_add_ref(zval *zv)
ce->refcount++; ce->refcount++;
} }
ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC) ZEND_API void destroy_op_array(zend_op_array *op_array)
{ {
zval *literal = op_array->literals; zval *literal = op_array->literals;
zval *end; zval *end;
@ -366,7 +365,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
efree(op_array->try_catch_array); efree(op_array->try_catch_array);
} }
if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) { if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) {
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array TSRMLS_CC); zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array);
} }
if (op_array->arg_info) { if (op_array->arg_info) {
for (i=0; i<op_array->num_args; i++) { for (i=0; i<op_array->num_args; i++) {
@ -379,14 +378,14 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
} }
} }
void init_op(zend_op *op TSRMLS_DC) void init_op(zend_op *op)
{ {
memset(op, 0, sizeof(zend_op)); memset(op, 0, sizeof(zend_op));
op->lineno = CG(zend_lineno); op->lineno = CG(zend_lineno);
SET_UNUSED(op->result); SET_UNUSED(op->result);
} }
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC) zend_op *get_next_op(zend_op_array *op_array)
{ {
uint32_t next_op_num = op_array->last++; uint32_t next_op_num = op_array->last++;
zend_op *next_op; zend_op *next_op;
@ -398,7 +397,7 @@ zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC)
next_op = &(op_array->opcodes[next_op_num]); next_op = &(op_array->opcodes[next_op_num]);
init_op(next_op TSRMLS_CC); init_op(next_op);
return next_op; return next_op;
} }
@ -415,7 +414,7 @@ zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array)
return &op_array->brk_cont_array[op_array->last_brk_cont-1]; return &op_array->brk_cont_array[op_array->last_brk_cont-1];
} }
static void zend_update_extended_info(zend_op_array *op_array TSRMLS_DC) static void zend_update_extended_info(zend_op_array *op_array)
{ {
zend_op *opline = op_array->opcodes, *end=opline+op_array->last; zend_op *opline = op_array->opcodes, *end=opline+op_array->last;
@ -438,14 +437,14 @@ static void zend_update_extended_info(zend_op_array *op_array TSRMLS_DC)
} }
} }
static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array)
{ {
if (extension->op_array_handler) { if (extension->op_array_handler) {
extension->op_array_handler(op_array); extension->op_array_handler(op_array);
} }
} }
static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num TSRMLS_DC) static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
{ {
int i; int i;
@ -470,7 +469,7 @@ static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num
} }
} }
static void zend_adjust_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t start, uint32_t end TSRMLS_DC) static void zend_adjust_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t start, uint32_t end)
{ {
int i; int i;
uint32_t op_num = 0; uint32_t op_num = 0;
@ -491,7 +490,7 @@ static void zend_adjust_fast_call(zend_op_array *op_array, uint32_t fast_call, u
} }
} }
static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t op_num TSRMLS_DC) static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t op_num)
{ {
int i; int i;
uint32_t finally_op_num = 0; uint32_t finally_op_num = 0;
@ -513,14 +512,14 @@ static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call,
} }
} }
static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num TSRMLS_DC) static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
{ {
uint32_t start_op; uint32_t start_op;
zend_op *opline; zend_op *opline;
uint32_t i = op_array->last_try_catch; uint32_t i = op_array->last_try_catch;
if (dst_num != (uint32_t)-1) { if (dst_num != (uint32_t)-1) {
zend_check_finally_breakout(op_array, op_num, dst_num TSRMLS_CC); zend_check_finally_breakout(op_array, op_num, dst_num);
} }
/* the backward order is mater */ /* the backward order is mater */
@ -541,7 +540,7 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
/* generate a FAST_CALL to finally block */ /* generate a FAST_CALL to finally block */
start_op = get_next_op_number(op_array); start_op = get_next_op_number(op_array);
opline = get_next_op(op_array TSRMLS_CC); opline = get_next_op(op_array);
opline->opcode = ZEND_FAST_CALL; opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR; opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var; opline->result.var = fast_call_var;
@ -549,21 +548,21 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
SET_UNUSED(opline->op2); SET_UNUSED(opline->op2);
zend_adjust_fast_call(op_array, start_op, zend_adjust_fast_call(op_array, start_op,
op_array->try_catch_array[i].finally_op, op_array->try_catch_array[i].finally_op,
op_array->try_catch_array[i].finally_end TSRMLS_CC); op_array->try_catch_array[i].finally_end);
if (op_array->try_catch_array[i].catch_op) { if (op_array->try_catch_array[i].catch_op) {
opline->extended_value = ZEND_FAST_CALL_FROM_CATCH; opline->extended_value = ZEND_FAST_CALL_FROM_CATCH;
opline->op2.opline_num = op_array->try_catch_array[i].catch_op; opline->op2.opline_num = op_array->try_catch_array[i].catch_op;
opline->op1.opline_num = get_next_op_number(op_array); opline->op1.opline_num = get_next_op_number(op_array);
/* generate a FAST_CALL to hole CALL_FROM_FINALLY */ /* generate a FAST_CALL to hole CALL_FROM_FINALLY */
opline = get_next_op(op_array TSRMLS_CC); opline = get_next_op(op_array);
opline->opcode = ZEND_FAST_CALL; opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR; opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var; opline->result.var = fast_call_var;
SET_UNUSED(opline->op1); SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2); SET_UNUSED(opline->op2);
zend_resolve_fast_call(op_array, start_op + 1, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC); zend_resolve_fast_call(op_array, start_op + 1, op_array->try_catch_array[i].finally_op - 2);
} else { } else {
zend_resolve_fast_call(op_array, start_op, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC); zend_resolve_fast_call(op_array, start_op, op_array->try_catch_array[i].finally_op - 2);
} }
opline->op1.opline_num = op_array->try_catch_array[i].finally_op; opline->op1.opline_num = op_array->try_catch_array[i].finally_op;
@ -576,7 +575,7 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
(dst_num < op_array->try_catch_array[i].try_op || (dst_num < op_array->try_catch_array[i].try_op ||
dst_num > op_array->try_catch_array[i].finally_end)) { dst_num > op_array->try_catch_array[i].finally_end)) {
opline = get_next_op(op_array TSRMLS_CC); opline = get_next_op(op_array);
opline->opcode = ZEND_FAST_CALL; opline->opcode = ZEND_FAST_CALL;
opline->result_type = IS_TMP_VAR; opline->result_type = IS_TMP_VAR;
opline->result.var = fast_call_var; opline->result.var = fast_call_var;
@ -587,7 +586,7 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
} }
/* Finish the sequence with original opcode */ /* Finish the sequence with original opcode */
opline = get_next_op(op_array TSRMLS_CC); opline = get_next_op(op_array);
*opline = op_array->opcodes[op_num]; *opline = op_array->opcodes[op_num];
/* Replace original opcode with jump to this sequence */ /* Replace original opcode with jump to this sequence */
@ -602,7 +601,7 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
} }
} }
static void zend_resolve_finally_ret(zend_op_array *op_array, uint32_t op_num TSRMLS_DC) static void zend_resolve_finally_ret(zend_op_array *op_array, uint32_t op_num)
{ {
int i; int i;
uint32_t catch_op_num = 0, finally_op_num = 0; uint32_t catch_op_num = 0, finally_op_num = 0;
@ -630,7 +629,7 @@ static void zend_resolve_finally_ret(zend_op_array *op_array, uint32_t op_num TS
} }
} }
static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) static void zend_resolve_finally_calls(zend_op_array *op_array)
{ {
uint32_t i, j; uint32_t i, j;
zend_op *opline; zend_op *opline;
@ -641,7 +640,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
case ZEND_RETURN: case ZEND_RETURN:
case ZEND_RETURN_BY_REF: case ZEND_RETURN_BY_REF:
case ZEND_GENERATOR_RETURN: case ZEND_GENERATOR_RETURN:
zend_resolve_finally_call(op_array, i, (uint32_t)-1 TSRMLS_CC); zend_resolve_finally_call(op_array, i, (uint32_t)-1);
break; break;
case ZEND_BRK: case ZEND_BRK:
case ZEND_CONT: case ZEND_CONT:
@ -657,7 +656,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
array_offset = jmp_to->parent; array_offset = jmp_to->parent;
} }
} while (--nest_levels > 0); } while (--nest_levels > 0);
zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC); zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont);
break; break;
} }
} }
@ -666,18 +665,18 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
uint32_t num = opline->op2.constant; uint32_t num = opline->op2.constant;
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2); ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2);
zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC); zend_resolve_goto_label(op_array, opline, 1);
opline->op2.constant = num; opline->op2.constant = num;
} }
/* break omitted intentionally */ /* break omitted intentionally */
case ZEND_JMP: case ZEND_JMP:
zend_resolve_finally_call(op_array, i, opline->op1.opline_num TSRMLS_CC); zend_resolve_finally_call(op_array, i, opline->op1.opline_num);
break; break;
case ZEND_FAST_CALL: case ZEND_FAST_CALL:
zend_resolve_fast_call(op_array, i, i TSRMLS_CC); zend_resolve_fast_call(op_array, i, i);
break; break;
case ZEND_FAST_RET: case ZEND_FAST_RET:
zend_resolve_finally_ret(op_array, i TSRMLS_CC); zend_resolve_finally_ret(op_array, i);
break; break;
default: default:
break; break;
@ -685,7 +684,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
} }
} }
ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) ZEND_API int pass_two(zend_op_array *op_array)
{ {
zend_op *opline, *end; zend_op *opline, *end;
@ -693,13 +692,13 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
return 0; return 0;
} }
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) { if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_resolve_finally_calls(op_array TSRMLS_CC); zend_resolve_finally_calls(op_array);
} }
if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) { if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {
zend_update_extended_info(op_array TSRMLS_CC); zend_update_extended_info(op_array);
} }
if (CG(compiler_options) & ZEND_COMPILE_HANDLE_OP_ARRAY) { if (CG(compiler_options) & ZEND_COMPILE_HANDLE_OP_ARRAY) {
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array TSRMLS_CC); zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array);
} }
if (CG(context).vars_size != op_array->last_var) { if (CG(context).vars_size != op_array->last_var) {
@ -737,7 +736,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
break; break;
case ZEND_GOTO: case ZEND_GOTO:
if (Z_TYPE_P(RT_CONSTANT(op_array, opline->op2)) != IS_LONG) { if (Z_TYPE_P(RT_CONSTANT(op_array, opline->op2)) != IS_LONG) {
zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC); zend_resolve_goto_label(op_array, opline, 1);
} }
/* break omitted intentionally */ /* break omitted intentionally */
case ZEND_JMP: case ZEND_JMP:
@ -779,15 +778,15 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
return 0; return 0;
} }
int pass_two_wrapper(zval *el TSRMLS_DC) int pass_two_wrapper(zval *el)
{ {
return pass_two((zend_op_array *) Z_PTR_P(el) TSRMLS_CC); return pass_two((zend_op_array *) Z_PTR_P(el));
} }
int print_class(zend_class_entry *class_entry TSRMLS_DC) int print_class(zend_class_entry *class_entry)
{ {
printf("Class %s:\n", class_entry->name->val); printf("Class %s:\n", class_entry->name->val);
zend_hash_apply(&class_entry->function_table, pass_two_wrapper TSRMLS_CC); zend_hash_apply(&class_entry->function_table, pass_two_wrapper);
printf("End of class %s.\n\n", class_entry->name->val); printf("End of class %s.\n\n", class_entry->name->val);
return 0; return 0;
} }

View file

@ -135,7 +135,7 @@ ZEND_API zend_long zend_atol(const char *str, int str_len) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */ ZEND_API void convert_scalar_to_number(zval *op) /* {{{ */
{ {
try_again: try_again:
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
@ -183,7 +183,7 @@ try_again:
#define zendi_convert_scalar_to_number(op, holder, result) \ #define zendi_convert_scalar_to_number(op, holder, result) \
if (op==result) { \ if (op==result) { \
if (Z_TYPE_P(op) != IS_LONG) { \ if (Z_TYPE_P(op) != IS_LONG) { \
convert_scalar_to_number(op TSRMLS_CC); \ convert_scalar_to_number(op); \
} \ } \
} else { \ } else { \
switch (Z_TYPE_P(op)) { \ switch (Z_TYPE_P(op)) { \
@ -224,13 +224,13 @@ try_again:
#define convert_object_to_type(op, dst, ctype, conv_func) \ #define convert_object_to_type(op, dst, ctype, conv_func) \
ZVAL_UNDEF(dst); \ ZVAL_UNDEF(dst); \
if (Z_OBJ_HT_P(op)->cast_object) { \ if (Z_OBJ_HT_P(op)->cast_object) { \
if (Z_OBJ_HT_P(op)->cast_object(op, dst, ctype TSRMLS_CC) == FAILURE) { \ if (Z_OBJ_HT_P(op)->cast_object(op, dst, ctype) == FAILURE) { \
zend_error(E_RECOVERABLE_ERROR, \ zend_error(E_RECOVERABLE_ERROR, \
"Object of class %s could not be converted to %s", Z_OBJCE_P(op)->name->val,\ "Object of class %s could not be converted to %s", Z_OBJCE_P(op)->name->val,\
zend_get_type_by_const(ctype)); \ zend_get_type_by_const(ctype)); \
} \ } \
} else if (Z_OBJ_HT_P(op)->get) { \ } else if (Z_OBJ_HT_P(op)->get) { \
zval *newop = Z_OBJ_HT_P(op)->get(op, dst TSRMLS_CC); \ zval *newop = Z_OBJ_HT_P(op)->get(op, dst); \
if (Z_TYPE_P(newop) != IS_OBJECT) { \ if (Z_TYPE_P(newop) != IS_OBJECT) { \
/* for safety - avoid loop */ \ /* for safety - avoid loop */ \
ZVAL_COPY_VALUE(dst, newop); \ ZVAL_COPY_VALUE(dst, newop); \
@ -289,8 +289,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
case IS_OBJECT: case IS_OBJECT:
{ {
zval dst; zval dst;
TSRMLS_FETCH();
convert_object_to_type(op, &dst, IS_LONG, convert_to_long); convert_object_to_type(op, &dst, IS_LONG, convert_to_long);
zval_dtor(op); zval_dtor(op);
@ -347,8 +346,7 @@ ZEND_API void convert_to_double(zval *op) /* {{{ */
case IS_OBJECT: case IS_OBJECT:
{ {
zval dst; zval dst;
TSRMLS_FETCH();
convert_object_to_type(op, &dst, IS_DOUBLE, convert_to_double); convert_object_to_type(op, &dst, IS_DOUBLE, convert_to_double);
zval_dtor(op); zval_dtor(op);
@ -371,10 +369,9 @@ ZEND_API void convert_to_null(zval *op) /* {{{ */
if (Z_TYPE_P(op) == IS_OBJECT) { if (Z_TYPE_P(op) == IS_OBJECT) {
if (Z_OBJ_HT_P(op)->cast_object) { if (Z_OBJ_HT_P(op)->cast_object) {
zval org; zval org;
TSRMLS_FETCH();
ZVAL_COPY_VALUE(&org, op); ZVAL_COPY_VALUE(&org, op);
if (Z_OBJ_HT_P(op)->cast_object(&org, op, IS_NULL TSRMLS_CC) == SUCCESS) { if (Z_OBJ_HT_P(op)->cast_object(&org, op, IS_NULL) == SUCCESS) {
zval_dtor(&org); zval_dtor(&org);
return; return;
} }
@ -432,8 +429,7 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */
case IS_OBJECT: case IS_OBJECT:
{ {
zval dst; zval dst;
TSRMLS_FETCH();
convert_object_to_type(op, &dst, _IS_BOOL, convert_to_boolean); convert_object_to_type(op, &dst, _IS_BOOL, convert_to_boolean);
zval_dtor(op); zval_dtor(op);
@ -461,8 +457,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
case IS_UNDEF: case IS_UNDEF:
case IS_NULL: case IS_NULL:
case IS_FALSE: { case IS_FALSE: {
TSRMLS_FETCH(); ZVAL_EMPTY_STRING(op);
ZVAL_EMPTY_STRING(op);
break; break;
} }
case IS_TRUE: case IS_TRUE:
@ -483,8 +478,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
case IS_DOUBLE: { case IS_DOUBLE: {
zend_string *str; zend_string *str;
double dval = Z_DVAL_P(op); double dval = Z_DVAL_P(op);
TSRMLS_FETCH();
str = zend_strpprintf(0, "%.*G", (int) EG(precision), dval); str = zend_strpprintf(0, "%.*G", (int) EG(precision), dval);
/* %G already handles removing trailing zeros from the fractional part, yay */ /* %G already handles removing trailing zeros from the fractional part, yay */
ZVAL_NEW_STR(op, str); ZVAL_NEW_STR(op, str);
@ -497,8 +491,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
break; break;
case IS_OBJECT: { case IS_OBJECT: {
zval dst; zval dst;
TSRMLS_FETCH();
convert_object_to_type(op, &dst, IS_STRING, convert_to_string); convert_object_to_type(op, &dst, IS_STRING, convert_to_string);
if (Z_TYPE(dst) == IS_STRING) { if (Z_TYPE(dst) == IS_STRING) {
@ -516,7 +509,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static void convert_scalar_to_array(zval *op TSRMLS_DC) /* {{{ */ static void convert_scalar_to_array(zval *op) /* {{{ */
{ {
zval entry; zval entry;
@ -530,7 +523,6 @@ static void convert_scalar_to_array(zval *op TSRMLS_DC) /* {{{ */
ZEND_API void convert_to_array(zval *op) /* {{{ */ ZEND_API void convert_to_array(zval *op) /* {{{ */
{ {
TSRMLS_FETCH();
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
case IS_ARRAY: case IS_ARRAY:
@ -538,10 +530,10 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */
/* OBJECTS_OPTIMIZE */ /* OBJECTS_OPTIMIZE */
case IS_OBJECT: case IS_OBJECT:
if (Z_OBJCE_P(op) == zend_ce_closure) { if (Z_OBJCE_P(op) == zend_ce_closure) {
convert_scalar_to_array(op TSRMLS_CC); convert_scalar_to_array(op);
} else { } else {
if (Z_OBJ_HT_P(op)->get_properties) { if (Z_OBJ_HT_P(op)->get_properties) {
HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op TSRMLS_CC); HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op);
if (obj_ht) { if (obj_ht) {
zval arr; zval arr;
ZVAL_NEW_ARR(&arr); ZVAL_NEW_ARR(&arr);
@ -570,7 +562,7 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */
zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0);
break; break;
default: default:
convert_scalar_to_array(op TSRMLS_CC); convert_scalar_to_array(op);
break; break;
} }
} }
@ -578,7 +570,6 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */
ZEND_API void convert_to_object(zval *op) /* {{{ */ ZEND_API void convert_to_object(zval *op) /* {{{ */
{ {
TSRMLS_FETCH();
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
case IS_ARRAY: case IS_ARRAY:
@ -657,7 +648,7 @@ ZEND_API void multi_convert_to_string_ex(int argc, ...) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API zend_long _zval_get_long_func(zval *op TSRMLS_DC) /* {{{ */ ZEND_API zend_long _zval_get_long_func(zval *op) /* {{{ */
{ {
try_again: try_again:
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
@ -696,7 +687,7 @@ try_again:
} }
/* }}} */ /* }}} */
ZEND_API double _zval_get_double_func(zval *op TSRMLS_DC) /* {{{ */ ZEND_API double _zval_get_double_func(zval *op) /* {{{ */
{ {
try_again: try_again:
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
@ -737,7 +728,7 @@ try_again:
} }
/* }}} */ /* }}} */
ZEND_API zend_string *_zval_get_string_func(zval *op TSRMLS_DC) /* {{{ */ ZEND_API zend_string *_zval_get_string_func(zval *op) /* {{{ */
{ {
try_again: try_again:
switch (Z_TYPE_P(op)) { switch (Z_TYPE_P(op)) {
@ -766,11 +757,11 @@ try_again:
case IS_OBJECT: { case IS_OBJECT: {
zval tmp; zval tmp;
if (Z_OBJ_HT_P(op)->cast_object) { if (Z_OBJ_HT_P(op)->cast_object) {
if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_STRING TSRMLS_CC) == SUCCESS) { if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_STRING) == SUCCESS) {
return Z_STR(tmp); return Z_STR(tmp);
} }
} else if (Z_OBJ_HT_P(op)->get) { } else if (Z_OBJ_HT_P(op)->get) {
zval *z = Z_OBJ_HT_P(op)->get(op, &tmp TSRMLS_CC); zval *z = Z_OBJ_HT_P(op)->get(op, &tmp);
if (Z_TYPE_P(z) != IS_OBJECT) { if (Z_TYPE_P(z) != IS_OBJECT) {
zend_string *str = zval_get_string(z); zend_string *str = zval_get_string(z);
zval_ptr_dtor(z); zval_ptr_dtor(z);
@ -792,7 +783,7 @@ try_again:
} }
/* }}} */ /* }}} */
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int add_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int converted = 0; int converted = 0;
@ -856,7 +847,7 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int sub_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int converted = 0; int converted = 0;
@ -909,7 +900,7 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int mul_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int converted = 0; int converted = 0;
@ -956,7 +947,7 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int pow_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int converted = 0; int converted = 0;
@ -1044,7 +1035,7 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int div_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int converted = 0; int converted = 0;
@ -1115,7 +1106,7 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int mod_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1129,7 +1120,7 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
} }
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_MOD, mod_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_MOD, mod_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
@ -1144,7 +1135,7 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
} }
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_MOD); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_MOD);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1167,7 +1158,7 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
int op1_val, op2_val; int op1_val, op2_val;
@ -1217,7 +1208,7 @@ ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
/* }}} */ /* }}} */
ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZEND_API int boolean_not_function(zval *result, zval *op1) /* {{{ */
{ {
if (Z_TYPE_P(op1) < IS_TRUE) { if (Z_TYPE_P(op1) < IS_TRUE) {
ZVAL_TRUE(result); ZVAL_TRUE(result);
@ -1242,7 +1233,7 @@ ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_not_function(zval *result, zval *op1) /* {{{ */
{ {
try_again: try_again:
switch (Z_TYPE_P(op1)) { switch (Z_TYPE_P(op1)) {
@ -1274,7 +1265,7 @@ try_again:
} }
/* }}} */ /* }}} */
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1313,13 +1304,13 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_OR, bitwise_or_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_OR, bitwise_or_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_OR); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_OR);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1329,7 +1320,7 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
} }
/* }}} */ /* }}} */
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1368,13 +1359,13 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_AND, bitwise_or_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_AND, bitwise_or_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_AND); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_AND);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1384,7 +1375,7 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
/* }}} */ /* }}} */
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1423,13 +1414,13 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_XOR, bitwise_or_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BW_XOR, bitwise_or_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) {
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_XOR); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BW_XOR);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1439,7 +1430,7 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
/* }}} */ /* }}} */
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1453,7 +1444,7 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
} }
} }
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SL, mod_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SL, mod_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
@ -1468,7 +1459,7 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
} }
} }
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SL); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SL);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1491,7 +1482,7 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
} }
/* }}} */ /* }}} */
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_long op1_lval, op2_lval; zend_long op1_lval, op2_lval;
@ -1505,7 +1496,7 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
} }
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SR, mod_function); ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_SR, mod_function);
op1_lval = _zval_get_long_func(op1 TSRMLS_CC); op1_lval = _zval_get_long_func(op1);
} else { } else {
op1_lval = Z_LVAL_P(op1); op1_lval = Z_LVAL_P(op1);
} }
@ -1520,7 +1511,7 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
} }
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SR); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_SR);
op2_lval = _zval_get_long_func(op2 TSRMLS_CC); op2_lval = _zval_get_long_func(op2);
} else { } else {
op2_lval = Z_LVAL_P(op2); op2_lval = Z_LVAL_P(op2);
} }
@ -1570,7 +1561,7 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
} }
/* }}} */ /* }}} */
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int concat_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zval op1_copy, op2_copy; zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0; int use_copy1 = 0, use_copy2 = 0;
@ -1582,7 +1573,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
if (Z_TYPE_P(op1) == IS_STRING) break; if (Z_TYPE_P(op1) == IS_STRING) break;
} }
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT, concat_function); ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT, concat_function);
use_copy1 = zend_make_printable_zval(op1, &op1_copy TSRMLS_CC); use_copy1 = zend_make_printable_zval(op1, &op1_copy);
if (use_copy1) { if (use_copy1) {
/* We have created a converted copy of op1. Therefore, op1 won't become the result so /* We have created a converted copy of op1. Therefore, op1 won't become the result so
* we have to free it. * we have to free it.
@ -1604,7 +1595,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
if (Z_TYPE_P(op2) == IS_STRING) break; if (Z_TYPE_P(op2) == IS_STRING) break;
} }
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_CONCAT); ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_CONCAT);
use_copy2 = zend_make_printable_zval(op2, &op2_copy TSRMLS_CC); use_copy2 = zend_make_printable_zval(op2, &op2_copy);
if (use_copy2) { if (use_copy2) {
op2 = &op2_copy; op2 = &op2_copy;
} }
@ -1648,7 +1639,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
} }
/* }}} */ /* }}} */
ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC) /* {{{ */ ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive) /* {{{ */
{ {
zend_string *str1 = zval_get_string(op1); zend_string *str1 = zval_get_string(op1);
zend_string *str2 = zval_get_string(op2); zend_string *str2 = zval_get_string(op2);
@ -1665,7 +1656,7 @@ ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend
} }
/* }}} */ /* }}} */
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) && if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) &&
EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
@ -1687,7 +1678,7 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
} }
/* }}} */ /* }}} */
ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) && if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) &&
EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
@ -1710,7 +1701,7 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR
/* }}} */ /* }}} */
#if HAVE_STRCOLL #if HAVE_STRCOLL
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
zend_string *str1 = zval_get_string(op1); zend_string *str1 = zval_get_string(op1);
zend_string *str2 = zval_get_string(op2); zend_string *str2 = zval_get_string(op2);
@ -1724,7 +1715,7 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T
/* }}} */ /* }}} */
#endif #endif
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
double d1, d2; double d1, d2;
@ -1737,7 +1728,7 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_
} }
/* }}} */ /* }}} */
static inline void zend_free_obj_get_result(zval *op TSRMLS_DC) /* {{{ */ static inline void zend_free_obj_get_result(zval *op) /* {{{ */
{ {
if (Z_REFCOUNTED_P(op)) { if (Z_REFCOUNTED_P(op)) {
if (Z_REFCOUNT_P(op) == 0) { if (Z_REFCOUNT_P(op) == 0) {
@ -1749,7 +1740,7 @@ static inline void zend_free_obj_get_result(zval *op TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int compare_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
int ret; int ret;
int converted = 0; int converted = 0;
@ -1782,7 +1773,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
return SUCCESS; return SUCCESS;
case TYPE_PAIR(IS_ARRAY, IS_ARRAY): case TYPE_PAIR(IS_ARRAY, IS_ARRAY):
zend_compare_arrays(result, op1, op2 TSRMLS_CC); zend_compare_arrays(result, op1, op2);
return SUCCESS; return SUCCESS;
case TYPE_PAIR(IS_NULL, IS_NULL): case TYPE_PAIR(IS_NULL, IS_NULL):
@ -1835,9 +1826,9 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
} }
if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, compare)) { if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, compare)) {
return Z_OBJ_HANDLER_P(op1, compare)(result, op1, op2 TSRMLS_CC); return Z_OBJ_HANDLER_P(op1, compare)(result, op1, op2);
} else if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, compare)) { } else if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, compare)) {
return Z_OBJ_HANDLER_P(op2, compare)(result, op1, op2 TSRMLS_CC); return Z_OBJ_HANDLER_P(op2, compare)(result, op1, op2);
} }
if (Z_TYPE_P(op1) == IS_OBJECT && Z_TYPE_P(op2) == IS_OBJECT) { if (Z_TYPE_P(op1) == IS_OBJECT && Z_TYPE_P(op2) == IS_OBJECT) {
@ -1847,45 +1838,45 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
return SUCCESS; return SUCCESS;
} }
if (Z_OBJ_HANDLER_P(op1, compare_objects) == Z_OBJ_HANDLER_P(op2, compare_objects)) { if (Z_OBJ_HANDLER_P(op1, compare_objects) == Z_OBJ_HANDLER_P(op2, compare_objects)) {
ZVAL_LONG(result, Z_OBJ_HANDLER_P(op1, compare_objects)(op1, op2 TSRMLS_CC)); ZVAL_LONG(result, Z_OBJ_HANDLER_P(op1, compare_objects)(op1, op2));
return SUCCESS; return SUCCESS;
} }
} }
if (Z_TYPE_P(op1) == IS_OBJECT) { if (Z_TYPE_P(op1) == IS_OBJECT) {
if (Z_OBJ_HT_P(op1)->get) { if (Z_OBJ_HT_P(op1)->get) {
zval rv; zval rv;
op_free = Z_OBJ_HT_P(op1)->get(op1, &rv TSRMLS_CC); op_free = Z_OBJ_HT_P(op1)->get(op1, &rv);
ret = compare_function(result, op_free, op2 TSRMLS_CC); ret = compare_function(result, op_free, op2);
zend_free_obj_get_result(op_free TSRMLS_CC); zend_free_obj_get_result(op_free);
return ret; return ret;
} else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) { } else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) {
ZVAL_UNDEF(&tmp_free); ZVAL_UNDEF(&tmp_free);
if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, ((Z_TYPE_P(op2) == IS_FALSE || Z_TYPE_P(op2) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op2)) TSRMLS_CC) == FAILURE) { if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, ((Z_TYPE_P(op2) == IS_FALSE || Z_TYPE_P(op2) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op2))) == FAILURE) {
ZVAL_LONG(result, 1); ZVAL_LONG(result, 1);
zend_free_obj_get_result(&tmp_free TSRMLS_CC); zend_free_obj_get_result(&tmp_free);
return SUCCESS; return SUCCESS;
} }
ret = compare_function(result, &tmp_free, op2 TSRMLS_CC); ret = compare_function(result, &tmp_free, op2);
zend_free_obj_get_result(&tmp_free TSRMLS_CC); zend_free_obj_get_result(&tmp_free);
return ret; return ret;
} }
} }
if (Z_TYPE_P(op2) == IS_OBJECT) { if (Z_TYPE_P(op2) == IS_OBJECT) {
if (Z_OBJ_HT_P(op2)->get) { if (Z_OBJ_HT_P(op2)->get) {
zval rv; zval rv;
op_free = Z_OBJ_HT_P(op2)->get(op2, &rv TSRMLS_CC); op_free = Z_OBJ_HT_P(op2)->get(op2, &rv);
ret = compare_function(result, op1, op_free TSRMLS_CC); ret = compare_function(result, op1, op_free);
zend_free_obj_get_result(op_free TSRMLS_CC); zend_free_obj_get_result(op_free);
return ret; return ret;
} else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) { } else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) {
ZVAL_UNDEF(&tmp_free); ZVAL_UNDEF(&tmp_free);
if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, ((Z_TYPE_P(op1) == IS_FALSE || Z_TYPE_P(op1) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op1)) TSRMLS_CC) == FAILURE) { if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, ((Z_TYPE_P(op1) == IS_FALSE || Z_TYPE_P(op1) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op1))) == FAILURE) {
ZVAL_LONG(result, -1); ZVAL_LONG(result, -1);
zend_free_obj_get_result(&tmp_free TSRMLS_CC); zend_free_obj_get_result(&tmp_free);
return SUCCESS; return SUCCESS;
} }
ret = compare_function(result, op1, &tmp_free TSRMLS_CC); ret = compare_function(result, op1, &tmp_free);
zend_free_obj_get_result(&tmp_free TSRMLS_CC); zend_free_obj_get_result(&tmp_free);
return ret; return ret;
} else if (Z_TYPE_P(op1) == IS_OBJECT) { } else if (Z_TYPE_P(op1) == IS_OBJECT) {
ZVAL_LONG(result, 1); ZVAL_LONG(result, 1);
@ -1931,7 +1922,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
} }
/* }}} */ /* }}} */
static int hash_zval_identical_function(zval *z1, zval *z2 TSRMLS_DC) /* {{{ */ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */
{ {
zval result; zval result;
@ -1942,14 +1933,14 @@ static int hash_zval_identical_function(zval *z1, zval *z2 TSRMLS_DC) /* {{{ */
*/ */
ZVAL_DEREF(z1); ZVAL_DEREF(z1);
ZVAL_DEREF(z2); ZVAL_DEREF(z2);
if (is_identical_function(&result, z1, z2 TSRMLS_CC)==FAILURE) { if (is_identical_function(&result, z1, z2)==FAILURE) {
return 1; return 1;
} }
return Z_TYPE(result) != IS_TRUE; return Z_TYPE(result) != IS_TRUE;
} }
/* }}} */ /* }}} */
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) { if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
ZVAL_BOOL(result, 0); ZVAL_BOOL(result, 0);
@ -1980,7 +1971,7 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
break; break;
case IS_ARRAY: case IS_ARRAY:
ZVAL_BOOL(result, Z_ARRVAL_P(op1) == Z_ARRVAL_P(op2) || ZVAL_BOOL(result, Z_ARRVAL_P(op1) == Z_ARRVAL_P(op2) ||
zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1 TSRMLS_CC)==0); zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1)==0);
break; break;
case IS_OBJECT: case IS_OBJECT:
if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) { if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) {
@ -1997,9 +1988,9 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
/* }}} */ /* }}} */
ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (is_identical_function(result, op1, op2 TSRMLS_CC) == FAILURE) { if (is_identical_function(result, op1, op2) == FAILURE) {
return FAILURE; return FAILURE;
} }
ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE); ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE);
@ -2007,9 +1998,9 @@ ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS
} }
/* }}} */ /* }}} */
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { if (compare_function(result, op1, op2) == FAILURE) {
return FAILURE; return FAILURE;
} }
ZVAL_BOOL(result, (Z_LVAL_P(result) == 0)); ZVAL_BOOL(result, (Z_LVAL_P(result) == 0));
@ -2017,9 +2008,9 @@ ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /*
} }
/* }}} */ /* }}} */
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { if (compare_function(result, op1, op2) == FAILURE) {
return FAILURE; return FAILURE;
} }
ZVAL_BOOL(result, (Z_LVAL_P(result) != 0)); ZVAL_BOOL(result, (Z_LVAL_P(result) != 0));
@ -2027,9 +2018,9 @@ ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
} }
/* }}} */ /* }}} */
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { if (compare_function(result, op1, op2) == FAILURE) {
return FAILURE; return FAILURE;
} }
ZVAL_BOOL(result, (Z_LVAL_P(result) < 0)); ZVAL_BOOL(result, (Z_LVAL_P(result) < 0));
@ -2037,9 +2028,9 @@ ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
} }
/* }}} */ /* }}} */
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */
{ {
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { if (compare_function(result, op1, op2) == FAILURE) {
return FAILURE; return FAILURE;
} }
ZVAL_BOOL(result, (Z_LVAL_P(result) <= 0)); ZVAL_BOOL(result, (Z_LVAL_P(result) <= 0));
@ -2047,12 +2038,12 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR
} }
/* }}} */ /* }}} */
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC) /* {{{ */ ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only) /* {{{ */
{ {
uint32_t i; uint32_t i;
for (i=0; i<instance_ce->num_interfaces; i++) { for (i=0; i<instance_ce->num_interfaces; i++) {
if (instanceof_function(instance_ce->interfaces[i], ce TSRMLS_CC)) { if (instanceof_function(instance_ce->interfaces[i], ce)) {
return 1; return 1;
} }
} }
@ -2069,9 +2060,9 @@ ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, c
} }
/* }}} */ /* }}} */
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC) /* {{{ */ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce) /* {{{ */
{ {
return instanceof_function_ex(instance_ce, ce, 0 TSRMLS_CC); return instanceof_function_ex(instance_ce, ce, 0);
} }
/* }}} */ /* }}} */
@ -2216,20 +2207,18 @@ try_again:
/* proxy object */ /* proxy object */
zval rv; zval rv;
zval *val; zval *val;
TSRMLS_FETCH();
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv);
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv TSRMLS_CC);
Z_ADDREF_P(val); Z_ADDREF_P(val);
fast_increment_function(val); fast_increment_function(val);
Z_OBJ_HANDLER_P(op1, set)(op1, val TSRMLS_CC); Z_OBJ_HANDLER_P(op1, set)(op1, val);
zval_ptr_dtor(val); zval_ptr_dtor(val);
} else if (Z_OBJ_HANDLER_P(op1, do_operation)) { } else if (Z_OBJ_HANDLER_P(op1, do_operation)) {
zval op2; zval op2;
int res; int res;
TSRMLS_FETCH();
ZVAL_LONG(&op2, 1); ZVAL_LONG(&op2, 1);
res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_ADD, op1, op1, &op2 TSRMLS_CC); res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_ADD, op1, op1, &op2);
zval_ptr_dtor(&op2); zval_ptr_dtor(&op2);
return res; return res;
@ -2291,20 +2280,18 @@ try_again:
/* proxy object */ /* proxy object */
zval rv; zval rv;
zval *val; zval *val;
TSRMLS_FETCH();
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv);
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv TSRMLS_CC);
Z_ADDREF_P(val); Z_ADDREF_P(val);
fast_decrement_function(val); fast_decrement_function(val);
Z_OBJ_HANDLER_P(op1, set)(op1, val TSRMLS_CC); Z_OBJ_HANDLER_P(op1, set)(op1, val);
zval_ptr_dtor(val); zval_ptr_dtor(val);
} else if (Z_OBJ_HANDLER_P(op1, do_operation)) { } else if (Z_OBJ_HANDLER_P(op1, do_operation)) {
zval op2; zval op2;
int res; int res;
TSRMLS_FETCH();
ZVAL_LONG(&op2, 1); ZVAL_LONG(&op2, 1);
res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_SUB, op1, op1, &op2 TSRMLS_CC); res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_SUB, op1, op1, &op2);
zval_ptr_dtor(&op2); zval_ptr_dtor(&op2);
return res; return res;
@ -2321,28 +2308,28 @@ try_again:
} }
/* }}} */ /* }}} */
ZEND_API int zend_is_true(zval *op TSRMLS_DC) /* {{{ */ ZEND_API int zend_is_true(zval *op) /* {{{ */
{ {
return i_zend_is_true(op TSRMLS_CC); return i_zend_is_true(op);
} }
/* }}} */ /* }}} */
ZEND_API int zend_object_is_true(zval *op TSRMLS_DC) /* {{{ */ ZEND_API int zend_object_is_true(zval *op) /* {{{ */
{ {
if (Z_OBJ_HT_P(op)->cast_object) { if (Z_OBJ_HT_P(op)->cast_object) {
zval tmp; zval tmp;
if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, _IS_BOOL TSRMLS_CC) == SUCCESS) { if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, _IS_BOOL) == SUCCESS) {
return Z_TYPE(tmp) == IS_TRUE; return Z_TYPE(tmp) == IS_TRUE;
} }
zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to boolean", Z_OBJ_P(op)->ce->name->val); zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to boolean", Z_OBJ_P(op)->ce->name->val);
} else if (Z_OBJ_HT_P(op)->get) { } else if (Z_OBJ_HT_P(op)->get) {
int result; int result;
zval rv; zval rv;
zval *tmp = Z_OBJ_HT_P(op)->get(op, &rv TSRMLS_CC); zval *tmp = Z_OBJ_HT_P(op)->get(op, &rv);
if (Z_TYPE_P(tmp) != IS_OBJECT) { if (Z_TYPE_P(tmp) != IS_OBJECT) {
/* for safety - avoid loop */ /* for safety - avoid loop */
result = i_zend_is_true(tmp TSRMLS_CC); result = i_zend_is_true(tmp);
zval_ptr_dtor(tmp); zval_ptr_dtor(tmp);
return result; return result;
} }
@ -2586,36 +2573,36 @@ string_cmp:
} }
/* }}} */ /* }}} */
static int hash_zval_compare_function(zval *z1, zval *z2 TSRMLS_DC) /* {{{ */ static int hash_zval_compare_function(zval *z1, zval *z2) /* {{{ */
{ {
zval result; zval result;
if (compare_function(&result, z1, z2 TSRMLS_CC)==FAILURE) { if (compare_function(&result, z1, z2)==FAILURE) {
return 1; return 1;
} }
return Z_LVAL(result); return Z_LVAL(result);
} }
/* }}} */ /* }}} */
ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */ ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2) /* {{{ */
{ {
return ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC); return ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0);
} }
/* }}} */ /* }}} */
ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */ ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2) /* {{{ */
{ {
ZVAL_LONG(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC)); ZVAL_LONG(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0));
} }
/* }}} */ /* }}} */
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC) /* {{{ */ ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2) /* {{{ */
{ {
zend_compare_symbol_tables(result, Z_ARRVAL_P(a1), Z_ARRVAL_P(a2) TSRMLS_CC); zend_compare_symbol_tables(result, Z_ARRVAL_P(a1), Z_ARRVAL_P(a2));
} }
/* }}} */ /* }}} */
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2) /* {{{ */
{ {
if (Z_OBJ_P(o1) == Z_OBJ_P(o2)) { if (Z_OBJ_P(o1) == Z_OBJ_P(o2)) {
ZVAL_LONG(result, 0); ZVAL_LONG(result, 0);
@ -2625,7 +2612,7 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) /
if (Z_OBJ_HT_P(o1)->compare_objects == NULL) { if (Z_OBJ_HT_P(o1)->compare_objects == NULL) {
ZVAL_LONG(result, 1); ZVAL_LONG(result, 1);
} else { } else {
ZVAL_LONG(result, Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC)); ZVAL_LONG(result, Z_OBJ_HT_P(o1)->compare_objects(o1, o2));
} }
} }
/* }}} */ /* }}} */
@ -2633,7 +2620,6 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) /
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */ ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */
{ {
zend_string *str; zend_string *str;
TSRMLS_FETCH();
str = zend_strpprintf(0, "%.*G", (int) EG(precision), (double)Z_DVAL_P(op)); str = zend_strpprintf(0, "%.*G", (int) EG(precision), (double)Z_DVAL_P(op));
ZVAL_NEW_STR(op, str); ZVAL_NEW_STR(op, str);

View file

@ -44,31 +44,31 @@
#define LONG_SIGN_MASK (((zend_long)1) << (8*sizeof(zend_long)-1)) #define LONG_SIGN_MASK (((zend_long)1) << (8*sizeof(zend_long)-1))
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int add_function(zval *result, zval *op1, zval *op2);
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int sub_function(zval *result, zval *op1, zval *op2);
ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int mul_function(zval *result, zval *op1, zval *op2);
ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int pow_function(zval *result, zval *op1, zval *op2);
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int div_function(zval *result, zval *op1, zval *op2);
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int mod_function(zval *result, zval *op1, zval *op2);
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2);
ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC); ZEND_API int boolean_not_function(zval *result, zval *op1);
ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC); ZEND_API int bitwise_not_function(zval *result, zval *op1);
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2);
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2);
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2);
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2);
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2);
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int concat_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC); ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only);
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC); ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce);
/** /**
* Checks whether the string "str" with length "length" is numeric. The value * Checks whether the string "str" with length "length" is numeric. The value
@ -221,7 +221,7 @@ BEGIN_EXTERN_C()
ZEND_API int increment_function(zval *op1); ZEND_API int increment_function(zval *op1);
ZEND_API int decrement_function(zval *op2); ZEND_API int decrement_function(zval *op2);
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC); ZEND_API void convert_scalar_to_number(zval *op);
ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC); ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC);
ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC); ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC);
ZEND_API void convert_to_long(zval *op); ZEND_API void convert_to_long(zval *op);
@ -235,23 +235,23 @@ ZEND_API void multi_convert_to_long_ex(int argc, ...);
ZEND_API void multi_convert_to_double_ex(int argc, ...); ZEND_API void multi_convert_to_double_ex(int argc, ...);
ZEND_API void multi_convert_to_string_ex(int argc, ...); ZEND_API void multi_convert_to_string_ex(int argc, ...);
ZEND_API zend_long _zval_get_long_func(zval *op TSRMLS_DC); ZEND_API zend_long _zval_get_long_func(zval *op);
ZEND_API double _zval_get_double_func(zval *op TSRMLS_DC); ZEND_API double _zval_get_double_func(zval *op);
ZEND_API zend_string *_zval_get_string_func(zval *op TSRMLS_DC); ZEND_API zend_string *_zval_get_string_func(zval *op);
static zend_always_inline zend_long _zval_get_long(zval *op TSRMLS_DC) { static zend_always_inline zend_long _zval_get_long(zval *op) {
return Z_TYPE_P(op) == IS_LONG ? Z_LVAL_P(op) : _zval_get_long_func(op TSRMLS_CC); return Z_TYPE_P(op) == IS_LONG ? Z_LVAL_P(op) : _zval_get_long_func(op);
} }
static zend_always_inline double _zval_get_double(zval *op TSRMLS_DC) { static zend_always_inline double _zval_get_double(zval *op) {
return Z_TYPE_P(op) == IS_DOUBLE ? Z_DVAL_P(op) : _zval_get_double_func(op TSRMLS_CC); return Z_TYPE_P(op) == IS_DOUBLE ? Z_DVAL_P(op) : _zval_get_double_func(op);
} }
static zend_always_inline zend_string *_zval_get_string(zval *op TSRMLS_DC) { static zend_always_inline zend_string *_zval_get_string(zval *op) {
return Z_TYPE_P(op) == IS_STRING ? zend_string_copy(Z_STR_P(op)) : _zval_get_string_func(op TSRMLS_CC); return Z_TYPE_P(op) == IS_STRING ? zend_string_copy(Z_STR_P(op)) : _zval_get_string_func(op);
} }
#define zval_get_long(op) _zval_get_long((op) TSRMLS_CC) #define zval_get_long(op) _zval_get_long((op))
#define zval_get_double(op) _zval_get_double((op) TSRMLS_CC) #define zval_get_double(op) _zval_get_double((op))
#define zval_get_string(op) _zval_get_string((op) TSRMLS_CC) #define zval_get_string(op) _zval_get_string((op))
ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2); ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2);
ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2); ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2);
@ -259,13 +259,13 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); } #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
ZEND_API int zend_is_true(zval *op TSRMLS_DC); ZEND_API int zend_is_true(zval *op);
ZEND_API int zend_object_is_true(zval *op TSRMLS_DC); ZEND_API int zend_object_is_true(zval *op);
#define zval_is_true(op) \ #define zval_is_true(op) \
zend_is_true(op TSRMLS_CC) zend_is_true(op)
static zend_always_inline int i_zend_is_true(zval *op TSRMLS_DC) static zend_always_inline int i_zend_is_true(zval *op)
{ {
int result; int result;
@ -300,7 +300,7 @@ again:
result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
break; break;
case IS_OBJECT: case IS_OBJECT:
result = zend_object_is_true(op TSRMLS_CC); result = zend_object_is_true(op);
break; break;
case IS_REFERENCE: case IS_REFERENCE:
op = Z_REFVAL_P(op); op = Z_REFVAL_P(op);
@ -313,13 +313,13 @@ again:
return result; return result;
} }
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int compare_function(zval *result, zval *op1, zval *op2);
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2);
ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC); ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive);
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2);
ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2);
#if HAVE_STRCOLL #if HAVE_STRCOLL
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2);
#endif #endif
ZEND_API void zend_str_tolower(char *str, size_t length); ZEND_API void zend_str_tolower(char *str, size_t length);
@ -338,9 +338,9 @@ ZEND_API int zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s
ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length); ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2); ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC); ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2);
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC); ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2);
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC); ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2);
ZEND_API int zend_atoi(const char *str, int str_len); ZEND_API int zend_atoi(const char *str, int str_len);
ZEND_API zend_long zend_atol(const char *str, int str_len); ZEND_API zend_long zend_atol(const char *str, int str_len);
@ -400,7 +400,7 @@ ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
#define convert_scalar_to_number_ex(pzv) \ #define convert_scalar_to_number_ex(pzv) \
if (Z_TYPE_P(pzv)!=IS_LONG && Z_TYPE_P(pzv)!=IS_DOUBLE) { \ if (Z_TYPE_P(pzv)!=IS_LONG && Z_TYPE_P(pzv)!=IS_DOUBLE) { \
SEPARATE_ZVAL_IF_NOT_REF(pzv); \ SEPARATE_ZVAL_IF_NOT_REF(pzv); \
convert_scalar_to_number(pzv TSRMLS_CC); \ convert_scalar_to_number(pzv); \
} }
#if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER) && (_MSC_VER >= 1400) #if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER) && (_MSC_VER >= 1400)
@ -558,7 +558,7 @@ static zend_always_inline int fast_decrement_function(zval *op1)
return decrement_function(op1); return decrement_function(op1);
} }
static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -666,10 +666,10 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o
return SUCCESS; return SUCCESS;
} }
} }
return add_function(result, op1, op2 TSRMLS_CC); return add_function(result, op1, op2);
} }
static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -779,10 +779,10 @@ static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *o
return SUCCESS; return SUCCESS;
} }
} }
return sub_function(result, op1, op2 TSRMLS_CC); return sub_function(result, op1, op2);
} }
static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -804,10 +804,10 @@ static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *o
return SUCCESS; return SUCCESS;
} }
} }
return mul_function(result, op1, op2 TSRMLS_CC); return mul_function(result, op1, op2);
} }
static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2)
{ {
#if 0 #if 0
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) {
@ -855,10 +855,10 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o
} }
} }
#endif #endif
return div_function(result, op1, op2 TSRMLS_CC); return div_function(result, op1, op2);
} }
static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -875,10 +875,10 @@ static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *o
return SUCCESS; return SUCCESS;
} }
} }
return mod_function(result, op1, op2 TSRMLS_CC); return mod_function(result, op1, op2);
} }
static zend_always_inline int fast_equal_check_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline int fast_equal_check_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -908,11 +908,11 @@ static zend_always_inline int fast_equal_check_function(zval *result, zval *op1,
} }
} }
} }
compare_function(result, op1, op2 TSRMLS_CC); compare_function(result, op1, op2);
return Z_LVAL_P(result) == 0; return Z_LVAL_P(result) == 0;
} }
static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -950,11 +950,11 @@ static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval
} }
} }
} }
compare_function(result, op1, op2 TSRMLS_CC); compare_function(result, op1, op2);
ZVAL_BOOL(result, Z_LVAL_P(result) == 0); ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
} }
static zend_always_inline void fast_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_not_equal_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -992,11 +992,11 @@ static zend_always_inline void fast_not_equal_function(zval *result, zval *op1,
} }
} }
} }
compare_function(result, op1, op2 TSRMLS_CC); compare_function(result, op1, op2);
ZVAL_BOOL(result, Z_LVAL_P(result) != 0); ZVAL_BOOL(result, Z_LVAL_P(result) != 0);
} }
static zend_always_inline void fast_is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_is_smaller_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -1015,11 +1015,11 @@ static zend_always_inline void fast_is_smaller_function(zval *result, zval *op1,
return; return;
} }
} }
compare_function(result, op1, op2 TSRMLS_CC); compare_function(result, op1, op2);
ZVAL_BOOL(result, Z_LVAL_P(result) < 0); ZVAL_BOOL(result, Z_LVAL_P(result) < 0);
} }
static zend_always_inline void fast_is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_is_smaller_or_equal_function(zval *result, zval *op1, zval *op2)
{ {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
@ -1038,26 +1038,26 @@ static zend_always_inline void fast_is_smaller_or_equal_function(zval *result, z
return; return;
} }
} }
compare_function(result, op1, op2 TSRMLS_CC); compare_function(result, op1, op2);
ZVAL_BOOL(result, Z_LVAL_P(result) <= 0); ZVAL_BOOL(result, Z_LVAL_P(result) <= 0);
} }
static zend_always_inline void fast_is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_is_identical_function(zval *result, zval *op1, zval *op2)
{ {
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) { if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
ZVAL_BOOL(result, 0); ZVAL_BOOL(result, 0);
return; return;
} }
is_identical_function(result, op1, op2 TSRMLS_CC); is_identical_function(result, op1, op2);
} }
static zend_always_inline void fast_is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) static zend_always_inline void fast_is_not_identical_function(zval *result, zval *op1, zval *op2)
{ {
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) { if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
ZVAL_BOOL(result, 1); ZVAL_BOOL(result, 1);
return; return;
} }
is_identical_function(result, op1, op2 TSRMLS_CC); is_identical_function(result, op1, op2);
ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE); ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE);
} }
@ -1068,15 +1068,15 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
&& EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \ && EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \
int ret; \ int ret; \
zval rv; \ zval rv; \
zval *objval = Z_OBJ_HANDLER_P(op1, get)(op1, &rv TSRMLS_CC); \ zval *objval = Z_OBJ_HANDLER_P(op1, get)(op1, &rv); \
Z_ADDREF_P(objval); \ Z_ADDREF_P(objval); \
ret = binary_op(objval, objval, op2 TSRMLS_CC); \ ret = binary_op(objval, objval, op2); \
Z_OBJ_HANDLER_P(op1, set)(op1, objval TSRMLS_CC); \ Z_OBJ_HANDLER_P(op1, set)(op1, objval); \
zval_ptr_dtor(objval); \ zval_ptr_dtor(objval); \
return ret; \ return ret; \
} else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ } else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \ && UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \
if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2 TSRMLS_CC))) { \ if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2))) { \
return SUCCESS; \ return SUCCESS; \
} \ } \
} }
@ -1084,7 +1084,7 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
#define ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(opcode) \ #define ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(opcode) \
if (UNEXPECTED(Z_TYPE_P(op2) == IS_OBJECT) \ if (UNEXPECTED(Z_TYPE_P(op2) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op2, do_operation)) \ && UNEXPECTED(Z_OBJ_HANDLER_P(op2, do_operation)) \
&& EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op2, do_operation)(opcode, result, op1, op2 TSRMLS_CC))) { \ && EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op2, do_operation)(opcode, result, op1, op2))) { \
return SUCCESS; \ return SUCCESS; \
} }
@ -1096,7 +1096,7 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
#define ZEND_TRY_UNARY_OBJECT_OPERATION(opcode) \ #define ZEND_TRY_UNARY_OBJECT_OPERATION(opcode) \
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation)) \ && UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation)) \
&& EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, NULL TSRMLS_CC))) { \ && EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, NULL))) { \
return SUCCESS; \ return SUCCESS; \
} }

View file

@ -54,7 +54,7 @@ static void _zend_qsort_swap(void *a, void *b, size_t siz)
} }
} }
ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg TSRMLS_DC) ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg)
{ {
void *begin_stack[QSORT_STACK_SIZE]; void *begin_stack[QSORT_STACK_SIZE];
void *end_stack[QSORT_STACK_SIZE]; void *end_stack[QSORT_STACK_SIZE];
@ -81,10 +81,10 @@ ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_
seg2 = end; seg2 = end;
while (1) { while (1) {
for (; seg1 < seg2 && compare(begin, seg1 TSRMLS_CC, arg) > 0; for (; seg1 < seg2 && compare(begin, seg1, arg) > 0;
seg1 += siz); seg1 += siz);
for (; seg2 >= seg1 && compare(seg2, begin TSRMLS_CC, arg) > 0; for (; seg2 >= seg1 && compare(seg2, begin, arg) > 0;
seg2 -= siz); seg2 -= siz);
if (seg1 >= seg2) if (seg1 >= seg2)
@ -118,9 +118,9 @@ ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_
} }
} }
ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare TSRMLS_DC) ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare)
{ {
zend_qsort_r(base, nmemb, siz, (compare_r_func_t)compare, NULL TSRMLS_CC); zend_qsort_r(base, nmemb, siz, (compare_r_func_t)compare, NULL);
} }
/* /*

View file

@ -22,9 +22,9 @@
#define ZEND_QSORT_H #define ZEND_QSORT_H
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
typedef int (*compare_r_func_t)(const void *, const void * TSRMLS_DC, void *); typedef int (*compare_r_func_t)(const void *, const void *, void *);
ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare TSRMLS_DC); ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare);
ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg TSRMLS_DC); ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg);
END_EXTERN_C() END_EXTERN_C()
#endif /* ZEND_QSORT_H */ #endif /* ZEND_QSORT_H */

View file

@ -51,8 +51,8 @@ ZEND_API int zend_signal_globals_id;
zend_signal_globals_t zend_signal_globals; zend_signal_globals_t zend_signal_globals;
#endif #endif
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context TSRMLS_DC); static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context);
static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*) TSRMLS_DC); static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*));
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#define TIMEOUT_SIG SIGALRM #define TIMEOUT_SIG SIGALRM
@ -74,7 +74,6 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
{ {
int errno_save = errno; int errno_save = errno;
zend_signal_queue_t *queue, *qtmp; zend_signal_queue_t *queue, *qtmp;
TSRMLS_FETCH();
if (SIGG(active)) { if (SIGG(active)) {
if (SIGG(depth) == 0) { /* try to handle signal */ if (SIGG(depth) == 0) { /* try to handle signal */
@ -83,13 +82,13 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
} }
if (SIGG(running) == 0) { if (SIGG(running) == 0) {
SIGG(running) = 1; SIGG(running) = 1;
zend_signal_handler(signo, siginfo, context TSRMLS_CC); zend_signal_handler(signo, siginfo, context);
queue = SIGG(phead); queue = SIGG(phead);
SIGG(phead) = NULL; SIGG(phead) = NULL;
while (queue) { while (queue) {
zend_signal_handler(queue->zend_signal.signo, queue->zend_signal.siginfo, queue->zend_signal.context TSRMLS_CC); zend_signal_handler(queue->zend_signal.signo, queue->zend_signal.siginfo, queue->zend_signal.context);
qtmp = queue->next; qtmp = queue->next;
queue->next = SIGG(pavail); queue->next = SIGG(pavail);
queue->zend_signal.signo = 0; queue->zend_signal.signo = 0;
@ -123,7 +122,7 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
} }
} else { } else {
/* need to just run handler if we're inactive and getting a signal */ /* need to just run handler if we're inactive and getting a signal */
zend_signal_handler(signo, siginfo, context TSRMLS_CC); zend_signal_handler(signo, siginfo, context);
} }
errno = errno_save; errno = errno_save;
@ -131,7 +130,7 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
/* {{{ zend_signal_handler_unblock /* {{{ zend_signal_handler_unblock
* Handle deferred signal from HANDLE_UNBLOCK_ALARMS */ * Handle deferred signal from HANDLE_UNBLOCK_ALARMS */
ZEND_API void zend_signal_handler_unblock(TSRMLS_D) ZEND_API void zend_signal_handler_unblock(void)
{ {
zend_signal_queue_t *queue; zend_signal_queue_t *queue;
zend_signal_t zend_signal; zend_signal_t zend_signal;
@ -154,7 +153,7 @@ ZEND_API void zend_signal_handler_unblock(TSRMLS_D)
/* {{{ zend_signal_handler /* {{{ zend_signal_handler
* Call the previously registered handler for a signal * Call the previously registered handler for a signal
*/ */
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context TSRMLS_DC) static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context)
{ {
int errno_save = errno; int errno_save = errno;
struct sigaction sa = {{0}}; struct sigaction sa = {{0}};
@ -192,7 +191,7 @@ static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context TSR
/* {{{ zend_sigaction /* {{{ zend_sigaction
* Register a signal handler that will be deferred in critical sections */ * Register a signal handler that will be deferred in critical sections */
ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact TSRMLS_DC) ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact)
{ {
struct sigaction sa = {{0}}; struct sigaction sa = {{0}};
sigset_t sigset; sigset_t sigset;
@ -230,7 +229,7 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac
/* {{{ zend_signal /* {{{ zend_signal
* Register a signal handler that will be deferred in critical sections */ * Register a signal handler that will be deferred in critical sections */
ZEND_API int zend_signal(int signo, void (*handler)(int) TSRMLS_DC) ZEND_API int zend_signal(int signo, void (*handler)(int))
{ {
struct sigaction sa = {{0}}; struct sigaction sa = {{0}};
@ -238,7 +237,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int) TSRMLS_DC)
sa.sa_handler = handler; sa.sa_handler = handler;
sa.sa_mask = global_sigmask; sa.sa_mask = global_sigmask;
return zend_sigaction(signo, &sa, NULL TSRMLS_CC); return zend_sigaction(signo, &sa, NULL);
} }
/* }}} */ /* }}} */
@ -246,7 +245,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int) TSRMLS_DC)
* Set a handler for a signal we want to defer. * Set a handler for a signal we want to defer.
* Previously set handler must have been saved before. * Previously set handler must have been saved before.
*/ */
static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*) TSRMLS_DC) static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*))
{ {
struct sigaction sa = {{0}}; struct sigaction sa = {{0}};
@ -277,14 +276,14 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void
/* {{{ zend_signal_activate /* {{{ zend_signal_activate
* Install our signal handlers, per request */ * Install our signal handlers, per request */
void zend_signal_activate(TSRMLS_D) void zend_signal_activate(void)
{ {
int x; int x;
memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers)); memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
for (x=0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) { for (x=0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
zend_signal_register(zend_sigs[x], zend_signal_handler_defer TSRMLS_CC); zend_signal_register(zend_sigs[x], zend_signal_handler_defer);
} }
SIGG(active) = 1; SIGG(active) = 1;
@ -293,7 +292,7 @@ void zend_signal_activate(TSRMLS_D)
/* {{{ zend_signal_deactivate /* {{{ zend_signal_deactivate
* */ * */
void zend_signal_deactivate(TSRMLS_D) void zend_signal_deactivate(void)
{ {
int x; int x;
struct sigaction sa = {{0}}; struct sigaction sa = {{0}};
@ -320,7 +319,7 @@ void zend_signal_deactivate(TSRMLS_D)
} }
/* }}} */ /* }}} */
static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals TSRMLS_DC) static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals)
{ {
size_t x; size_t x;
@ -335,7 +334,7 @@ static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals
} }
} }
static void zend_signal_globals_dtor(zend_signal_globals_t *zend_signal_globals TSRMLS_DC) static void zend_signal_globals_dtor(zend_signal_globals_t *zend_signal_globals)
{ {
zend_signal_globals->blocked = -1; zend_signal_globals->blocked = -1;
} }
@ -392,7 +391,7 @@ void zend_signal_startup()
/* {{{ zend_signal_shutdown /* {{{ zend_signal_shutdown
* called by zend_shutdown */ * called by zend_shutdown */
void zend_signal_shutdown(TSRMLS_D) void zend_signal_shutdown(void)
{ {
#ifndef ZTS #ifndef ZTS
zend_signal_globals_dtor(&zend_signal_globals); zend_signal_globals_dtor(&zend_signal_globals);

View file

@ -70,12 +70,12 @@ BEGIN_EXTERN_C()
ZEND_API extern int zend_signal_globals_id; ZEND_API extern int zend_signal_globals_id;
END_EXTERN_C() END_EXTERN_C()
# define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; } # define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED((--SIGG(depth))==SIGG(blocked))) { zend_signal_handler_unblock(TSRMLS_C); } # define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED((--SIGG(depth))==SIGG(blocked))) { zend_signal_handler_unblock(); }
#else /* ZTS */ #else /* ZTS */
# define SIGG(v) (zend_signal_globals.v) # define SIGG(v) (zend_signal_globals.v)
extern ZEND_API zend_signal_globals_t zend_signal_globals; extern ZEND_API zend_signal_globals_t zend_signal_globals;
# define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() SIGG(depth)++; # define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() SIGG(depth)++;
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (UNEXPECTED((--SIGG(depth))==SIGG(blocked))) { zend_signal_handler_unblock(TSRMLS_C); } # define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (UNEXPECTED((--SIGG(depth))==SIGG(blocked))) { zend_signal_handler_unblock(); }
#endif /* not ZTS */ #endif /* not ZTS */
# define SIGNAL_BEGIN_CRITICAL() sigset_t oldmask; \ # define SIGNAL_BEGIN_CRITICAL() sigset_t oldmask; \
@ -84,12 +84,12 @@ extern ZEND_API zend_signal_globals_t zend_signal_globals;
void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context); void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context);
ZEND_API void zend_signal_handler_unblock(); ZEND_API void zend_signal_handler_unblock();
void zend_signal_activate(TSRMLS_D); void zend_signal_activate(void);
void zend_signal_deactivate(TSRMLS_D); void zend_signal_deactivate(void);
void zend_signal_startup(); void zend_signal_startup();
void zend_signal_shutdown(TSRMLS_D); void zend_signal_shutdown(void);
ZEND_API int zend_signal(int signo, void (*handler)(int) TSRMLS_DC); ZEND_API int zend_signal(int signo, void (*handler)(int));
ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact TSRMLS_DC); ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact);
#ifdef ZTS #ifdef ZTS
#define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset)) #define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))

View file

@ -49,19 +49,19 @@
ZEND_DLIMPORT int isatty(int fd); ZEND_DLIMPORT int isatty(int fd);
static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len TSRMLS_DC) /* {{{ */ static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len) /* {{{ */
{ {
return fread(buf, 1, len, (FILE*)handle); return fread(buf, 1, len, (FILE*)handle);
} /* }}} */ } /* }}} */
static void zend_stream_stdio_closer(void *handle TSRMLS_DC) /* {{{ */ static void zend_stream_stdio_closer(void *handle) /* {{{ */
{ {
if (handle && (FILE*)handle != stdin) { if (handle && (FILE*)handle != stdin) {
fclose((FILE*)handle); fclose((FILE*)handle);
} }
} /* }}} */ } /* }}} */
static size_t zend_stream_stdio_fsizer(void *handle TSRMLS_DC) /* {{{ */ static size_t zend_stream_stdio_fsizer(void *handle) /* {{{ */
{ {
zend_stat_t buf; zend_stat_t buf;
if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) { if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) {
@ -75,7 +75,7 @@ static size_t zend_stream_stdio_fsizer(void *handle TSRMLS_DC) /* {{{ */
return 0; return 0;
} /* }}} */ } /* }}} */
static void zend_stream_unmap(zend_stream *stream TSRMLS_DC) { /* {{{ */ static void zend_stream_unmap(zend_stream *stream) { /* {{{ */
#if HAVE_MMAP #if HAVE_MMAP
if (stream->mmap.map) { if (stream->mmap.map) {
munmap(stream->mmap.map, stream->mmap.len + ZEND_MMAP_AHEAD); munmap(stream->mmap.map, stream->mmap.len + ZEND_MMAP_AHEAD);
@ -91,11 +91,11 @@ static void zend_stream_unmap(zend_stream *stream TSRMLS_DC) { /* {{{ */
stream->handle = stream->mmap.old_handle; stream->handle = stream->mmap.old_handle;
} /* }}} */ } /* }}} */
static void zend_stream_mmap_closer(zend_stream *stream TSRMLS_DC) /* {{{ */ static void zend_stream_mmap_closer(zend_stream *stream) /* {{{ */
{ {
zend_stream_unmap(stream TSRMLS_CC); zend_stream_unmap(stream);
if (stream->mmap.old_closer && stream->handle) { if (stream->mmap.old_closer && stream->handle) {
stream->mmap.old_closer(stream->handle TSRMLS_CC); stream->mmap.old_closer(stream->handle);
} }
} /* }}} */ } /* }}} */
@ -103,7 +103,7 @@ static inline int zend_stream_is_mmap(zend_file_handle *file_handle) { /* {{{ */
return file_handle->type == ZEND_HANDLE_MAPPED; return file_handle->type == ZEND_HANDLE_MAPPED;
} /* }}} */ } /* }}} */
static size_t zend_stream_fsize(zend_file_handle *file_handle TSRMLS_DC) /* {{{ */ static size_t zend_stream_fsize(zend_file_handle *file_handle) /* {{{ */
{ {
zend_stat_t buf; zend_stat_t buf;
@ -111,7 +111,7 @@ static size_t zend_stream_fsize(zend_file_handle *file_handle TSRMLS_DC) /* {{{
return file_handle->handle.stream.mmap.len; return file_handle->handle.stream.mmap.len;
} }
if (file_handle->type == ZEND_HANDLE_STREAM || file_handle->type == ZEND_HANDLE_MAPPED) { if (file_handle->type == ZEND_HANDLE_STREAM || file_handle->type == ZEND_HANDLE_MAPPED) {
return file_handle->handle.stream.fsizer(file_handle->handle.stream.handle TSRMLS_CC); return file_handle->handle.stream.fsizer(file_handle->handle.stream.handle);
} }
if (file_handle->handle.fp && zend_fstat(fileno(file_handle->handle.fp), &buf) == 0) { if (file_handle->handle.fp && zend_fstat(fileno(file_handle->handle.fp), &buf) == 0) {
#ifdef S_ISREG #ifdef S_ISREG
@ -125,14 +125,14 @@ static size_t zend_stream_fsize(zend_file_handle *file_handle TSRMLS_DC) /* {{{
return -1; return -1;
} /* }}} */ } /* }}} */
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */ ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */
{ {
if (zend_stream_open_function) { if (zend_stream_open_function) {
return zend_stream_open_function(filename, handle TSRMLS_CC); return zend_stream_open_function(filename, handle);
} }
handle->type = ZEND_HANDLE_FP; handle->type = ZEND_HANDLE_FP;
handle->opened_path = NULL; handle->opened_path = NULL;
handle->handle.fp = zend_fopen(filename, &handle->opened_path TSRMLS_CC); handle->handle.fp = zend_fopen(filename, &handle->opened_path);
handle->filename = filename; handle->filename = filename;
handle->free_filename = 0; handle->free_filename = 0;
memset(&handle->handle.stream.mmap, 0, sizeof(zend_mmap)); memset(&handle->handle.stream.mmap, 0, sizeof(zend_mmap));
@ -140,17 +140,17 @@ ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSR
return (handle->handle.fp) ? SUCCESS : FAILURE; return (handle->handle.fp) ? SUCCESS : FAILURE;
} /* }}} */ } /* }}} */
static int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC) /* {{{ */ static int zend_stream_getc(zend_file_handle *file_handle) /* {{{ */
{ {
char buf; char buf;
if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf) TSRMLS_CC)) { if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf))) {
return (int)buf; return (int)buf;
} }
return EOF; return EOF;
} /* }}} */ } /* }}} */
static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC) /* {{{ */ static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len) /* {{{ */
{ {
if (!zend_stream_is_mmap(file_handle) && file_handle->handle.stream.isatty) { if (!zend_stream_is_mmap(file_handle) && file_handle->handle.stream.isatty) {
int c = '*'; int c = '*';
@ -162,9 +162,9 @@ static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t
Ascii value 4 is actually EOT character which is not defined anywhere in the LibC Ascii value 4 is actually EOT character which is not defined anywhere in the LibC
or else we can use instead of hardcoded 4. or else we can use instead of hardcoded 4.
*/ */
for (n = 0; n < len && (c = zend_stream_getc(file_handle TSRMLS_CC)) != EOF && c != 4 && c != '\n'; ++n) { for (n = 0; n < len && (c = zend_stream_getc(file_handle)) != EOF && c != 4 && c != '\n'; ++n) {
#else #else
for (n = 0; n < len && (c = zend_stream_getc(file_handle TSRMLS_CC)) != EOF && c != '\n'; ++n) { for (n = 0; n < len && (c = zend_stream_getc(file_handle)) != EOF && c != '\n'; ++n) {
#endif #endif
buf[n] = (char)c; buf[n] = (char)c;
} }
@ -174,16 +174,16 @@ static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t
return n; return n;
} }
return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len TSRMLS_CC); return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len);
} /* }}} */ } /* }}} */
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len TSRMLS_DC) /* {{{ */ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */
{ {
size_t size; size_t size;
zend_stream_type old_type; zend_stream_type old_type;
if (file_handle->type == ZEND_HANDLE_FILENAME) { if (file_handle->type == ZEND_HANDLE_FILENAME) {
if (zend_stream_open(file_handle->filename, file_handle TSRMLS_CC) == FAILURE) { if (zend_stream_open(file_handle->filename, file_handle) == FAILURE) {
return FAILURE; return FAILURE;
} }
} }
@ -218,7 +218,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
return FAILURE; return FAILURE;
} }
size = zend_stream_fsize(file_handle TSRMLS_CC); size = zend_stream_fsize(file_handle);
if (size == (size_t)-1) { if (size == (size_t)-1) {
return FAILURE; return FAILURE;
} }
@ -252,13 +252,13 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
#endif #endif
file_handle->handle.stream.mmap.map = 0; file_handle->handle.stream.mmap.map = 0;
file_handle->handle.stream.mmap.buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD); file_handle->handle.stream.mmap.buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD);
file_handle->handle.stream.mmap.len = zend_stream_read(file_handle, *buf, size TSRMLS_CC); file_handle->handle.stream.mmap.len = zend_stream_read(file_handle, *buf, size);
} else { } else {
size_t read, remain = 4*1024; size_t read, remain = 4*1024;
*buf = emalloc(remain); *buf = emalloc(remain);
size = 0; size = 0;
while ((read = zend_stream_read(file_handle, *buf + size, remain TSRMLS_CC)) > 0) { while ((read = zend_stream_read(file_handle, *buf + size, remain)) > 0) {
size += read; size += read;
remain -= read; remain -= read;
@ -299,7 +299,7 @@ return_mapped:
return SUCCESS; return SUCCESS;
} /* }}} */ } /* }}} */
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC) /* {{{ */ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */
{ {
switch (fh->type) { switch (fh->type) {
case ZEND_HANDLE_FD: case ZEND_HANDLE_FD:
@ -311,7 +311,7 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC) /* {{{ */
case ZEND_HANDLE_STREAM: case ZEND_HANDLE_STREAM:
case ZEND_HANDLE_MAPPED: case ZEND_HANDLE_MAPPED:
if (fh->handle.stream.closer && fh->handle.stream.handle) { if (fh->handle.stream.closer && fh->handle.stream.handle) {
fh->handle.stream.closer(fh->handle.stream.handle TSRMLS_CC); fh->handle.stream.closer(fh->handle.stream.handle);
} }
fh->handle.stream.handle = NULL; fh->handle.stream.handle = NULL;
break; break;

View file

@ -30,9 +30,9 @@
/* Lightweight stream implementation for the ZE scanners. /* Lightweight stream implementation for the ZE scanners.
* These functions are private to the engine. * These functions are private to the engine.
* */ * */
typedef size_t (*zend_stream_fsizer_t)(void* handle TSRMLS_DC); typedef size_t (*zend_stream_fsizer_t)(void* handle);
typedef size_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len TSRMLS_DC); typedef size_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len);
typedef void (*zend_stream_closer_t)(void* handle TSRMLS_DC); typedef void (*zend_stream_closer_t)(void* handle);
#define ZEND_MMAP_AHEAD 32 #define ZEND_MMAP_AHEAD 32
@ -75,9 +75,9 @@ typedef struct _zend_file_handle {
} zend_file_handle; } zend_file_handle;
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC); ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle);
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len TSRMLS_DC); ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len);
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh);
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
END_EXTERN_C() END_EXTERN_C()

View file

@ -21,13 +21,13 @@
#include "zend.h" #include "zend.h"
#include "zend_globals.h" #include "zend_globals.h"
ZEND_API zend_string *(*zend_new_interned_string)(zend_string *str TSRMLS_DC); ZEND_API zend_string *(*zend_new_interned_string)(zend_string *str);
ZEND_API void (*zend_interned_strings_snapshot)(TSRMLS_D); ZEND_API void (*zend_interned_strings_snapshot)(void);
ZEND_API void (*zend_interned_strings_restore)(TSRMLS_D); ZEND_API void (*zend_interned_strings_restore)(void);
static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC); static zend_string *zend_new_interned_string_int(zend_string *str);
static void zend_interned_strings_snapshot_int(TSRMLS_D); static void zend_interned_strings_snapshot_int(void);
static void zend_interned_strings_restore_int(TSRMLS_D); static void zend_interned_strings_restore_int(void);
ZEND_API zend_ulong zend_hash_func(const char *str, size_t len) ZEND_API zend_ulong zend_hash_func(const char *str, size_t len)
{ {
@ -43,7 +43,7 @@ static void _str_dtor(zval *zv)
} }
#endif #endif
void zend_interned_strings_init(TSRMLS_D) void zend_interned_strings_init(void)
{ {
#ifndef ZTS #ifndef ZTS
zend_string *str; zend_string *str;
@ -58,7 +58,7 @@ void zend_interned_strings_init(TSRMLS_D)
/* interned empty string */ /* interned empty string */
str = zend_string_alloc(sizeof("")-1, 1); str = zend_string_alloc(sizeof("")-1, 1);
str->val[0] = '\000'; str->val[0] = '\000';
CG(empty_string) = zend_new_interned_string_int(str TSRMLS_CC); CG(empty_string) = zend_new_interned_string_int(str);
#endif #endif
/* one char strings (the actual interned strings are going to be created by ext/opcache) */ /* one char strings (the actual interned strings are going to be created by ext/opcache) */
@ -69,14 +69,14 @@ void zend_interned_strings_init(TSRMLS_D)
zend_interned_strings_restore = zend_interned_strings_restore_int; zend_interned_strings_restore = zend_interned_strings_restore_int;
} }
void zend_interned_strings_dtor(TSRMLS_D) void zend_interned_strings_dtor(void)
{ {
#ifndef ZTS #ifndef ZTS
zend_hash_destroy(&CG(interned_strings)); zend_hash_destroy(&CG(interned_strings));
#endif #endif
} }
static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) static zend_string *zend_new_interned_string_int(zend_string *str)
{ {
#ifndef ZTS #ifndef ZTS
zend_ulong h; zend_ulong h;
@ -143,7 +143,7 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC)
#endif #endif
} }
static void zend_interned_strings_snapshot_int(TSRMLS_D) static void zend_interned_strings_snapshot_int(void)
{ {
#ifndef ZTS #ifndef ZTS
uint idx; uint idx;
@ -159,7 +159,7 @@ static void zend_interned_strings_snapshot_int(TSRMLS_D)
#endif #endif
} }
static void zend_interned_strings_restore_int(TSRMLS_D) static void zend_interned_strings_restore_int(void)
{ {
#ifndef ZTS #ifndef ZTS
uint nIndex; uint nIndex;

View file

@ -25,13 +25,13 @@
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
ZEND_API extern zend_string *(*zend_new_interned_string)(zend_string *str TSRMLS_DC); ZEND_API extern zend_string *(*zend_new_interned_string)(zend_string *str);
ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D); ZEND_API extern void (*zend_interned_strings_snapshot)(void);
ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D); ZEND_API extern void (*zend_interned_strings_restore)(void);
ZEND_API zend_ulong zend_hash_func(const char *str, size_t len); ZEND_API zend_ulong zend_hash_func(const char *str, size_t len);
void zend_interned_strings_init(TSRMLS_D); void zend_interned_strings_init(void);
void zend_interned_strings_dtor(TSRMLS_D); void zend_interned_strings_dtor(void);
END_EXTERN_C() END_EXTERN_C()
@ -282,7 +282,7 @@ EMPTY_SWITCH_DEFAULT_CASE()
return hash; return hash;
} }
static zend_always_inline void zend_interned_empty_string_init(zend_string **s TSRMLS_DC) static zend_always_inline void zend_interned_empty_string_init(zend_string **s)
{ {
zend_string *str; zend_string *str;
@ -290,7 +290,7 @@ static zend_always_inline void zend_interned_empty_string_init(zend_string **s T
str->val[0] = '\000'; str->val[0] = '\000';
#ifndef ZTS #ifndef ZTS
*s = zend_new_interned_string(str TSRMLS_CC); *s = zend_new_interned_string(str);
#else #else
zend_string_hash_val(str); zend_string_hash_val(str);
str->gc.u.v.flags |= IS_STR_INTERNED; str->gc.u.v.flags |= IS_STR_INTERNED;
@ -298,7 +298,7 @@ static zend_always_inline void zend_interned_empty_string_init(zend_string **s T
#endif #endif
} }
static zend_always_inline void zend_interned_empty_string_free(zend_string **s TSRMLS_DC) static zend_always_inline void zend_interned_empty_string_free(zend_string **s)
{ {
if (NULL != *s) { if (NULL != *s) {
free(*s); free(*s);

View file

@ -144,35 +144,35 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht)
#endif #endif
} }
ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func)
{ {
begin_write(ht); begin_write(ht);
zend_hash_apply(TS_HASH(ht), apply_func TSRMLS_CC); zend_hash_apply(TS_HASH(ht), apply_func);
end_write(ht); end_write(ht);
} }
ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument)
{ {
begin_write(ht); begin_write(ht);
zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC); zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument);
end_write(ht); end_write(ht);
} }
ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...) ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht, apply_func_args_t apply_func, int num_args, ...)
{ {
va_list args; va_list args;
va_start(args, num_args); va_start(args, num_args);
begin_write(ht); begin_write(ht);
zend_hash_apply_with_arguments(TS_HASH(ht) TSRMLS_CC, apply_func, num_args, args); zend_hash_apply_with_arguments(TS_HASH(ht), apply_func, num_args, args);
end_write(ht); end_write(ht);
va_end(args); va_end(args);
} }
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func)
{ {
begin_write(ht); begin_write(ht);
zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC); zend_hash_reverse_apply(TS_HASH(ht), apply_func);
end_write(ht); end_write(ht);
} }
@ -276,36 +276,36 @@ ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, co
end_read(source); end_read(source);
} }
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC) ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber)
{ {
int retval; int retval;
begin_write(ht); begin_write(ht);
retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC); retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber);
end_write(ht); end_write(ht);
return retval; return retval;
} }
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered)
{ {
int retval; int retval;
begin_read(ht1); begin_read(ht1);
begin_read(ht2); begin_read(ht2);
retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC); retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered);
end_read(ht2); end_read(ht2);
end_read(ht1); end_read(ht1);
return retval; return retval;
} }
ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag TSRMLS_DC) ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag)
{ {
zval *retval; zval *retval;
begin_read(ht); begin_read(ht);
retval = zend_hash_minmax(TS_HASH(ht), compar, flag TSRMLS_CC); retval = zend_hash_minmax(TS_HASH(ht), compar, flag);
end_read(ht); end_read(ht);
return retval; return retval;

View file

@ -64,11 +64,11 @@ ZEND_API zval *_zend_ts_hash_index_add_or_update(TsHashTable *ht, zend_ulong h,
ZEND_API zval* zend_ts_hash_add_empty_element(TsHashTable *ht, zend_string *key); ZEND_API zval* zend_ts_hash_add_empty_element(TsHashTable *ht, zend_string *key);
ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht); ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht);
ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC); ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func);
ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC); ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *);
ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int, ...); ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht, apply_func_args_t apply_func, int, ...);
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC); ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func);
/* Deletes */ /* Deletes */
@ -88,9 +88,9 @@ ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_c
ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor);
ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite); ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite);
ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam); ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam);
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC); ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber);
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC); ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered);
ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag TSRMLS_DC); ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag);
ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht); ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht);

View file

@ -83,8 +83,8 @@ typedef struct _zend_reference zend_reference;
typedef struct _zend_ast_ref zend_ast_ref; typedef struct _zend_ast_ref zend_ast_ref;
typedef struct _zend_ast zend_ast; typedef struct _zend_ast zend_ast;
typedef int (*compare_func_t)(const void *, const void * TSRMLS_DC); typedef int (*compare_func_t)(const void *, const void *);
typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t TSRMLS_DC); typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t);
typedef void (*dtor_func_t)(zval *pDest); typedef void (*dtor_func_t)(zval *pDest);
typedef void (*copy_ctor_func_t)(zval *pElement); typedef void (*copy_ctor_func_t)(zval *pElement);
@ -427,10 +427,10 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
#define Z_OBJCE(zval) (Z_OBJ(zval)->ce) #define Z_OBJCE(zval) (Z_OBJ(zval)->ce)
#define Z_OBJCE_P(zval_p) Z_OBJCE(*(zval_p)) #define Z_OBJCE_P(zval_p) Z_OBJCE(*(zval_p))
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC) #define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval))
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*(zval_p)) #define Z_OBJPROP_P(zval_p) Z_OBJPROP(*(zval_p))
#define Z_OBJDEBUG(zval,tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp TSRMLS_CC):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL)) #define Z_OBJDEBUG(zval,tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))
#define Z_OBJDEBUG_P(zval_p,tmp) Z_OBJDEBUG(*(zval_p), tmp) #define Z_OBJDEBUG_P(zval_p,tmp) Z_OBJDEBUG(*(zval_p), tmp)
#define Z_RES(zval) (zval).value.res #define Z_RES(zval) (zval).value.res

View file

@ -39,13 +39,12 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
} }
case IS_ARRAY: { case IS_ARRAY: {
zend_array *arr = (zend_array*)p; zend_array *arr = (zend_array*)p;
TSRMLS_FETCH();
if (arr != &EG(symbol_table)) { if (arr != &EG(symbol_table)) {
/* break possible cycles */ /* break possible cycles */
GC_TYPE(arr) = IS_NULL; GC_TYPE(arr) = IS_NULL;
GC_REMOVE_FROM_BUFFER(arr); GC_REMOVE_FROM_BUFFER(arr);
zend_array_destroy(&arr->ht TSRMLS_CC); zend_array_destroy(&arr->ht);
efree_size(arr, sizeof(zend_array)); efree_size(arr, sizeof(zend_array));
} }
break; break;
@ -59,15 +58,13 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
} }
case IS_OBJECT: { case IS_OBJECT: {
zend_object *obj = (zend_object*)p; zend_object *obj = (zend_object*)p;
TSRMLS_FETCH();
OBJ_RELEASE(obj); OBJ_RELEASE(obj);
break; break;
} }
case IS_RESOURCE: { case IS_RESOURCE: {
zend_resource *res = (zend_resource*)p; zend_resource *res = (zend_resource*)p;
TSRMLS_FETCH();
if (--GC_REFCOUNT(res) == 0) { if (--GC_REFCOUNT(res) == 0) {
/* destroy resource */ /* destroy resource */
zend_list_free(res); zend_list_free(res);
@ -77,9 +74,8 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
case IS_REFERENCE: { case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)p; zend_reference *ref = (zend_reference*)p;
if (--GC_REFCOUNT(ref) == 0) { if (--GC_REFCOUNT(ref) == 0) {
TSRMLS_FETCH();
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC);
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
efree_size(ref, sizeof(zend_reference)); efree_size(ref, sizeof(zend_reference));
} }
break; break;
@ -101,13 +97,12 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
} }
case IS_ARRAY: { case IS_ARRAY: {
zend_array *arr = (zend_array*)p; zend_array *arr = (zend_array*)p;
TSRMLS_FETCH();
if (arr != &EG(symbol_table)) { if (arr != &EG(symbol_table)) {
/* break possible cycles */ /* break possible cycles */
GC_TYPE(arr) = IS_NULL; GC_TYPE(arr) = IS_NULL;
GC_REMOVE_FROM_BUFFER(arr); GC_REMOVE_FROM_BUFFER(arr);
zend_array_destroy(&arr->ht TSRMLS_CC); zend_array_destroy(&arr->ht);
efree_size(arr, sizeof(zend_array)); efree_size(arr, sizeof(zend_array));
} }
break; break;
@ -121,24 +116,21 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
} }
case IS_OBJECT: { case IS_OBJECT: {
zend_object *obj = (zend_object*)p; zend_object *obj = (zend_object*)p;
TSRMLS_FETCH();
zend_objects_store_del(obj);
zend_objects_store_del(obj TSRMLS_CC);
break; break;
} }
case IS_RESOURCE: { case IS_RESOURCE: {
zend_resource *res = (zend_resource*)p; zend_resource *res = (zend_resource*)p;
TSRMLS_FETCH();
/* destroy resource */ /* destroy resource */
zend_list_free(res); zend_list_free(res);
break; break;
} }
case IS_REFERENCE: { case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)p; zend_reference *ref = (zend_reference*)p;
TSRMLS_FETCH();
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC);
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
efree_size(ref, sizeof(zend_reference)); efree_size(ref, sizeof(zend_reference));
break; break;
} }
@ -241,8 +233,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
break; break;
case IS_ARRAY: { case IS_ARRAY: {
HashTable *ht; HashTable *ht;
TSRMLS_FETCH();
if (Z_ARR_P(zvalue) == &EG(symbol_table)) { if (Z_ARR_P(zvalue) == &EG(symbol_table)) {
return; /* do nothing */ return; /* do nothing */
} }
@ -269,9 +260,9 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
} }
ZEND_API size_t zend_print_variable(zval *var TSRMLS_DC) ZEND_API size_t zend_print_variable(zval *var)
{ {
return zend_print_zval(var, 0 TSRMLS_CC); return zend_print_zval(var, 0);
} }
@ -296,9 +287,8 @@ ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
ZEND_API void _zval_ptr_dtor_wrapper(zval *zval_ptr) ZEND_API void _zval_ptr_dtor_wrapper(zval *zval_ptr)
{ {
TSRMLS_FETCH();
i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_CC TSRMLS_CC); i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_CC);
} }
@ -308,7 +298,7 @@ ZEND_API void _zval_internal_ptr_dtor_wrapper(zval *zval_ptr)
} }
#endif #endif
ZEND_API int zval_copy_static_var(zval *p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */ ZEND_API int zval_copy_static_var(zval *p, int num_args, va_list args, zend_hash_key *key) /* {{{ */
{ {
zend_array *symbol_table; zend_array *symbol_table;
HashTable *target = va_arg(args, HashTable*); HashTable *target = va_arg(args, HashTable*);
@ -318,7 +308,7 @@ ZEND_API int zval_copy_static_var(zval *p TSRMLS_DC, int num_args, va_list args,
if (Z_CONST_FLAGS_P(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { if (Z_CONST_FLAGS_P(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) {
is_ref = Z_CONST_FLAGS_P(p) & IS_LEXICAL_REF; is_ref = Z_CONST_FLAGS_P(p) & IS_LEXICAL_REF;
symbol_table = zend_rebuild_symbol_table(TSRMLS_C); symbol_table = zend_rebuild_symbol_table();
p = zend_hash_find(&symbol_table->ht, key->key); p = zend_hash_find(&symbol_table->ht, key->key);
if (!p) { if (!p) {
p = &tmp; p = &tmp;

View file

@ -45,7 +45,7 @@ static zend_always_inline void _zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE
} }
} }
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC) static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
{ {
if (Z_REFCOUNTED_P(zval_ptr)) { if (Z_REFCOUNTED_P(zval_ptr)) {
if (!Z_DELREF_P(zval_ptr)) { if (!Z_DELREF_P(zval_ptr)) {
@ -104,9 +104,9 @@ static zend_always_inline void _zval_opt_copy_ctor_no_imm(zval *zvalue ZEND_FILE
} }
} }
ZEND_API int zval_copy_static_var(zval *p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key); ZEND_API int zval_copy_static_var(zval *p, int num_args, va_list args, zend_hash_key *key);
ZEND_API size_t zend_print_variable(zval *var TSRMLS_DC); ZEND_API size_t zend_print_variable(zval *var);
ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC); ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC); ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC); ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC);

View file

@ -428,7 +428,7 @@ static int php_is_file_ok(const cwd_state *state) /* {{{ */
} }
/* }}} */ /* }}} */
static void cwd_globals_ctor(virtual_cwd_globals *cwd_g TSRMLS_DC) /* {{{ */ static void cwd_globals_ctor(virtual_cwd_globals *cwd_g) /* {{{ */
{ {
CWD_STATE_COPY(&cwd_g->cwd, &main_cwd_state); CWD_STATE_COPY(&cwd_g->cwd, &main_cwd_state);
cwd_g->realpath_cache_size = 0; cwd_g->realpath_cache_size = 0;
@ -438,9 +438,9 @@ static void cwd_globals_ctor(virtual_cwd_globals *cwd_g TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static void cwd_globals_dtor(virtual_cwd_globals *cwd_g TSRMLS_DC) /* {{{ */ static void cwd_globals_dtor(virtual_cwd_globals *cwd_g) /* {{{ */
{ {
realpath_cache_clean(TSRMLS_C); realpath_cache_clean();
} }
/* }}} */ /* }}} */
@ -478,7 +478,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */
#ifdef ZTS #ifdef ZTS
ts_allocate_id(&cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor); ts_allocate_id(&cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
#else #else
cwd_globals_ctor(&cwd_globals TSRMLS_CC); cwd_globals_ctor(&cwd_globals);
#endif #endif
#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS) #if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS)
@ -490,7 +490,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */
CWD_API void virtual_cwd_shutdown(void) /* {{{ */ CWD_API void virtual_cwd_shutdown(void) /* {{{ */
{ {
#ifndef ZTS #ifndef ZTS
cwd_globals_dtor(&cwd_globals TSRMLS_CC); cwd_globals_dtor(&cwd_globals);
#endif #endif
#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS) #if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS)
tsrm_mutex_free(cwd_mutex); tsrm_mutex_free(cwd_mutex);
@ -500,7 +500,7 @@ CWD_API void virtual_cwd_shutdown(void) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_cwd_activate(TSRMLS_D) /* {{{ */ CWD_API int virtual_cwd_activate(void) /* {{{ */
{ {
if (CWDG(cwd).cwd == NULL) { if (CWDG(cwd).cwd == NULL) {
CWD_STATE_COPY(&CWDG(cwd), &main_cwd_state); CWD_STATE_COPY(&CWDG(cwd), &main_cwd_state);
@ -509,7 +509,7 @@ CWD_API int virtual_cwd_activate(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_cwd_deactivate(TSRMLS_D) /* {{{ */ CWD_API int virtual_cwd_deactivate(void) /* {{{ */
{ {
if (CWDG(cwd).cwd != NULL) { if (CWDG(cwd).cwd != NULL) {
CWD_STATE_FREE(&CWDG(cwd)); CWD_STATE_FREE(&CWDG(cwd));
@ -519,7 +519,7 @@ CWD_API int virtual_cwd_deactivate(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC) /* {{{ */ CWD_API char *virtual_getcwd_ex(size_t *length) /* {{{ */
{ {
cwd_state *state; cwd_state *state;
@ -561,12 +561,12 @@ CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
/* Same semantics as UNIX getcwd() */ /* Same semantics as UNIX getcwd() */
CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */ CWD_API char *virtual_getcwd(char *buf, size_t size) /* {{{ */
{ {
size_t length; size_t length;
char *cwd; char *cwd;
cwd = virtual_getcwd_ex(&length TSRMLS_CC); cwd = virtual_getcwd_ex(&length);
if (buf == NULL) { if (buf == NULL) {
return cwd; return cwd;
@ -583,10 +583,10 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
#ifdef PHP_WIN32 #ifdef PHP_WIN32
static inline zend_ulong realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */ static inline zend_ulong realpath_cache_key(const char *path, int path_len) /* {{{ */
{ {
register zend_ulong h; register zend_ulong h;
char *bucket_key_start = tsrm_win32_get_path_sid_key(path TSRMLS_CC); char *bucket_key_start = tsrm_win32_get_path_sid_key(path);
char *bucket_key = (char *)bucket_key_start; char *bucket_key = (char *)bucket_key_start;
const char *e = bucket_key + strlen(bucket_key); const char *e = bucket_key + strlen(bucket_key);
@ -618,7 +618,7 @@ static inline zend_ulong realpath_cache_key(const char *path, int path_len) /* {
/* }}} */ /* }}} */
#endif /* defined(PHP_WIN32) */ #endif /* defined(PHP_WIN32) */
CWD_API void realpath_cache_clean(TSRMLS_D) /* {{{ */ CWD_API void realpath_cache_clean(void) /* {{{ */
{ {
uint32_t i; uint32_t i;
@ -635,10 +635,10 @@ CWD_API void realpath_cache_clean(TSRMLS_D) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ */ CWD_API void realpath_cache_del(const char *path, int path_len) /* {{{ */
{ {
#ifdef PHP_WIN32 #ifdef PHP_WIN32
zend_ulong key = realpath_cache_key(path, path_len TSRMLS_CC); zend_ulong key = realpath_cache_key(path, path_len);
#else #else
zend_ulong key = realpath_cache_key(path, path_len); zend_ulong key = realpath_cache_key(path, path_len);
#endif #endif
@ -667,7 +667,7 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, int is_dir, time_t t TSRMLS_DC) /* {{{ */ static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, int is_dir, time_t t) /* {{{ */
{ {
zend_long size = sizeof(realpath_cache_bucket) + path_len + 1; zend_long size = sizeof(realpath_cache_bucket) + path_len + 1;
int same = 1; int same = 1;
@ -687,7 +687,7 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
} }
#ifdef PHP_WIN32 #ifdef PHP_WIN32
bucket->key = realpath_cache_key(path, path_len TSRMLS_CC); bucket->key = realpath_cache_key(path, path_len);
#else #else
bucket->key = realpath_cache_key(path, path_len); bucket->key = realpath_cache_key(path, path_len);
#endif #endif
@ -717,10 +717,10 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
} }
/* }}} */ /* }}} */
static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t) /* {{{ */
{ {
#ifdef PHP_WIN32 #ifdef PHP_WIN32
zend_ulong key = realpath_cache_key(path, path_len TSRMLS_CC); zend_ulong key = realpath_cache_key(path, path_len);
#else #else
zend_ulong key = realpath_cache_key(path, path_len); zend_ulong key = realpath_cache_key(path, path_len);
#endif #endif
@ -751,23 +751,23 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
} }
/* }}} */ /* }}} */
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t) /* {{{ */
{ {
return realpath_cache_find(path, path_len, t TSRMLS_CC); return realpath_cache_find(path, path_len, t);
} }
/* }}} */ /* }}} */
CWD_API zend_long realpath_cache_size(TSRMLS_D) CWD_API zend_long realpath_cache_size(void)
{ {
return CWDG(realpath_cache_size); return CWDG(realpath_cache_size);
} }
CWD_API zend_long realpath_cache_max_buckets(TSRMLS_D) CWD_API zend_long realpath_cache_max_buckets(void)
{ {
return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
} }
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D) CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void)
{ {
return CWDG(realpath_cache); return CWDG(realpath_cache);
} }
@ -776,7 +776,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D)
#undef LINK_MAX #undef LINK_MAX
#define LINK_MAX 32 #define LINK_MAX 32
static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir TSRMLS_DC) /* {{{ */ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir) /* {{{ */
{ {
int i, j, save; int i, j, save;
int directory = 0; int directory = 0;
@ -819,7 +819,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if (i - 1 <= start) { if (i - 1 <= start) {
return start ? start : len; return start ? start : len;
} }
j = tsrm_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL TSRMLS_CC); j = tsrm_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL);
if (j > start) { if (j > start) {
j--; j--;
while (j > start && !IS_SLASH(path[j])) { while (j > start && !IS_SLASH(path[j])) {
@ -861,7 +861,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if (!*t) { if (!*t) {
*t = time(0); *t = time(0);
} }
if ((bucket = realpath_cache_find(path, len, *t TSRMLS_CC)) != NULL) { if ((bucket = realpath_cache_find(path, len, *t)) != NULL) {
if (is_dir && !bucket->is_dir) { if (is_dir && !bucket->is_dir) {
/* not a directory */ /* not a directory */
return -1; return -1;
@ -1034,7 +1034,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if(isabsolute == 1) { if(isabsolute == 1) {
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) { if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
/* use_realpath is 0 in the call below coz path is absolute*/ /* use_realpath is 0 in the call below coz path is absolute*/
j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory TSRMLS_CC); j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory);
if(j < 0) { if(j < 0) {
free_alloca(tmp, use_heap); free_alloca(tmp, use_heap);
return -1; return -1;
@ -1050,7 +1050,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
memmove(path+i, path, j+1); memmove(path+i, path, j+1);
memcpy(path, tmp, i-1); memcpy(path, tmp, i-1);
path[i-1] = DEFAULT_SLASH; path[i-1] = DEFAULT_SLASH;
j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory TSRMLS_CC); j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory);
if(j < 0) { if(j < 0) {
free_alloca(tmp, use_heap); free_alloca(tmp, use_heap);
return -1; return -1;
@ -1096,7 +1096,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
} }
path[j] = 0; path[j] = 0;
if (IS_ABSOLUTE_PATH(path, j)) { if (IS_ABSOLUTE_PATH(path, j)) {
j = tsrm_realpath_r(path, 1, j, ll, t, use_realpath, is_dir, &directory TSRMLS_CC); j = tsrm_realpath_r(path, 1, j, ll, t, use_realpath, is_dir, &directory);
if (j < 0) { if (j < 0) {
free_alloca(tmp, use_heap); free_alloca(tmp, use_heap);
return -1; return -1;
@ -1109,7 +1109,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
memmove(path+i, path, j+1); memmove(path+i, path, j+1);
memcpy(path, tmp, i-1); memcpy(path, tmp, i-1);
path[i-1] = DEFAULT_SLASH; path[i-1] = DEFAULT_SLASH;
j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory TSRMLS_CC); j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory);
if (j < 0) { if (j < 0) {
free_alloca(tmp, use_heap); free_alloca(tmp, use_heap);
return -1; return -1;
@ -1135,7 +1135,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
j = start; j = start;
} else { } else {
/* some leading directories may be unaccessable */ /* some leading directories may be unaccessable */
j = tsrm_realpath_r(path, start, i-1, ll, t, save ? CWD_FILEPATH : use_realpath, 1, NULL TSRMLS_CC); j = tsrm_realpath_r(path, start, i-1, ll, t, save ? CWD_FILEPATH : use_realpath, 1, NULL);
if (j > start) { if (j > start) {
path[j++] = DEFAULT_SLASH; path[j++] = DEFAULT_SLASH;
} }
@ -1167,7 +1167,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if (save && start && CWDG(realpath_cache_size_limit)) { if (save && start && CWDG(realpath_cache_size_limit)) {
/* save absolute path in the cache */ /* save absolute path in the cache */
realpath_cache_add(tmp, len, path, j, directory, *t TSRMLS_CC); realpath_cache_add(tmp, len, path, j, directory, *t);
} }
free_alloca(tmp, use_heap); free_alloca(tmp, use_heap);
@ -1178,7 +1178,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
/* Resolve path relatively to state and put the real path into state */ /* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */ /* returns 0 for ok, 1 for error */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath TSRMLS_DC) /* {{{ */ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
{ {
int path_length = (int)strlen(path); int path_length = (int)strlen(path);
char resolved_path[MAXPATHLEN]; char resolved_path[MAXPATHLEN];
@ -1319,7 +1319,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]); add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]);
t = CWDG(realpath_cache_ttl) ? 0 : -1; t = CWDG(realpath_cache_ttl) ? 0 : -1;
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL TSRMLS_CC); path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
if (path_length < 0) { if (path_length < 0) {
errno = ENOENT; errno = ENOENT;
@ -1386,13 +1386,13 @@ verify:
} }
/* }}} */ /* }}} */
CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */ CWD_API int virtual_chdir(const char *path) /* {{{ */
{ {
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH TSRMLS_CC)?-1:0; return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0;
} }
/* }}} */ /* }}} */
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) /* {{{ */ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path)) /* {{{ */
{ {
int length = (int)strlen(path); int length = (int)strlen(path);
char *temp; char *temp;
@ -1420,13 +1420,13 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
#if VIRTUAL_CWD_DEBUG #if VIRTUAL_CWD_DEBUG
fprintf (stderr, "Changing directory to %s\n", temp); fprintf (stderr, "Changing directory to %s\n", temp);
#endif #endif
retval = p_chdir(temp TSRMLS_CC); retval = p_chdir(temp);
free_alloca(temp, use_heap); free_alloca(temp, use_heap);
return retval; return retval;
} }
/* }}} */ /* }}} */
CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */ CWD_API char *virtual_realpath(const char *path, char *real_path) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
char *retval; char *retval;
@ -1456,7 +1456,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
new_state.cwd_length = 0; new_state.cwd_length = 0;
} }
if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)==0) { if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)==0) {
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length; int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
memcpy(real_path, new_state.cwd, len); memcpy(real_path, new_state.cwd, len);
@ -1472,13 +1472,13 @@ end:
} }
/* }}} */ /* }}} */
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC) /* {{{ */ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, verify_path, CWD_FILEPATH TSRMLS_CC); retval = virtual_file_ex(&new_state, path, verify_path, CWD_FILEPATH);
*filepath = new_state.cwd; *filepath = new_state.cwd;
@ -1487,13 +1487,13 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
} }
/* }}} */ /* }}} */
CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC) /* {{{ */ CWD_API int virtual_filepath(const char *path, char **filepath) /* {{{ */
{ {
return virtual_filepath_ex(path, filepath, php_is_file_ok TSRMLS_CC); return virtual_filepath_ex(path, filepath, php_is_file_ok);
} }
/* }}} */ /* }}} */
CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC) /* {{{ */ CWD_API FILE *virtual_fopen(const char *path, const char *mode) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
FILE *f; FILE *f;
@ -1503,7 +1503,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC) /* {{{
} }
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return NULL; return NULL;
} }
@ -1516,19 +1516,19 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */ CWD_API int virtual_access(const char *pathname, int mode) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int ret; int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
#if defined(TSRM_WIN32) #if defined(TSRM_WIN32)
ret = tsrm_win32_access(new_state.cwd, mode TSRMLS_CC); ret = tsrm_win32_access(new_state.cwd, mode);
#else #else
ret = access(new_state.cwd, mode); ret = access(new_state.cwd, mode);
#endif #endif
@ -1540,13 +1540,13 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
#if HAVE_UTIME #if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /* {{{ */ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int ret; int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1563,13 +1563,13 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /
/* }}} */ /* }}} */
#endif #endif
CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC) /* {{{ */ CWD_API int virtual_chmod(const char *filename, mode_t mode) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int ret; int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1582,13 +1582,13 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
#if !defined(TSRM_WIN32) && !defined(NETWARE) #if !defined(TSRM_WIN32) && !defined(NETWARE)
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC) /* {{{ */ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int ret; int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1609,13 +1609,13 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li
/* }}} */ /* }}} */
#endif #endif
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */ CWD_API int virtual_open(const char *path, int flags, ...) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int f; int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1637,13 +1637,13 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */ CWD_API int virtual_creat(const char *path, mode_t mode) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int f; int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1655,21 +1655,21 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) /* {{{ */ CWD_API int virtual_rename(const char *oldname, const char *newname) /* {{{ */
{ {
cwd_state old_state; cwd_state old_state;
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&old_state, &CWDG(cwd)); CWD_STATE_COPY(&old_state, &CWDG(cwd));
if (virtual_file_ex(&old_state, oldname, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&old_state, oldname, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&old_state); CWD_STATE_FREE_ERR(&old_state);
return -1; return -1;
} }
oldname = old_state.cwd; oldname = old_state.cwd;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, newname, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&new_state, newname, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&old_state); CWD_STATE_FREE_ERR(&old_state);
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
@ -1692,13 +1692,13 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) /
} }
/* }}} */ /* }}} */
CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */ CWD_API int virtual_stat(const char *path, zend_stat_t *buf) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1710,13 +1710,13 @@ CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */ CWD_API int virtual_lstat(const char *path, zend_stat_t *buf) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1728,13 +1728,13 @@ CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ *
} }
/* }}} */ /* }}} */
CWD_API int virtual_unlink(const char *path TSRMLS_DC) /* {{{ */ CWD_API int virtual_unlink(const char *path) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1746,13 +1746,13 @@ CWD_API int virtual_unlink(const char *path TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC) /* {{{ */ CWD_API int virtual_mkdir(const char *pathname, mode_t mode) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, pathname, NULL, CWD_FILEPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, pathname, NULL, CWD_FILEPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1767,13 +1767,13 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC) /* {{{ */ CWD_API int virtual_rmdir(const char *pathname) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
int retval; int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, pathname, NULL, CWD_EXPAND TSRMLS_CC)) { if (virtual_file_ex(&new_state, pathname, NULL, CWD_EXPAND)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return -1; return -1;
} }
@ -1789,13 +1789,13 @@ CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC) /* {{{ */
DIR *opendir(const char *name); DIR *opendir(const char *name);
#endif #endif
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC) /* {{{ */ CWD_API DIR *virtual_opendir(const char *pathname) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
DIR *retval; DIR *retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd)); CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
CWD_STATE_FREE_ERR(&new_state); CWD_STATE_FREE_ERR(&new_state);
return NULL; return NULL;
} }
@ -1808,16 +1808,16 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */ CWD_API FILE *virtual_popen(const char *command, const char *type) /* {{{ */
{ {
return popen_ex(command, type, CWDG(cwd).cwd, NULL TSRMLS_CC); return popen_ex(command, type, CWDG(cwd).cwd, NULL);
} }
/* }}} */ /* }}} */
#elif defined(NETWARE) #elif defined(NETWARE)
/* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform /* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform
a VCWD_CHDIR() and mutex it a VCWD_CHDIR() and mutex it
*/ */
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */ CWD_API FILE *virtual_popen(const char *command, const char *type) /* {{{ */
{ {
char prev_cwd[MAXPATHLEN]; char prev_cwd[MAXPATHLEN];
char *getcwd_result; char *getcwd_result;
@ -1844,7 +1844,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
} }
/* }}} */ /* }}} */
#else /* Unix */ #else /* Unix */
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */ CWD_API FILE *virtual_popen(const char *command, const char *type) /* {{{ */
{ {
int command_length; int command_length;
int dir_length, extra = 0; int dir_length, extra = 0;
@ -1904,7 +1904,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
/* }}} */ /* }}} */
#endif #endif
CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */ CWD_API char *tsrm_realpath(const char *path, char *real_path) /* {{{ */
{ {
cwd_state new_state; cwd_state new_state;
char cwd[MAXPATHLEN]; char cwd[MAXPATHLEN];
@ -1933,7 +1933,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
new_state.cwd_length = 0; new_state.cwd_length = 0;
} }
if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
efree(new_state.cwd); efree(new_state.cwd);
return NULL; return NULL;
} }

View file

@ -151,27 +151,27 @@ typedef int (*verify_path_func)(const cwd_state *);
CWD_API void virtual_cwd_startup(void); CWD_API void virtual_cwd_startup(void);
CWD_API void virtual_cwd_shutdown(void); CWD_API void virtual_cwd_shutdown(void);
CWD_API int virtual_cwd_activate(TSRMLS_D); CWD_API int virtual_cwd_activate(void);
CWD_API int virtual_cwd_deactivate(TSRMLS_D); CWD_API int virtual_cwd_deactivate(void);
CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC); CWD_API char *virtual_getcwd_ex(size_t *length);
CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC); CWD_API char *virtual_getcwd(char *buf, size_t size);
CWD_API int virtual_chdir(const char *path TSRMLS_DC); CWD_API int virtual_chdir(const char *path);
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC); CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path));
CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC); CWD_API int virtual_filepath(const char *path, char **filepath);
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC); CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path);
CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC); CWD_API char *virtual_realpath(const char *path, char *real_path);
CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC); CWD_API FILE *virtual_fopen(const char *path, const char *mode);
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...); CWD_API int virtual_open(const char *path, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC); CWD_API int virtual_creat(const char *path, mode_t mode);
CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC); CWD_API int virtual_rename(const char *oldname, const char *newname);
CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC); CWD_API int virtual_stat(const char *path, zend_stat_t *buf);
CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC); CWD_API int virtual_lstat(const char *path, zend_stat_t *buf);
CWD_API int virtual_unlink(const char *path TSRMLS_DC); CWD_API int virtual_unlink(const char *path);
CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC); CWD_API int virtual_mkdir(const char *pathname, mode_t mode);
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC); CWD_API int virtual_rmdir(const char *pathname);
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC); CWD_API DIR *virtual_opendir(const char *pathname);
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC); CWD_API FILE *virtual_popen(const char *command, const char *type);
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC); CWD_API int virtual_access(const char *pathname, int mode);
#if defined(TSRM_WIN32) #if defined(TSRM_WIN32)
/* these are not defined in win32 headers */ /* these are not defined in win32 headers */
#ifndef W_OK #ifndef W_OK
@ -189,11 +189,11 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
#endif #endif
#if HAVE_UTIME #if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC); CWD_API int virtual_utime(const char *filename, struct utimbuf *buf);
#endif #endif
CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC); CWD_API int virtual_chmod(const char *filename, mode_t mode);
#if !defined(TSRM_WIN32) && !defined(NETWARE) #if !defined(TSRM_WIN32) && !defined(NETWARE)
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC); CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link);
#endif #endif
/* One of the following constants must be used as the last argument /* One of the following constants must be used as the last argument
@ -203,9 +203,9 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li
#define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */ #define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */
#define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */ #define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath TSRMLS_DC); CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC); CWD_API char *tsrm_realpath(const char *path, char *real_path);
#define REALPATH_CACHE_TTL (2*60) /* 2 minutes */ #define REALPATH_CACHE_TTL (2*60) /* 2 minutes */
#define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */ #define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */
@ -243,12 +243,12 @@ extern virtual_cwd_globals cwd_globals;
# define CWDG(v) (cwd_globals.v) # define CWDG(v) (cwd_globals.v)
#endif #endif
CWD_API void realpath_cache_clean(TSRMLS_D); CWD_API void realpath_cache_clean(void);
CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC); CWD_API void realpath_cache_del(const char *path, int path_len);
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC); CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t);
CWD_API zend_long realpath_cache_size(TSRMLS_D); CWD_API zend_long realpath_cache_size(void);
CWD_API zend_long realpath_cache_max_buckets(TSRMLS_D); CWD_API zend_long realpath_cache_max_buckets(void);
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D); CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void);
/* The actual macros to be used in programs using TSRM /* The actual macros to be used in programs using TSRM
* If the program defines VIRTUAL_DIR it will use the * If the program defines VIRTUAL_DIR it will use the
@ -257,33 +257,33 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
#ifdef VIRTUAL_DIR #ifdef VIRTUAL_DIR
#define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size TSRMLS_CC) #define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size)
#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode TSRMLS_CC) #define VCWD_FOPEN(path, mode) virtual_fopen(path, mode)
/* Because open() has two modes, we have to macros to replace it */ /* Because open() has two modes, we have to macros to replace it */
#define VCWD_OPEN(path, flags) virtual_open(path TSRMLS_CC, flags) #define VCWD_OPEN(path, flags) virtual_open(path, flags)
#define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path TSRMLS_CC, flags, mode) #define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode)
#define VCWD_CREAT(path, mode) virtual_creat(path, mode TSRMLS_CC) #define VCWD_CREAT(path, mode) virtual_creat(path, mode)
#define VCWD_CHDIR(path) virtual_chdir(path TSRMLS_CC) #define VCWD_CHDIR(path) virtual_chdir(path)
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir TSRMLS_CC) #define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir)
#define VCWD_GETWD(buf) #define VCWD_GETWD(buf)
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC) #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path)
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC) #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname)
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC) #define VCWD_STAT(path, buff) virtual_stat(path, buff)
# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC) # define VCWD_LSTAT(path, buff) virtual_lstat(path, buff)
#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC) #define VCWD_UNLINK(path) virtual_unlink(path)
#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC) #define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC) #define VCWD_RMDIR(pathname) virtual_rmdir(pathname)
#define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC) #define VCWD_OPENDIR(pathname) virtual_opendir(pathname)
#define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC) #define VCWD_POPEN(command, type) virtual_popen(command, type)
#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode TSRMLS_CC) #define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode)
#if HAVE_UTIME #if HAVE_UTIME
#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC) #define VCWD_UTIME(path, time) virtual_utime(path, time)
#endif #endif
#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC) #define VCWD_CHMOD(path, mode) virtual_chmod(path, mode)
#if !defined(TSRM_WIN32) && !defined(NETWARE) #if !defined(TSRM_WIN32) && !defined(NETWARE)
#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0 TSRMLS_CC) #define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0)
#if HAVE_LCHOWN #if HAVE_LCHOWN
#define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1 TSRMLS_CC) #define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1)
#endif #endif
#endif #endif
@ -312,12 +312,12 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
#define VCWD_OPENDIR(pathname) opendir(pathname) #define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type) #define VCWD_POPEN(command, type) popen(command, type)
#if defined(TSRM_WIN32) #if defined(TSRM_WIN32)
#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode TSRMLS_CC) #define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
#else #else
#define VCWD_ACCESS(pathname, mode) access(pathname, mode) #define VCWD_ACCESS(pathname, mode) access(pathname, mode)
#endif #endif
#define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path TSRMLS_CC) #define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path)
#if HAVE_UTIME #if HAVE_UTIME
# ifdef TSRM_WIN32 # ifdef TSRM_WIN32

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{%DEFINES%} {%DEFINES%}
ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC) ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data)
{ {
DCL_OPLINE DCL_OPLINE
@ -26,7 +26,7 @@ ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC)
zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen");
} }
ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value TSRMLS_DC) ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value)
{ {
zend_execute_data *execute_data; zend_execute_data *execute_data;
@ -35,15 +35,15 @@ ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value
} }
execute_data = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_CODE, execute_data = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_CODE,
(zend_function*)op_array, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, EG(current_execute_data) ? Z_OBJ(EG(current_execute_data)->This) : NULL, NULL TSRMLS_CC); (zend_function*)op_array, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, EG(current_execute_data) ? Z_OBJ(EG(current_execute_data)->This) : NULL, NULL);
if (EG(current_execute_data)) { if (EG(current_execute_data)) {
execute_data->symbol_table = zend_rebuild_symbol_table(TSRMLS_C); execute_data->symbol_table = zend_rebuild_symbol_table();
} else { } else {
execute_data->symbol_table = &EG(symbol_table); execute_data->symbol_table = &EG(symbol_table);
} }
EX(prev_execute_data) = EG(current_execute_data); EX(prev_execute_data) = EG(current_execute_data);
i_init_execute_data(execute_data, op_array, return_value TSRMLS_CC); i_init_execute_data(execute_data, op_array, return_value);
zend_{%EXECUTOR_NAME%}_ex(execute_data TSRMLS_CC); zend_{%EXECUTOR_NAME%}_ex(execute_data);
} }
{%EXTERNAL_EXECUTOR%} {%EXTERNAL_EXECUTOR%}

View file

@ -147,7 +147,7 @@ static PHP_GINIT_FUNCTION(bcmath)
ZEND_TSRMLS_CACHE_UPDATE; ZEND_TSRMLS_CACHE_UPDATE;
#endif #endif
bcmath_globals->bc_precision = 0; bcmath_globals->bc_precision = 0;
bc_init_numbers(TSRMLS_C); bc_init_numbers();
} }
/* }}} */ /* }}} */
@ -194,16 +194,16 @@ PHP_MINFO_FUNCTION(bcmath)
/* {{{ php_str2num /* {{{ php_str2num
Convert to bc_num detecting scale */ Convert to bc_num detecting scale */
static void php_str2num(bc_num *num, char *str TSRMLS_DC) static void php_str2num(bc_num *num, char *str)
{ {
char *p; char *p;
if (!(p = strchr(str, '.'))) { if (!(p = strchr(str, '.'))) {
bc_str2num(num, str, 0 TSRMLS_CC); bc_str2num(num, str, 0);
return; return;
} }
bc_str2num(num, str, strlen(p+1) TSRMLS_CC); bc_str2num(num, str, strlen(p+1));
} }
/* }}} */ /* }}} */
@ -217,7 +217,7 @@ PHP_FUNCTION(bcadd)
size_t left_len, right_len; size_t left_len, right_len;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -225,11 +225,11 @@ PHP_FUNCTION(bcadd)
scale = (int) (scale_param < 0 ? 0 : scale_param); scale = (int) (scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
bc_add (first, second, &result, scale); bc_add (first, second, &result, scale);
if (result->n_scale > scale) { if (result->n_scale > scale) {
@ -254,7 +254,7 @@ PHP_FUNCTION(bcsub)
bc_num first, second, result; bc_num first, second, result;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -262,11 +262,11 @@ PHP_FUNCTION(bcsub)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
bc_sub (first, second, &result, scale); bc_sub (first, second, &result, scale);
if (result->n_scale > scale) { if (result->n_scale > scale) {
@ -291,7 +291,7 @@ PHP_FUNCTION(bcmul)
bc_num first, second, result; bc_num first, second, result;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -299,12 +299,12 @@ PHP_FUNCTION(bcmul)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
bc_multiply (first, second, &result, scale TSRMLS_CC); bc_multiply (first, second, &result, scale);
if (result->n_scale > scale) { if (result->n_scale > scale) {
result->n_scale = scale; result->n_scale = scale;
@ -328,7 +328,7 @@ PHP_FUNCTION(bcdiv)
bc_num first, second, result; bc_num first, second, result;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -336,13 +336,13 @@ PHP_FUNCTION(bcdiv)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
switch (bc_divide(first, second, &result, scale TSRMLS_CC)) { switch (bc_divide(first, second, &result, scale)) {
case 0: /* OK */ case 0: /* OK */
if (result->n_scale > scale) { if (result->n_scale > scale) {
result->n_scale = scale; result->n_scale = scale;
@ -350,7 +350,7 @@ PHP_FUNCTION(bcdiv)
RETVAL_STR(bc_num2str(result)); RETVAL_STR(bc_num2str(result));
break; break;
case -1: /* division by zero */ case -1: /* division by zero */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero"); php_error_docref(NULL, E_WARNING, "Division by zero");
break; break;
} }
@ -369,22 +369,22 @@ PHP_FUNCTION(bcmod)
size_t left_len, right_len; size_t left_len, right_len;
bc_num first, second, result; bc_num first, second, result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &left, &left_len, &right, &right_len) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &left, &left_len, &right, &right_len) == FAILURE) {
return; return;
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
bc_str2num(&first, left, 0 TSRMLS_CC); bc_str2num(&first, left, 0);
bc_str2num(&second, right, 0 TSRMLS_CC); bc_str2num(&second, right, 0);
switch (bc_modulo(first, second, &result, 0 TSRMLS_CC)) { switch (bc_modulo(first, second, &result, 0)) {
case 0: case 0:
RETVAL_STR(bc_num2str(result)); RETVAL_STR(bc_num2str(result));
break; break;
case -1: case -1:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero"); php_error_docref(NULL, E_WARNING, "Division by zero");
break; break;
} }
@ -405,21 +405,21 @@ PHP_FUNCTION(bcpowmod)
zend_long scale = BCG(bc_precision); zend_long scale = BCG(bc_precision);
int scale_int; int scale_int;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|l", &left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) {
return; return;
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&mod TSRMLS_CC); bc_init_num(&mod);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
php_str2num(&mod, modulous TSRMLS_CC); php_str2num(&mod, modulous);
scale_int = (int) ((int)scale < 0 ? 0 : scale); scale_int = (int) ((int)scale < 0 ? 0 : scale);
if (bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC) != -1) { if (bc_raisemod(first, second, mod, &result, scale_int) != -1) {
if (result->n_scale > scale) { if (result->n_scale > scale) {
result->n_scale = (int)scale; result->n_scale = (int)scale;
} }
@ -446,7 +446,7 @@ PHP_FUNCTION(bcpow)
bc_num first, second, result; bc_num first, second, result;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -454,12 +454,12 @@ PHP_FUNCTION(bcpow)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&first, left TSRMLS_CC); php_str2num(&first, left);
php_str2num(&second, right TSRMLS_CC); php_str2num(&second, right);
bc_raise (first, second, &result, scale TSRMLS_CC); bc_raise (first, second, &result, scale);
if (result->n_scale > scale) { if (result->n_scale > scale) {
result->n_scale = scale; result->n_scale = scale;
@ -483,7 +483,7 @@ PHP_FUNCTION(bcsqrt)
bc_num result; bc_num result;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "s|l", &left, &left_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "s|l", &left, &left_len, &scale_param) == FAILURE) {
return; return;
} }
@ -491,16 +491,16 @@ PHP_FUNCTION(bcsqrt)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&result TSRMLS_CC); bc_init_num(&result);
php_str2num(&result, left TSRMLS_CC); php_str2num(&result, left);
if (bc_sqrt (&result, scale TSRMLS_CC) != 0) { if (bc_sqrt (&result, scale) != 0) {
if (result->n_scale > scale) { if (result->n_scale > scale) {
result->n_scale = scale; result->n_scale = scale;
} }
RETVAL_STR(bc_num2str(result)); RETVAL_STR(bc_num2str(result));
} else { } else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number"); php_error_docref(NULL, E_WARNING, "Square root of negative number");
} }
bc_free_num(&result); bc_free_num(&result);
@ -518,7 +518,7 @@ PHP_FUNCTION(bccomp)
bc_num first, second; bc_num first, second;
int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { if (zend_parse_parameters(argc, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) {
return; return;
} }
@ -526,11 +526,11 @@ PHP_FUNCTION(bccomp)
scale = (int) ((int)scale_param < 0 ? 0 : scale_param); scale = (int) ((int)scale_param < 0 ? 0 : scale_param);
} }
bc_init_num(&first TSRMLS_CC); bc_init_num(&first);
bc_init_num(&second TSRMLS_CC); bc_init_num(&second);
bc_str2num(&first, left, scale TSRMLS_CC); bc_str2num(&first, left, scale);
bc_str2num(&second, right, scale TSRMLS_CC); bc_str2num(&second, right, scale);
RETVAL_LONG(bc_compare(first, second)); RETVAL_LONG(bc_compare(first, second));
bc_free_num(&first); bc_free_num(&first);
@ -545,7 +545,7 @@ PHP_FUNCTION(bcscale)
{ {
zend_long new_scale; zend_long new_scale;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_scale) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_scale) == FAILURE) {
return; return;
} }

View file

@ -99,7 +99,7 @@ typedef struct bc_struct
#endif #endif
#endif #endif
_PROTOTYPE(void bc_init_numbers, (TSRMLS_D)); _PROTOTYPE(void bc_init_numbers, (void));
_PROTOTYPE(bc_num _bc_new_num_ex, (int length, int scale, int persistent)); _PROTOTYPE(bc_num _bc_new_num_ex, (int length, int scale, int persistent));
@ -107,9 +107,9 @@ _PROTOTYPE(void _bc_free_num_ex, (bc_num *num, int persistent));
_PROTOTYPE(bc_num bc_copy_num, (bc_num num)); _PROTOTYPE(bc_num bc_copy_num, (bc_num num));
_PROTOTYPE(void bc_init_num, (bc_num *num TSRMLS_DC)); _PROTOTYPE(void bc_init_num, (bc_num *num));
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale TSRMLS_DC)); _PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale));
_PROTOTYPE(zend_string *bc_num2str, (bc_num num)); _PROTOTYPE(zend_string *bc_num2str, (bc_num num));
@ -119,7 +119,7 @@ _PROTOTYPE(long bc_num2long, (bc_num num));
_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2)); _PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
_PROTOTYPE(char bc_is_zero, (bc_num num TSRMLS_DC)); _PROTOTYPE(char bc_is_zero, (bc_num num));
_PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale)); _PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale));
@ -129,26 +129,26 @@ _PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min)); _PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)); _PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)); _PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result, _PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result,
int scale TSRMLS_DC)); int scale));
_PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot, _PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot,
bc_num *rem, int scale TSRMLS_DC)); bc_num *rem, int scale));
_PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod, _PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod,
bc_num *result, int scale TSRMLS_DC)); bc_num *result, int scale));
_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result, _PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result,
int scale TSRMLS_DC)); int scale));
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale TSRMLS_DC)); _PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int), _PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),
int leading_zero TSRMLS_DC)); int leading_zero));
/* Prototypes needed for external utility routines. */ /* Prototypes needed for external utility routines. */

View file

@ -48,9 +48,9 @@ out_char (int c)
void void
pn (bc_num num TSRMLS_DC) pn (bc_num num)
{ {
bc_out_num (num, 10, out_char, 0 TSRMLS_CC); bc_out_num (num, 10, out_char, 0);
out_char ('\n'); out_char ('\n');
} }

View file

@ -85,7 +85,7 @@ _one_mult (num, size, digit, result)
by zero is tried. The algorithm is found in Knuth Vol 2. p237. */ by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
int int
bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC) bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale)
{ {
bc_num qval; bc_num qval;
unsigned char *num1, *num2; unsigned char *num1, *num2;
@ -98,7 +98,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
unsigned int norm; unsigned int norm;
/* Test for divide by zero. */ /* Test for divide by zero. */
if (bc_is_zero (n2 TSRMLS_CC)) return -1; if (bc_is_zero (n2)) return -1;
/* Test for divide by 1. If it is we must truncate. */ /* Test for divide by 1. If it is we must truncate. */
if (n2->n_scale == 0) if (n2->n_scale == 0)
@ -259,7 +259,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
/* Clean up and return the number. */ /* Clean up and return the number. */
qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS ); qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
if (bc_is_zero (qval TSRMLS_CC)) qval->n_sign = PLUS; if (bc_is_zero (qval)) qval->n_sign = PLUS;
_bc_rm_leading_zeros (qval); _bc_rm_leading_zeros (qval);
bc_free_num (quot); bc_free_num (quot);
*quot = qval; *quot = qval;

View file

@ -45,24 +45,24 @@
*/ */
int int
bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS_DC) bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale)
{ {
bc_num quotient = NULL; bc_num quotient = NULL;
bc_num temp; bc_num temp;
int rscale; int rscale;
/* Check for correct numbers. */ /* Check for correct numbers. */
if (bc_is_zero (num2 TSRMLS_CC)) return -1; if (bc_is_zero (num2)) return -1;
/* Calculate final scale. */ /* Calculate final scale. */
rscale = MAX (num1->n_scale, num2->n_scale+scale); rscale = MAX (num1->n_scale, num2->n_scale+scale);
bc_init_num(&temp TSRMLS_CC); bc_init_num(&temp);
/* Calculate it. */ /* Calculate it. */
bc_divide (num1, num2, &temp, scale TSRMLS_CC); bc_divide (num1, num2, &temp, scale);
if (quot) if (quot)
quotient = bc_copy_num (temp); quotient = bc_copy_num (temp);
bc_multiply (temp, num2, &temp, rscale TSRMLS_CC); bc_multiply (temp, num2, &temp, rscale);
bc_sub (num1, temp, rem, rscale); bc_sub (num1, temp, rem, rscale);
bc_free_num (&temp); bc_free_num (&temp);
@ -80,8 +80,8 @@ bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS
result in RESULT. */ result in RESULT. */
int int
bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC) bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale)
{ {
return bc_divmod (num1, num2, NULL, result, scale TSRMLS_CC); return bc_divmod (num1, num2, NULL, result, scale);
} }

View file

@ -101,7 +101,7 @@ _bc_free_num_ex (num, persistent)
/* Intitialize the number package! */ /* Intitialize the number package! */
void void
bc_init_numbers (TSRMLS_D) bc_init_numbers (void)
{ {
BCG(_zero_) = _bc_new_num_ex (1,0,1); BCG(_zero_) = _bc_new_num_ex (1,0,1);
BCG(_one_) = _bc_new_num_ex (1,0,1); BCG(_one_) = _bc_new_num_ex (1,0,1);
@ -124,7 +124,7 @@ bc_copy_num (bc_num num)
/* Initialize a number NUM by making it a copy of zero. */ /* Initialize a number NUM by making it a copy of zero. */
void void
bc_init_num (bc_num *num TSRMLS_DC) bc_init_num (bc_num *num)
{ {
*num = bc_copy_num (BCG(_zero_)); *num = bc_copy_num (BCG(_zero_));
} }

View file

@ -87,9 +87,9 @@ bc_out_long (val, size, space, out_char)
void void
#ifdef __STDC__ #ifdef __STDC__
bc_out_num (bc_num num, int o_base, void (*out_char)(int), int leading_zero TSRMLS_DC) bc_out_num (bc_num num, int o_base, void (*out_char)(int), int leading_zero)
#else #else
bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_DC) bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero)
#endif #endif
{ {
char *nptr; char *nptr;
@ -101,7 +101,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
if (num->n_sign == MINUS) (*out_char) ('-'); if (num->n_sign == MINUS) (*out_char) ('-');
/* Output the number. */ /* Output the number. */
if (bc_is_zero (num TSRMLS_CC)) if (bc_is_zero (num))
(*out_char) ('0'); (*out_char) ('0');
else else
if (o_base == 10) if (o_base == 10)
@ -114,7 +114,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
else else
nptr++; nptr++;
if (leading_zero && bc_is_zero (num TSRMLS_CC)) if (leading_zero && bc_is_zero (num))
(*out_char) ('0'); (*out_char) ('0');
/* Now the fraction. */ /* Now the fraction. */
@ -128,36 +128,36 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
else else
{ {
/* special case ... */ /* special case ... */
if (leading_zero && bc_is_zero (num TSRMLS_CC)) if (leading_zero && bc_is_zero (num))
(*out_char) ('0'); (*out_char) ('0');
/* The number is some other base. */ /* The number is some other base. */
digits = NULL; digits = NULL;
bc_init_num (&int_part TSRMLS_CC); bc_init_num (&int_part);
bc_divide (num, BCG(_one_), &int_part, 0 TSRMLS_CC); bc_divide (num, BCG(_one_), &int_part, 0);
bc_init_num (&frac_part TSRMLS_CC); bc_init_num (&frac_part);
bc_init_num (&cur_dig TSRMLS_CC); bc_init_num (&cur_dig);
bc_init_num (&base TSRMLS_CC); bc_init_num (&base);
bc_sub (num, int_part, &frac_part, 0); bc_sub (num, int_part, &frac_part, 0);
/* Make the INT_PART and FRAC_PART positive. */ /* Make the INT_PART and FRAC_PART positive. */
int_part->n_sign = PLUS; int_part->n_sign = PLUS;
frac_part->n_sign = PLUS; frac_part->n_sign = PLUS;
bc_int2num (&base, o_base); bc_int2num (&base, o_base);
bc_init_num (&max_o_digit TSRMLS_CC); bc_init_num (&max_o_digit);
bc_int2num (&max_o_digit, o_base-1); bc_int2num (&max_o_digit, o_base-1);
/* Get the digits of the integer part and push them on a stack. */ /* Get the digits of the integer part and push them on a stack. */
while (!bc_is_zero (int_part TSRMLS_CC)) while (!bc_is_zero (int_part))
{ {
bc_modulo (int_part, base, &cur_dig, 0 TSRMLS_CC); bc_modulo (int_part, base, &cur_dig, 0);
/* PHP Change: malloc() -> emalloc() */ /* PHP Change: malloc() -> emalloc() */
temp = (stk_rec *) emalloc (sizeof(stk_rec)); temp = (stk_rec *) emalloc (sizeof(stk_rec));
if (temp == NULL) bc_out_of_memory(); if (temp == NULL) bc_out_of_memory();
temp->digit = bc_num2long (cur_dig); temp->digit = bc_num2long (cur_dig);
temp->next = digits; temp->next = digits;
digits = temp; digits = temp;
bc_divide (int_part, base, &int_part, 0 TSRMLS_CC); bc_divide (int_part, base, &int_part, 0);
} }
/* Print the digits on the stack. */ /* Print the digits on the stack. */
@ -183,7 +183,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
pre_space = 0; pre_space = 0;
t_num = bc_copy_num (BCG(_one_)); t_num = bc_copy_num (BCG(_one_));
while (t_num->n_len <= num->n_scale) { while (t_num->n_len <= num->n_scale) {
bc_multiply (frac_part, base, &frac_part, num->n_scale TSRMLS_CC); bc_multiply (frac_part, base, &frac_part, num->n_scale);
fdigit = bc_num2long (frac_part); fdigit = bc_num2long (frac_part);
bc_int2num (&int_part, fdigit); bc_int2num (&int_part, fdigit);
bc_sub (frac_part, int_part, &frac_part, 0); bc_sub (frac_part, int_part, &frac_part, 0);
@ -193,7 +193,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
bc_out_long (fdigit, max_o_digit->n_len, pre_space, out_char); bc_out_long (fdigit, max_o_digit->n_len, pre_space, out_char);
pre_space = 1; pre_space = 1;
} }
bc_multiply (t_num, base, &t_num, 0 TSRMLS_CC); bc_multiply (t_num, base, &t_num, 0);
} }
bc_free_num (&t_num); bc_free_num (&t_num);
} }

View file

@ -44,7 +44,7 @@
only the integer part is used. */ only the integer part is used. */
void void
bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC) bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale)
{ {
bc_num temp, power; bc_num temp, power;
long exponent; long exponent;
@ -87,7 +87,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
while ((exponent & 1) == 0) while ((exponent & 1) == 0)
{ {
pwrscale = 2*pwrscale; pwrscale = 2*pwrscale;
bc_multiply (power, power, &power, pwrscale TSRMLS_CC); bc_multiply (power, power, &power, pwrscale);
exponent = exponent >> 1; exponent = exponent >> 1;
} }
temp = bc_copy_num (power); temp = bc_copy_num (power);
@ -98,10 +98,10 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
while (exponent > 0) while (exponent > 0)
{ {
pwrscale = 2*pwrscale; pwrscale = 2*pwrscale;
bc_multiply (power, power, &power, pwrscale TSRMLS_CC); bc_multiply (power, power, &power, pwrscale);
if ((exponent & 1) == 1) { if ((exponent & 1) == 1) {
calcscale = pwrscale + calcscale; calcscale = pwrscale + calcscale;
bc_multiply (temp, power, &temp, calcscale TSRMLS_CC); bc_multiply (temp, power, &temp, calcscale);
} }
exponent = exponent >> 1; exponent = exponent >> 1;
} }
@ -109,7 +109,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
/* Assign the value. */ /* Assign the value. */
if (neg) if (neg)
{ {
bc_divide (BCG(_one_), temp, result, rscale TSRMLS_CC); bc_divide (BCG(_one_), temp, result, rscale);
bc_free_num (&temp); bc_free_num (&temp);
} }
else else

View file

@ -43,20 +43,20 @@
only the integer part is used. */ only the integer part is used. */
int int
bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSRMLS_DC) bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale)
{ {
bc_num power, exponent, parity, temp; bc_num power, exponent, parity, temp;
int rscale; int rscale;
/* Check for correct numbers. */ /* Check for correct numbers. */
if (bc_is_zero(mod TSRMLS_CC)) return -1; if (bc_is_zero(mod)) return -1;
if (bc_is_neg(expo)) return -1; if (bc_is_neg(expo)) return -1;
/* Set initial values. */ /* Set initial values. */
power = bc_copy_num (base); power = bc_copy_num (base);
exponent = bc_copy_num (expo); exponent = bc_copy_num (expo);
temp = bc_copy_num (BCG(_one_)); temp = bc_copy_num (BCG(_one_));
bc_init_num(&parity TSRMLS_CC); bc_init_num(&parity);
/* Check the base for scale digits. */ /* Check the base for scale digits. */
if (base->n_scale != 0) if (base->n_scale != 0)
@ -66,7 +66,7 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
if (exponent->n_scale != 0) if (exponent->n_scale != 0)
{ {
bc_rt_warn ("non-zero scale in exponent"); bc_rt_warn ("non-zero scale in exponent");
bc_divide (exponent, BCG(_one_), &exponent, 0 TSRMLS_CC); /*truncate */ bc_divide (exponent, BCG(_one_), &exponent, 0); /*truncate */
} }
/* Check the modulus for scale digits. */ /* Check the modulus for scale digits. */
@ -75,17 +75,17 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
/* Do the calculation. */ /* Do the calculation. */
rscale = MAX(scale, base->n_scale); rscale = MAX(scale, base->n_scale);
while ( !bc_is_zero(exponent TSRMLS_CC) ) while ( !bc_is_zero(exponent) )
{ {
(void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0 TSRMLS_CC); (void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0);
if ( !bc_is_zero(parity TSRMLS_CC) ) if ( !bc_is_zero(parity) )
{ {
bc_multiply (temp, power, &temp, rscale TSRMLS_CC); bc_multiply (temp, power, &temp, rscale);
(void) bc_modulo (temp, mod, &temp, scale TSRMLS_CC); (void) bc_modulo (temp, mod, &temp, scale);
} }
bc_multiply (power, power, &power, rscale TSRMLS_CC); bc_multiply (power, power, &power, rscale);
(void) bc_modulo (power, mod, &power, scale TSRMLS_CC); (void) bc_modulo (power, mod, &power, scale);
} }
/* Assign the value. */ /* Assign the value. */

View file

@ -180,7 +180,7 @@ _bc_shift_addsub (bc_num accum, bc_num val, int shift, int sub)
*/ */
static void static void
_bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod, _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
int full_scale TSRMLS_DC) int full_scale)
{ {
bc_num u0, u1, v0, v1; bc_num u0, u1, v0, v1;
bc_num m1, m2, m3, d1, d2; bc_num m1, m2, m3, d1, d2;
@ -218,12 +218,12 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
_bc_rm_leading_zeros (v1); _bc_rm_leading_zeros (v1);
_bc_rm_leading_zeros (v0); _bc_rm_leading_zeros (v0);
m1zero = bc_is_zero(u1 TSRMLS_CC) || bc_is_zero(v1 TSRMLS_CC); m1zero = bc_is_zero(u1) || bc_is_zero(v1);
/* Calculate sub results ... */ /* Calculate sub results ... */
bc_init_num(&d1 TSRMLS_CC); bc_init_num(&d1);
bc_init_num(&d2 TSRMLS_CC); bc_init_num(&d2);
bc_sub (u1, u0, &d1, 0); bc_sub (u1, u0, &d1, 0);
d1len = d1->n_len; d1len = d1->n_len;
bc_sub (v0, v1, &d2, 0); bc_sub (v0, v1, &d2, 0);
@ -234,17 +234,17 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
if (m1zero) if (m1zero)
m1 = bc_copy_num (BCG(_zero_)); m1 = bc_copy_num (BCG(_zero_));
else else
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0 TSRMLS_CC); _bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0);
if (bc_is_zero(d1 TSRMLS_CC) || bc_is_zero(d2 TSRMLS_CC)) if (bc_is_zero(d1) || bc_is_zero(d2))
m2 = bc_copy_num (BCG(_zero_)); m2 = bc_copy_num (BCG(_zero_));
else else
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0 TSRMLS_CC); _bc_rec_mul (d1, d1len, d2, d2len, &m2, 0);
if (bc_is_zero(u0 TSRMLS_CC) || bc_is_zero(v0 TSRMLS_CC)) if (bc_is_zero(u0) || bc_is_zero(v0))
m3 = bc_copy_num (BCG(_zero_)); m3 = bc_copy_num (BCG(_zero_));
else else
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0 TSRMLS_CC); _bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0);
/* Initialize product */ /* Initialize product */
prodlen = ulen+vlen+1; prodlen = ulen+vlen+1;
@ -275,7 +275,7 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
*/ */
void void
bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC) bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale)
{ {
bc_num pval; bc_num pval;
int len1, len2; int len1, len2;
@ -288,7 +288,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale))); prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale)));
/* Do the multiply */ /* Do the multiply */
_bc_rec_mul (n1, len1, n2, len2, &pval, full_scale TSRMLS_CC); _bc_rec_mul (n1, len1, n2, len2, &pval, full_scale);
/* Assign to prod and clean up the number. */ /* Assign to prod and clean up the number. */
pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS ); pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
@ -296,7 +296,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
pval->n_len = len2 + len1 + 1 - full_scale; pval->n_len = len2 + len1 + 1 - full_scale;
pval->n_scale = prod_scale; pval->n_scale = prod_scale;
_bc_rm_leading_zeros (pval); _bc_rm_leading_zeros (pval);
if (bc_is_zero (pval TSRMLS_CC)) if (bc_is_zero (pval))
pval->n_sign = PLUS; pval->n_sign = PLUS;
bc_free_num (prod); bc_free_num (prod);
*prod = pval; *prod = pval;

Some files were not shown because too many files have changed in this diff Show more