Introduced "zif_handler" type (zif = zend internal function).

This commit is contained in:
Dmitry Stogov 2017-06-08 16:52:39 +03:00
parent ace9fe5317
commit db4561bfff
8 changed files with 62 additions and 59 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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) /* {{{ */

View File

@ -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;

View File

@ -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; \
\