From db4561bfffc348fe99276b059e360eba4c906c4a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 8 Jun 2017 16:52:39 +0300 Subject: [PATCH] Introduced "zif_handler" type (zif = zend internal function). --- Zend/zend_API.h | 2 +- Zend/zend_closures.c | 6 ++-- Zend/zend_compile.h | 5 ++- ext/opcache/ZendAccelerator.c | 2 +- ext/opcache/zend_accelerator_module.c | 12 +++---- ext/phar/func_interceptors.c | 48 +++++++++++++-------------- ext/phar/phar_internal.h | 44 ++++++++++++------------ ext/standard/filestat.c | 2 +- 8 files changed, 62 insertions(+), 59 deletions(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 69f4d56b62..df04be1fbe 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -35,7 +35,7 @@ BEGIN_EXTERN_C() typedef struct _zend_function_entry { const char *fname; - void (*handler)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler handler; const struct _zend_internal_arg_info *arg_info; uint32_t num_args; uint32_t flags; diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 6e7b30361f..2dd468d954 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -39,7 +39,7 @@ typedef struct _zend_closure { zend_function func; zval this_ptr; zend_class_entry *called_scope; - void (*orig_internal_handler)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler orig_internal_handler; } zend_closure; /* non-static since it needs to be referenced */ @@ -235,7 +235,7 @@ ZEND_METHOD(Closure, bind) } /* }}} */ -static void zend_closure_call_magic(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ { +static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { zend_fcall_info fci; zend_fcall_info_cache fcc; zval params[2]; @@ -628,7 +628,7 @@ void zend_register_closure_ce(void) /* {{{ */ } /* }}} */ -static void zend_closure_internal_handler(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ +static ZEND_NAMED_FUNCTION(zend_closure_internal_handler) /* {{{ */ { zend_closure *closure = (zend_closure*)EX(func)->common.prototype; closure->orig_internal_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 44035a67ff..4264232bc4 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -409,6 +409,9 @@ struct _zend_op_array { #define ZEND_RETURN_VALUE 0 #define ZEND_RETURN_REFERENCE 1 +/* zend_internal_function_handler */ +typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); + typedef struct _zend_internal_function { /* Common elements */ zend_uchar type; @@ -422,7 +425,7 @@ typedef struct _zend_internal_function { zend_internal_arg_info *arg_info; /* END of common elements */ - void (*handler)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler handler; struct _zend_module_entry *module; void *reserved[ZEND_MAX_RESERVED_RESOURCES]; } zend_internal_function; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 0d81b89455..c2ff267606 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -115,7 +115,7 @@ zend_bool fallback_process = 0; /* process uses file cache fallback */ static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); static int (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); static zend_string *(*accelerator_orig_zend_resolve_path)(const char *filename, int filename_len); -static void (*orig_chdir)(INTERNAL_FUNCTION_PARAMETERS) = NULL; +static zif_handler orig_chdir = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; static void accel_gen_system_id(void); diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index c583f679b2..6f76851455 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -37,9 +37,9 @@ #define MAX_ACCEL_FILES 1000000 #define TOKENTOSTR(X) #X -static void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS) = NULL; -static void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS) = NULL; -static void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS) = NULL; +static zif_handler orig_file_exists = NULL; +static zif_handler orig_is_file = NULL; +static zif_handler orig_is_readable = NULL; ZEND_BEGIN_ARG_INFO(arginfo_opcache_none, 0) ZEND_END_ARG_INFO() @@ -365,7 +365,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS) return filename_is_in_cache(Z_STR(zfilename)); } -static void accel_file_exists(INTERNAL_FUNCTION_PARAMETERS) +static ZEND_NAMED_FUNCTION(accel_file_exists) { if (accel_file_in_cache(INTERNAL_FUNCTION_PARAM_PASSTHRU)) { RETURN_TRUE; @@ -374,7 +374,7 @@ static void accel_file_exists(INTERNAL_FUNCTION_PARAMETERS) } } -static void accel_is_file(INTERNAL_FUNCTION_PARAMETERS) +static ZEND_NAMED_FUNCTION(accel_is_file) { if (accel_file_in_cache(INTERNAL_FUNCTION_PARAM_PASSTHRU)) { RETURN_TRUE; @@ -383,7 +383,7 @@ static void accel_is_file(INTERNAL_FUNCTION_PARAMETERS) } } -static void accel_is_readable(INTERNAL_FUNCTION_PARAMETERS) +static ZEND_NAMED_FUNCTION(accel_is_readable) { if (accel_file_in_cache(INTERNAL_FUNCTION_PARAM_PASSTHRU)) { RETURN_TRUE; diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index 20a827e1d9..eb05d4ce2d 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -585,7 +585,7 @@ static void phar_fancy_stat(zend_stat_t *stat_sb, int type, zval *return_value) } /* }}} */ -static void phar_file_stat(const char *filename, size_t filename_length, int type, void (*orig_stat_func)(INTERNAL_FUNCTION_PARAMETERS), INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ +static void phar_file_stat(const char *filename, size_t filename_length, int type, zif_handler orig_stat_func, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ { if (!filename_length) { RETURN_FALSE; @@ -759,7 +759,7 @@ skip_phar: /* }}} */ #define PharFileFunction(fname, funcnum, orig) \ -void fname(INTERNAL_FUNCTION_PARAMETERS) { \ +ZEND_NAMED_FUNCTION(fname) { \ if (!PHAR_G(intercepted)) { \ PHAR_G(orig)(INTERNAL_FUNCTION_PARAM_PASSTHRU); \ } else { \ @@ -1080,28 +1080,28 @@ void phar_intercept_functions_shutdown(void) /* }}} */ static struct _phar_orig_functions { - void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler orig_fopen; + zif_handler orig_file_get_contents; + zif_handler orig_is_file; + zif_handler orig_is_link; + zif_handler orig_is_dir; + zif_handler orig_opendir; + zif_handler orig_file_exists; + zif_handler orig_fileperms; + zif_handler orig_fileinode; + zif_handler orig_filesize; + zif_handler orig_fileowner; + zif_handler orig_filegroup; + zif_handler orig_fileatime; + zif_handler orig_filemtime; + zif_handler orig_filectime; + zif_handler orig_filetype; + zif_handler orig_is_writable; + zif_handler orig_is_readable; + zif_handler orig_is_executable; + zif_handler orig_lstat; + zif_handler orig_readfile; + zif_handler orig_stat; } phar_orig_functions = {NULL}; void phar_save_orig_functions(void) /* {{{ */ diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index e06550d266..c08c88de19 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -155,28 +155,28 @@ ZEND_BEGIN_MODULE_GLOBALS(phar) int require_hash; int request_done; int request_ends; - void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS); - void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler orig_fopen; + zif_handler orig_file_get_contents; + zif_handler orig_is_file; + zif_handler orig_is_link; + zif_handler orig_is_dir; + zif_handler orig_opendir; + zif_handler orig_file_exists; + zif_handler orig_fileperms; + zif_handler orig_fileinode; + zif_handler orig_filesize; + zif_handler orig_fileowner; + zif_handler orig_filegroup; + zif_handler orig_fileatime; + zif_handler orig_filemtime; + zif_handler orig_filectime; + zif_handler orig_filetype; + zif_handler orig_is_writable; + zif_handler orig_is_readable; + zif_handler orig_is_executable; + zif_handler orig_lstat; + zif_handler orig_readfile; + zif_handler orig_stat; /* used for includes with . in them inside front controller */ char* cwd; int cwd_len; diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index dfb1c93490..f51892b510 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -996,7 +996,7 @@ PHPAPI void php_stat(const char *filename, size_t filename_length, int type, zva /* another quickie macro to make defining similar functions easier */ /* {{{ FileFunction(name, funcnum) */ #define FileFunction(name, funcnum) \ -void name(INTERNAL_FUNCTION_PARAMETERS) { \ +ZEND_NAMED_FUNCTION(name) { \ char *filename; \ size_t filename_len; \ \ -- 2.40.0