summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-10 11:07:01 +0000
committerXuefer <xuefer@gmail.com>2014-11-10 11:07:01 +0000
commit51accff949c03c54a1f5fef4c54e2aa61feb00ba (patch)
treef1047f9923d4511b6ea4adbdaae7333ad73f919f
parent6c397c70ecd8a7a4e67dd347614ee4571c2830fd (diff)
downloadxcache-51accff949c03c54a1f5fef4c54e2aa61feb00ba.tar.gz
xcache-51accff949c03c54a1f5fef4c54e2aa61feb00ba.zip
fix build for older PHP
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1561 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
-rw-r--r--mod_cacher/xc_cacher.c10
-rw-r--r--mod_optimizer/xc_optimizer.c2
-rw-r--r--processor/foot.m42
-rw-r--r--processor/processor.m48
-rw-r--r--processor/var-helper-t.h3
-rw-r--r--processor/var-helper.h11
-rw-r--r--xcache/xc_compatibility.c25
-rw-r--r--xcache/xc_compatibility.h11
-rw-r--r--xcache/xc_utils.c6
9 files changed, 63 insertions, 15 deletions
diff --git a/mod_cacher/xc_cacher.c b/mod_cacher/xc_cacher.c
index 40c55be..8a7c01d 100644
--- a/mod_cacher/xc_cacher.c
+++ b/mod_cacher/xc_cacher.c
@@ -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;
}
diff --git a/mod_optimizer/xc_optimizer.c b/mod_optimizer/xc_optimizer.c
index ae70d5d..4fe8cad 100644
--- a/mod_optimizer/xc_optimizer.c
+++ b/mod_optimizer/xc_optimizer.c
@@ -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;
diff --git a/processor/foot.m4 b/processor/foot.m4
index 31cd2c7..ff614ef 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -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);
}
diff --git a/processor/processor.m4 b/processor/processor.m4
index 696add7..c33999c 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -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;
diff --git a/processor/var-helper-t.h b/processor/var-helper-t.h
index 12c2a81..25ef538 100644
--- a/processor/var-helper-t.h
+++ b/processor/var-helper-t.h
@@ -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 */
diff --git a/processor/var-helper.h b/processor/var-helper.h
index 852f891..700dfb4 100644
--- a/processor/var-helper.h
+++ b/processor/var-helper.h
@@ -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;
diff --git a/xcache/xc_compatibility.c b/xcache/xc_compatibility.c
index 07ad6f5..2b2f8bb 100644
--- a/xcache/xc_compatibility.c
+++ b/xcache/xc_compatibility.c
@@ -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
diff --git a/xcache/xc_compatibility.h b/xcache/xc_compatibility.h
index 8840a30..b2be78c 100644
--- a/xcache/xc_compatibility.h
+++ b/xcache/xc_compatibility.h
@@ -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 */
diff --git a/xcache/xc_utils.c b/xcache/xc_utils.c
index b757b3c..244d015 100644
--- a/xcache/xc_utils.c
+++ b/xcache/xc_utils.c
@@ -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;