Fixed apply_func_arg_t, and it's better not using cast (compiler friendly)

This commit is contained in:
Xinchen Hui 2014-05-25 19:56:51 +08:00
parent c2082ece52
commit 0175d994c0
6 changed files with 26 additions and 20 deletions

View file

@ -1095,7 +1095,7 @@ ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static int zend_merge_property(zval *value TSRMLS_DC, int num_args, va_list args, const zend_hash_key *hash_key) /* {{{ */ static int zend_merge_property(zval *value TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{ {
/* which name should a numeric property have ? */ /* which name should a numeric property have ? */
if (hash_key->key) { if (hash_key->key) {
@ -1119,7 +1119,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro
zend_class_entry *old_scope = EG(scope); zend_class_entry *old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(obj); EG(scope) = Z_OBJCE_P(obj);
zend_hash_apply_with_arguments(properties TSRMLS_CC, (apply_func_args_t)zend_merge_property, 2, obj, obj_ht); zend_hash_apply_with_arguments(properties TSRMLS_CC, zend_merge_property, 2, obj, obj_ht);
EG(scope) = old_scope; EG(scope) = old_scope;
if (destroy_ht) { if (destroy_ht) {
@ -2453,9 +2453,11 @@ ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */
} }
/* }}} */ /* }}} */
static int clean_module_class(const zend_class_entry **ce, int *module_number TSRMLS_DC) /* {{{ */ static int clean_module_class(zval *el, void *arg TSRMLS_DC) /* {{{ */
{ {
if ((*ce)->type == ZEND_INTERNAL_CLASS && (*ce)->info.internal.module->module_number == *module_number) { zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
int module_number = *(int *)arg;
if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
return ZEND_HASH_APPLY_REMOVE; return ZEND_HASH_APPLY_REMOVE;
} else { } else {
return ZEND_HASH_APPLY_KEEP; return ZEND_HASH_APPLY_KEEP;
@ -2465,7 +2467,7 @@ static int clean_module_class(const zend_class_entry **ce, int *module_number TS
static void clean_module_classes(int module_number TSRMLS_DC) /* {{{ */ static void clean_module_classes(int module_number TSRMLS_DC) /* {{{ */
{ {
zend_hash_apply_with_argument(EG(class_table), (apply_func_arg_t) clean_module_class, (void *) &module_number TSRMLS_CC); zend_hash_apply_with_argument(EG(class_table), clean_module_class, (void *) &module_number TSRMLS_CC);
} }
/* }}} */ /* }}} */

View file

@ -1873,7 +1873,7 @@ ZEND_FUNCTION(get_loaded_extensions)
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 TSRMLS_CC);
} else { } else {
zend_hash_apply_with_argument(&module_registry, (apply_func_arg_t)add_extension_info, return_value TSRMLS_CC); zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value TSRMLS_CC);
} }
} }
/* }}} */ /* }}} */
@ -1939,7 +1939,7 @@ 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), (apply_func_arg_t)add_constant_info, return_value TSRMLS_CC); zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value TSRMLS_CC);
} }
} }
/* }}} */ /* }}} */

View file

@ -4101,9 +4101,10 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
} }
/* }}} */ /* }}} */
static int zend_fixup_trait_method(zval *zv, zend_class_entry *ce TSRMLS_DC) /* {{{ */ static int zend_fixup_trait_method(zval *zv, void *arg TSRMLS_DC) /* {{{ */
{ {
zend_function *fn = Z_PTR_P(zv); zend_function *fn = Z_PTR_P(zv);
zend_class_entry *ce = (zend_class_entry *)arg;
if ((fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { if ((fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
@ -4368,15 +4369,15 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
zend_traits_compile_exclude_table(&exclude_table, ce->trait_precedences, ce->traits[i]); zend_traits_compile_exclude_table(&exclude_table, ce->trait_precedences, ce->traits[i]);
/* copies functions, applies defined aliasing, and excludes unused trait methods */ /* copies functions, applies defined aliasing, and excludes unused trait methods */
zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, &exclude_table); zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, zend_traits_copy_functions, 3, ce, &overriden, &exclude_table);
zend_hash_destroy(&exclude_table); zend_hash_destroy(&exclude_table);
} else { } else {
zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, NULL); zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, zend_traits_copy_functions, 3, ce, &overriden, NULL);
} }
} }
zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t)zend_fixup_trait_method, ce TSRMLS_CC); zend_hash_apply_with_argument(&ce->function_table, zend_fixup_trait_method, ce TSRMLS_CC);
if (overriden) { if (overriden) {
zend_hash_destroy(overriden); zend_hash_destroy(overriden);

View file

@ -1541,9 +1541,10 @@ typedef struct _zend_abstract_info {
int ctor; int ctor;
} zend_abstract_info; } zend_abstract_info;
static int zend_verify_abstract_class_function(zval *zv, zend_abstract_info *ai TSRMLS_DC) /* {{{ */ static int zend_verify_abstract_class_function(zval *zv, void *arg TSRMLS_DC) /* {{{ */
{ {
zend_function *fn = Z_PTR_P(zv); zend_function *fn = (zend_function *)Z_PTR_P(zv);
zend_abstract_info *ai = (zend_abstract_info *)arg;
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) {
@ -1571,7 +1572,7 @@ void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */
if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
memset(&ai, 0, sizeof(ai)); memset(&ai, 0, sizeof(ai));
zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) zend_verify_abstract_class_function, &ai TSRMLS_CC); zend_hash_apply_with_argument(&ce->function_table, zend_verify_abstract_class_function, &ai TSRMLS_CC);
if (ai.cnt) { if (ai.cnt) {
zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")", zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",

View file

@ -34,8 +34,9 @@ static HashTable *registered_zend_ini_directives;
/* /*
* hash_apply functions * hash_apply functions
*/ */
static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number TSRMLS_DC) /* {{{ */ static int zend_remove_ini_entries(zval *el, int *module_number TSRMLS_DC) /* {{{ */
{ {
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
if (ini_entry->module_number == *module_number) { if (ini_entry->module_number == *module_number) {
return 1; return 1;
} else { } else {
@ -224,13 +225,14 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int modu
ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */ ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */
{ {
zend_hash_apply_with_argument(registered_zend_ini_directives, (apply_func_arg_t) 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 TSRMLS_CC);
} }
/* }}} */ /* }}} */
#ifdef ZTS #ifdef ZTS
static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{ */ static int zend_ini_refresh_cache(zval *el, int stage TSRMLS_DC) /* {{{ */
{ {
zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el);
if (p->on_modify) { if (p->on_modify) {
p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC); p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC);
} }
@ -240,7 +242,7 @@ static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{
ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */ ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */
{ {
zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) 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 TSRMLS_CC);
} }
/* }}} */ /* }}} */
#endif #endif

View file

@ -242,7 +242,7 @@ static int zend_clean_module_rsrc_dtors_cb(zval *zv, int *module_number TSRMLS_D
{ {
zend_rsrc_list_dtors_entry *ld = Z_PTR_P(zv); zend_rsrc_list_dtors_entry *ld = Z_PTR_P(zv);
if (ld->module_number == *module_number) { if (ld->module_number == *module_number) {
zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); zend_hash_apply_with_argument(&EG(persistent_list), clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
return 1; return 1;
} else { } else {
return 0; return 0;
@ -252,7 +252,7 @@ static int zend_clean_module_rsrc_dtors_cb(zval *zv, int *module_number TSRMLS_D
void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC) void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC)
{ {
zend_hash_apply_with_argument(&list_destructors, (apply_func_arg_t) 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 TSRMLS_CC);
} }