1
0
Fork 0

fix build for older PHP

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1561 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2014-11-10 11:07:01 +00:00
parent 6c397c70ec
commit 51accff949
9 changed files with 63 additions and 15 deletions

View File

@ -1423,7 +1423,9 @@ static void xc_collect_class_constant_info(xc_compiler_t *compiler, xc_const_usa
if ((Z_TYPE_P(constant) & IS_CONSTANT_TYPE_MASK) == IS_STRING) {
XCACHE_ANALYZE_CONSTANT(file, 0)
# ifdef ZEND_ENGINE_2_3
else XCACHE_ANALYZE_CONSTANT(dir, 0)
# endif
}
# ifdef IS_UNICODE
else if ((Z_TYPE_P(constant) & IS_CONSTANT_TYPE_MASK) == IS_UNICODE) {
@ -1463,7 +1465,9 @@ static void xc_collect_op_array_info(xc_compiler_t *compiler, xc_const_usage_t *
if (Z_TYPE_P(constant) == IS_STRING) {
XCACHE_ANALYZE_CONSTANT(file, 0)
# ifdef ZEND_ENGINE_2_3
else XCACHE_ANALYZE_CONSTANT(dir, 0)
# endif
}
# ifdef IS_UNICODE
else if (Z_TYPE_P(constant) == IS_UNICODE) {
@ -1520,7 +1524,7 @@ static void xc_collect_op_array_info(xc_compiler_t *compiler, xc_const_usage_t *
xc_constant_info_t detail;
detail.index = oplinenum;
detail.info = constantinfo;
xc_vector_add(xc_constant_info_t, &constantinfos, detail);
xc_vector_push_back(&constantinfos, &detail);
}
}
#endif /* ZEND_ENGINE_2_4 */
@ -1583,9 +1587,11 @@ void xc_fix_class_info(const xc_entry_php_t *entry_php, xc_classinfo_t *classinf
if ((constantinfo & xcache_constant_is_file)) {
xc_restore_constant_string("class_constant", constant, Z_TYPE_P(constant), &entry_php->filepath, &entry_php->u_filepath, shallow_copy TSRMLS_CC);
}
# ifdef ZEND_ENGINE_2_3
else if ((constantinfo & xcache_constant_is_dir)) {
xc_restore_constant_string("class_constant", constant, Z_TYPE_P(constant), &entry_php->dirpath, &entry_php->u_dirpath, shallow_copy TSRMLS_CC);
}
# endif
}
}
/* }}} */
@ -3669,7 +3675,7 @@ static inline void xc_var_inc_dec(int inc, INTERNAL_FUNCTION_PARAMETERS) /* {{{
}
TRACE("%s", "incdec: notlong");
if (stored_entry_var->objects_count) {
if (stored_entry_var->class_names_count) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot convert object to integer");
value = 0;
}

View File

@ -518,7 +518,9 @@ static int bbs_build_from(bbs_t *bbs, zend_op_array *op_array, int count TSRMLS_
static void bbs_restore_opnum(bbs_t *bbs, zend_op_array *op_array) /* {{{ */
{
int bbid;
#ifdef ZEND_ENGINE_2
int i;
#endif
for (bbid = 0; bbid < bbs_count(bbs); bbid ++) {
op_flowinfo_t fi;

View File

@ -153,7 +153,7 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
#ifdef ZEND_ENGINE_2
if (src->objects_count) {
for (i = 0; i < src->objects_count; ++i) {
zend_objects_store_del_ref_by_handle_ex(processor.object_handles[i], NULL TSRMLS_CC);
zend_objects_store_del_ref_by_handle(processor.object_handles[i] TSRMLS_CC);
}
efree(processor.object_handles);
}

View File

@ -1424,10 +1424,6 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
SRC(objects) = xc_vector_detach(zend_object, &processor->objects);
popdef(`src')
xc_vector_destroy(&processor->objects);
if (SRC(`objects_count')) {
xc_vector_init(xc_constant_string_t, &processor->class_names, 0);
zend_hash_init(&processor->class_name_to_index, 0, NULL, NULL, 0);
}
')
dnl must be after calc .value
PROCESS(zend_uint, objects_count)
@ -1457,10 +1453,6 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
IFSTORE(`
/* no longer needed */
if (vsrc->class_names_count) {
dnl size_t i;
dnl for (i = 0; i < vsrc->class_names_count; ++i) {
dnl efree(vsrc->class_names[i]);
dnl }
efree(vsrc->class_names);
vsrc->class_names_count = 0;
vsrc->class_names = NULL;

View File

@ -1,8 +1,9 @@
/* {{{ var object helpers */
zend_bool have_objects;
#ifdef ZEND_ENGINE_2
xc_vector_t objects; /* in calc only */
HashTable handle_to_index; /* in calc/store only */
zend_object_handle *object_handles; /* in restore only */
#endif
const xc_entry_var_t *entry_var_src; /* in restore */
xc_vector_t class_names; /* in calc only */

View File

@ -1,13 +1,14 @@
#ifdef ZEND_ENGINE_2
static void xc_var_collect_object(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC) /* {{{ */
{
size_t next_index = xc_vector_size(&processor->objects);
size_t next_index;
if (!xc_vector_initialized(&processor->objects)) {
xc_vector_init(zend_object, &processor->objects, 0);
zend_hash_init(&processor->handle_to_index, 0, NULL, NULL, 0);
}
next_index = xc_vector_size(&processor->objects);
if (_zend_hash_index_update_or_next_insert(&processor->handle_to_index, handle, (void *) &next_index, sizeof(next_index), NULL, HASH_ADD ZEND_FILE_LINE_CC) == SUCCESS) {
zend_object *object = zend_object_store_get_object_by_handle(handle TSRMLS_CC);
xc_vector_push_back(&processor->objects, object);
@ -36,8 +37,14 @@ static zend_object_handle xc_var_restore_handle(xc_processor_t *processor, size_
#endif
static void xc_var_collect_class(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
size_t next_index = xc_vector_size(&processor->class_names);
size_t next_index;
if (!xc_vector_initialized(&processor->class_names)) {
xc_vector_init(xc_constant_string_t, &processor->class_names, 0);
zend_hash_init(&processor->class_name_to_index, 0, NULL, NULL, 0);
}
next_index = xc_vector_size(&processor->class_names);
if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) {
xc_constant_string_t class_name;
class_name.str = (char *) ce->name;

View File

@ -43,3 +43,28 @@ long xc_atol(const char *str, int str_len) /* {{{ */
}
/* }}} */
#endif
#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_2)
void *xc_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */
{
zval zobject;
Z_OBJ_HANDLE_P(&zobject) = handle;
return zend_object_store_get_object(&zobject TSRMLS_CC);
}
/* }}} */
void xc_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */
{
zval zobject;
Z_OBJ_HANDLE_P(&zobject) = handle;
zend_objects_store_add_ref(&zobject TSRMLS_CC);
}
/* }}} */
void xc_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */
{
zval zobject;
Z_OBJ_HANDLE_P(&zobject) = handle;
zobject.refcount = 0;
zend_objects_store_del_ref(&zobject TSRMLS_CC);
}
/* }}} */
#endif

View File

@ -282,4 +282,15 @@ long xc_atol(const char *str, int len);
# endif
#endif
#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_2)
void *xc_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC);
# define zend_object_store_get_object_by_handle xc_object_store_get_object_by_handle
void xc_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
# define zend_objects_store_add_ref_by_handle xc_objects_store_add_ref_by_handle
void xc_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC);
# define zend_objects_store_del_ref_by_handle xc_objects_store_del_ref_by_handle
#endif
#endif /* XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C */

View File

@ -641,10 +641,14 @@ void xc_copy_internal_zend_constants(HashTable *target, HashTable *source) /* {{
zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC) /* {{{ */
{
xc_cest_t *cest;
#ifdef ZEND_ENGINE_2
#ifdef ZEND_ENGINE_2_4
if (zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &cest TSRMLS_CC) != SUCCESS) {
return NULL;
}
#elif defined(ZEND_ENGINE_2)
if (zend_lookup_class_ex(class_name, class_name_len, autoload, &cest TSRMLS_CC) != SUCCESS) {
return NULL;
}
#else
if (zend_hash_find(EG(class_table), class_name, class_name_len, (void **) &cest) != SUCCESS) {
return NULL;