1
0
Fork 0

ZEND_STRS ZEND_STRL is inconsist between PHP5.0- and PHP5.0+

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1313 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.1
Xuefer 2013-07-15 02:30:59 +00:00
parent c4d23d3884
commit 31e5f026de
9 changed files with 73 additions and 70 deletions

View File

@ -602,46 +602,46 @@ static void xc_fillinfo_unlocked(int cachetype, xc_cache_t *cache, zval *return_
interval = xc_var_gc_interval;
}
add_assoc_long_ex(return_value, ZEND_STRS("slots"), cache->hentry->size);
add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cached->compiling);
add_assoc_long_ex(return_value, ZEND_STRS("disabled"), cached->disabled);
add_assoc_long_ex(return_value, ZEND_STRS("updates"), cached->updates);
add_assoc_long_ex(return_value, ZEND_STRS("misses"), cached->updates); /* deprecated */
add_assoc_long_ex(return_value, ZEND_STRS("hits"), cached->hits);
add_assoc_long_ex(return_value, ZEND_STRS("skips"), cached->skips);
add_assoc_long_ex(return_value, ZEND_STRS("clogs"), cached->skips); /* deprecated */
add_assoc_long_ex(return_value, ZEND_STRS("ooms"), cached->ooms);
add_assoc_long_ex(return_value, ZEND_STRS("errors"), cached->errors);
add_assoc_long_ex(return_value, XCACHE_STRS("slots"), cache->hentry->size);
add_assoc_long_ex(return_value, XCACHE_STRS("compiling"), cached->compiling);
add_assoc_long_ex(return_value, XCACHE_STRS("disabled"), cached->disabled);
add_assoc_long_ex(return_value, XCACHE_STRS("updates"), cached->updates);
add_assoc_long_ex(return_value, XCACHE_STRS("misses"), cached->updates); /* deprecated */
add_assoc_long_ex(return_value, XCACHE_STRS("hits"), cached->hits);
add_assoc_long_ex(return_value, XCACHE_STRS("skips"), cached->skips);
add_assoc_long_ex(return_value, XCACHE_STRS("clogs"), cached->skips); /* deprecated */
add_assoc_long_ex(return_value, XCACHE_STRS("ooms"), cached->ooms);
add_assoc_long_ex(return_value, XCACHE_STRS("errors"), cached->errors);
add_assoc_long_ex(return_value, ZEND_STRS("cached"), cached->entries_count);
add_assoc_long_ex(return_value, ZEND_STRS("deleted"), cached->deletes_count);
add_assoc_long_ex(return_value, XCACHE_STRS("cached"), cached->entries_count);
add_assoc_long_ex(return_value, XCACHE_STRS("deleted"), cached->deletes_count);
if (interval) {
time_t gc = (cached->last_gc_expires + interval) - XG(request_time);
add_assoc_long_ex(return_value, ZEND_STRS("gc"), gc > 0 ? gc : 0);
add_assoc_long_ex(return_value, XCACHE_STRS("gc"), gc > 0 ? gc : 0);
}
else {
add_assoc_null_ex(return_value, ZEND_STRS("gc"));
add_assoc_null_ex(return_value, XCACHE_STRS("gc"));
}
MAKE_STD_ZVAL(hits);
array_init(hits);
for (i = 0; i < sizeof(cached->hits_by_hour) / sizeof(cached->hits_by_hour[0]); i ++) {
add_next_index_long(hits, (long) cached->hits_by_hour[i]);
}
add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_hour"), hits);
add_assoc_zval_ex(return_value, XCACHE_STRS("hits_by_hour"), hits);
MAKE_STD_ZVAL(hits);
array_init(hits);
for (i = 0; i < sizeof(cached->hits_by_second) / sizeof(cached->hits_by_second[0]); i ++) {
add_next_index_long(hits, (long) cached->hits_by_second[i]);
}
add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_second"), hits);
add_assoc_zval_ex(return_value, XCACHE_STRS("hits_by_second"), hits);
MAKE_STD_ZVAL(blocks);
array_init(blocks);
add_assoc_long_ex(return_value, ZEND_STRS("size"), vtable->size(allocator));
add_assoc_long_ex(return_value, ZEND_STRS("avail"), vtable->avail(allocator));
add_assoc_bool_ex(return_value, ZEND_STRS("can_readonly"), xc_readonly_protection);
add_assoc_long_ex(return_value, XCACHE_STRS("size"), vtable->size(allocator));
add_assoc_long_ex(return_value, XCACHE_STRS("avail"), vtable->avail(allocator));
add_assoc_bool_ex(return_value, XCACHE_STRS("can_readonly"), xc_readonly_protection);
for (b = vtable->freeblock_first(allocator); b; b = vtable->freeblock_next(b)) {
zval *bi;
@ -649,14 +649,14 @@ static void xc_fillinfo_unlocked(int cachetype, xc_cache_t *cache, zval *return_
MAKE_STD_ZVAL(bi);
array_init(bi);
add_assoc_long_ex(bi, ZEND_STRS("size"), vtable->block_size(b));
add_assoc_long_ex(bi, ZEND_STRS("offset"), vtable->block_offset(allocator, b));
add_assoc_long_ex(bi, XCACHE_STRS("size"), vtable->block_size(b));
add_assoc_long_ex(bi, XCACHE_STRS("offset"), vtable->block_offset(allocator, b));
add_next_index_zval(blocks, bi);
#ifndef NDEBUG
avail += vtable->block_size(b);
#endif
}
add_assoc_zval_ex(return_value, ZEND_STRS("free_blocks"), blocks);
add_assoc_zval_ex(return_value, XCACHE_STRS("free_blocks"), blocks);
#ifndef NDEBUG
assert(avail == vtable->avail(allocator));
#endif
@ -670,12 +670,12 @@ static void xc_fillentry_unlocked(xc_entry_type_t type, const xc_entry_t *entry,
ALLOC_INIT_ZVAL(ei);
array_init(ei);
add_assoc_long_ex(ei, ZEND_STRS("hits"), entry->hits);
add_assoc_long_ex(ei, ZEND_STRS("ctime"), entry->ctime);
add_assoc_long_ex(ei, ZEND_STRS("atime"), entry->atime);
add_assoc_long_ex(ei, ZEND_STRS("hvalue"), entryslotid);
add_assoc_long_ex(ei, XCACHE_STRS("hits"), entry->hits);
add_assoc_long_ex(ei, XCACHE_STRS("ctime"), entry->ctime);
add_assoc_long_ex(ei, XCACHE_STRS("atime"), entry->atime);
add_assoc_long_ex(ei, XCACHE_STRS("hvalue"), entryslotid);
if (del) {
add_assoc_long_ex(ei, ZEND_STRS("dtime"), entry->dtime);
add_assoc_long_ex(ei, XCACHE_STRS("dtime"), entry->dtime);
}
#ifdef IS_UNICODE
do {
@ -692,37 +692,37 @@ static void xc_fillentry_unlocked(xc_entry_type_t type, const xc_entry_t *entry,
assert(0);
}
zv->type = entry->name_type;
add_assoc_zval_ex(ei, ZEND_STRS("name"), zv);
add_assoc_zval_ex(ei, XCACHE_STRS("name"), zv);
} while (0);
#else
add_assoc_stringl_ex(ei, ZEND_STRS("name"), entry->name.str.val, entry->name.str.len, 1);
add_assoc_stringl_ex(ei, XCACHE_STRS("name"), entry->name.str.val, entry->name.str.len, 1);
#endif
switch (type) {
case XC_TYPE_PHP: {
xc_entry_php_t *entry_php = (xc_entry_php_t *) entry;
php = entry_php->php;
add_assoc_long_ex(ei, ZEND_STRS("size"), entry->size + php->size);
add_assoc_long_ex(ei, ZEND_STRS("refcount"), entry_php->refcount);
add_assoc_long_ex(ei, ZEND_STRS("phprefcount"), php->refcount);
add_assoc_long_ex(ei, ZEND_STRS("file_mtime"), entry_php->file_mtime);
add_assoc_long_ex(ei, ZEND_STRS("file_size"), entry_php->file_size);
add_assoc_long_ex(ei, ZEND_STRS("file_device"), entry_php->file_device);
add_assoc_long_ex(ei, ZEND_STRS("file_inode"), entry_php->file_inode);
add_assoc_long_ex(ei, XCACHE_STRS("size"), entry->size + php->size);
add_assoc_long_ex(ei, XCACHE_STRS("refcount"), entry_php->refcount);
add_assoc_long_ex(ei, XCACHE_STRS("phprefcount"), php->refcount);
add_assoc_long_ex(ei, XCACHE_STRS("file_mtime"), entry_php->file_mtime);
add_assoc_long_ex(ei, XCACHE_STRS("file_size"), entry_php->file_size);
add_assoc_long_ex(ei, XCACHE_STRS("file_device"), entry_php->file_device);
add_assoc_long_ex(ei, XCACHE_STRS("file_inode"), entry_php->file_inode);
#ifdef HAVE_XCACHE_CONSTANT
add_assoc_long_ex(ei, ZEND_STRS("constinfo_cnt"), php->constinfo_cnt);
add_assoc_long_ex(ei, XCACHE_STRS("constinfo_cnt"), php->constinfo_cnt);
#endif
add_assoc_long_ex(ei, ZEND_STRS("function_cnt"), php->funcinfo_cnt);
add_assoc_long_ex(ei, ZEND_STRS("class_cnt"), php->classinfo_cnt);
add_assoc_long_ex(ei, XCACHE_STRS("function_cnt"), php->funcinfo_cnt);
add_assoc_long_ex(ei, XCACHE_STRS("class_cnt"), php->classinfo_cnt);
#ifdef ZEND_ENGINE_2_1
add_assoc_long_ex(ei, ZEND_STRS("autoglobal_cnt"),php->autoglobal_cnt);
add_assoc_long_ex(ei, XCACHE_STRS("autoglobal_cnt"),php->autoglobal_cnt);
#endif
break;
}
case XC_TYPE_VAR:
add_assoc_long_ex(ei, ZEND_STRS("refcount"), 0); /* for BC only */
add_assoc_long_ex(ei, ZEND_STRS("size"), entry->size);
add_assoc_long_ex(ei, XCACHE_STRS("refcount"), 0); /* for BC only */
add_assoc_long_ex(ei, XCACHE_STRS("size"), entry->size);
break;
default:
@ -2554,8 +2554,8 @@ static inline zend_bool xc_var_has_prefix(const xc_entry_t *entry, zval *prefix,
/* module helper function */
static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */
{
zend_register_long_constant(ZEND_STRS("XC_TYPE_PHP"), XC_TYPE_PHP, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_long_constant(ZEND_STRS("XC_TYPE_VAR"), XC_TYPE_VAR, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_long_constant(XCACHE_STRS("XC_TYPE_PHP"), XC_TYPE_PHP, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_long_constant(XCACHE_STRS("XC_TYPE_VAR"), XC_TYPE_VAR, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
return SUCCESS;
}
/* }}} */

View File

@ -28,7 +28,7 @@ static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */
ALLOC_INIT_ZVAL(zv);
array_init(zv);
xc_dasm_zend_op_array(&dasm, zv, op_array TSRMLS_CC);
add_assoc_zval_ex(output, ZEND_STRS("op_array"), zv);
add_assoc_zval_ex(output, XCACHE_STRS("op_array"), zv);
buf = emalloc(bufsize);
@ -66,7 +66,7 @@ static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */
add_u_assoc_zval_ex(list, BUCKET_KEY_TYPE(b), ZSTR(buf), keyLength, zv);
}
add_assoc_zval_ex(output, ZEND_STRS("function_table"), list);
add_assoc_zval_ex(output, XCACHE_STRS("function_table"), list);
ALLOC_INIT_ZVAL(list);
array_init(list);
@ -102,7 +102,7 @@ static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */
add_u_assoc_zval_ex(list, BUCKET_KEY_TYPE(b), ZSTR(buf), keyLength, zv);
}
efree(buf);
add_assoc_zval_ex(output, ZEND_STRS("class_table"), list);
add_assoc_zval_ex(output, XCACHE_STRS("class_table"), list);
/*xc_apply_op_array(&cr, (apply_func_t) xc_redo_pass_two TSRMLS_CC);*/
xc_compile_result_free(&cr);

View File

@ -17,8 +17,8 @@ ifdef(`len', `
define(`m4_len', defn(`len'))
undefine(`len')
')
define(`ZEND_STRS', `($1), (sizeof($1))')
define(`ZEND_STRL', `($1), (sizeof($1) - 1)')
define(`XCACHE_STRS', `($1), (sizeof($1))')
define(`XCACHE_STRL', `($1), (sizeof($1) - 1)')
define(`DST', `dst->$1')
define(`SRC', `src->$1')
dnl ============
@ -94,9 +94,9 @@ define(`PROC_CLASS_ENTRY_P_EX', `
IFSTORE(`$1 = (zend_class_entry *) xc_get_class_num(processor, $2);')
IFRESTORE(`$1 = xc_get_class(processor, (zend_ulong) $2);')
#ifdef IS_UNICODE
IFDASM(`add_assoc_unicodel_ex(dst, ZEND_STRS("$3"), ZSTR_U($2->name), $2->name_length, 1);')
IFDASM(`add_assoc_unicodel_ex(dst, XCACHE_STRS("$3"), ZSTR_U($2->name), $2->name_length, 1);')
#else
IFDASM(`add_assoc_stringl_ex(dst, ZEND_STRS("$3"), (char *) $2->name, $2->name_length, 1);')
IFDASM(`add_assoc_stringl_ex(dst, XCACHE_STRS("$3"), (char *) $2->name, $2->name_length, 1);')
#endif
}
else {
@ -165,7 +165,7 @@ define(`SETZERO', `SETZERO_EX(`dst->$1')DONE(`$1')')
dnl }}}
dnl {{{ COPYNULL_EX(1:dst, 2:elm-name)
define(`COPYNULL_EX', `
IFDASM(`add_assoc_null_ex(dst, ZEND_STRS("$2"));')
IFDASM(`add_assoc_null_ex(dst, XCACHE_STRS("$2"));')
IFNOTMEMCPY(`IFCOPY(`$1 = NULL;')')
assert(patsubst($1, dst, src) == NULL);
')
@ -177,7 +177,7 @@ define(`COPYNULL', `
dnl }}}
dnl {{{ COPYZERO_EX(1:dst, 2:elm-name)
define(`COPYZERO_EX', `
IFDASM(`add_assoc_long_ex(dst, ZEND_STRS("$2"), 0);')
IFDASM(`add_assoc_long_ex(dst, XCACHE_STRS("$2"), 0);')
IFNOTMEMCPY(`IFCOPY(`$1 = 0;')')
assert(patsubst($1, dst, src) == 0);
')

View File

@ -6,8 +6,8 @@ define(`PROCESS_SCALAR', `dnl {{{ (1:elm, 2:format=%d, 3:type=)
')
IFDASM(`
ifelse(
`$3', `zend_bool', `add_assoc_bool_ex(dst, ZEND_STRS("$1"), SRC(`$1') ? 1 : 0);'
, `', `', `add_assoc_long_ex(dst, ZEND_STRS("$1"), SRC(`$1'));'
`$3', `zend_bool', `add_assoc_bool_ex(dst, XCACHE_STRS("$1"), SRC(`$1') ? 1 : 0);'
, `', `', `add_assoc_long_ex(dst, XCACHE_STRS("$1"), SRC(`$1'));'
)
')
DONE(`$1')
@ -106,7 +106,7 @@ define(`PROCESS_ARRAY', `dnl {{{ (1:count, 2:type, 3:elm, [4:real_type])
++LOOPCOUNTER;
}
add_assoc_zval_ex(dst, ZEND_STRS("$3"), arr);
add_assoc_zval_ex(dst, XCACHE_STRS("$3"), arr);
', `
dnl find count with NULL
ifelse(`$1', `', `

View File

@ -486,7 +486,7 @@ define(`UNION_znode_op', `dnl {{{
ALLOC_INIT_ZVAL(zv);
*zv = dasm->active_op_array_src->literals[src->$1.constant].constant;
zval_copy_ctor(zv);
add_assoc_zval_ex(dst, ZEND_STRS("$1.constant"), zv);
add_assoc_zval_ex(dst, XCACHE_STRS("$1.constant"), zv);
}
', `
IFCOPY(`

View File

@ -28,7 +28,7 @@ define(`PROC_STRING_N_EX', `
DSTPTR = NULL;
')')
IFDASM(`
add_assoc_null_ex(dst, ZEND_STRS("$4"));
add_assoc_null_ex(dst, XCACHE_STRS("$4"));
')
}
else {
@ -66,12 +66,12 @@ define(`PROC_STRING_N_EX', `
FIXPOINTER_EX(ifdef(`REALPTRTYPE', `REALPTRTYPE()', `PTRTYPE'), DSTPTR)
IFDASM(`
ifelse(STRTYPE,zstr_uchar, `
add_assoc_unicodel_ex(dst, ZEND_STRS("$4"), ZSTR_U($2), $3-1, 1);
add_assoc_unicodel_ex(dst, XCACHE_STRS("$4"), ZSTR_U($2), $3-1, 1);
', ` dnl else
ifelse(STRTYPE,zstr_char, `
add_assoc_stringl_ex(dst, ZEND_STRS("$4"), (char *) ZSTR_S($2), $3-1, 1);
add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) ZSTR_S($2), $3-1, 1);
', `
add_assoc_stringl_ex(dst, ZEND_STRS("$4"), (char *) $2, $3-1, 1);
add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) $2, $3-1, 1);
')
')
')

View File

@ -150,7 +150,7 @@ ifdef(`DASM_STRUCT_DIRECT', `', `
);
ifdef(`DASM_STRUCT_DIRECT', `', `
IFDASM(`
add_assoc_zval_ex(dst, ZEND_STRS("$4"), zv);
add_assoc_zval_ex(dst, XCACHE_STRS("$4"), zv);
} while (0);
')
')
@ -204,7 +204,7 @@ define(`STRUCT_ARRAY', `
FUNC_NAME (dasm, zv, &(SRC(`$4[LOOPCOUNTER]')) TSRMLS_CC);
add_next_index_zval(arr, zv);
}
add_assoc_zval_ex(dst, ZEND_STRS("$4"), arr);
add_assoc_zval_ex(dst, XCACHE_STRS("$4"), arr);
', `
dnl find count with NULL
ifelse(`$2', `', `

View File

@ -107,9 +107,9 @@ static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */
}
}
zend_register_long_constant(ZEND_STRS("XC_SIZEOF_TEMP_VARIABLE"), sizeof(temp_variable), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_stringl_constant(ZEND_STRS("XCACHE_VERSION"), ZEND_STRL(XCACHE_VERSION), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_stringl_constant(ZEND_STRS("XCACHE_MODULES"), ZEND_STRL(XCACHE_MODULES), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_long_constant(XCACHE_STRS("XC_SIZEOF_TEMP_VARIABLE"), sizeof(temp_variable), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_stringl_constant(XCACHE_STRS("XCACHE_VERSION"), XCACHE_STRL(XCACHE_VERSION), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
zend_register_stringl_constant(XCACHE_STRS("XCACHE_MODULES"), XCACHE_STRL(XCACHE_MODULES), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
return 0;
}
/* }}} */
@ -311,10 +311,10 @@ PHP_FUNCTION(xcache_get_opcode_spec)
opspec = xc_get_opcode_spec((zend_uchar) spec);
if (opspec) {
array_init(return_value);
add_assoc_long_ex(return_value, ZEND_STRS("ext"), opspec->ext);
add_assoc_long_ex(return_value, ZEND_STRS("op1"), opspec->op1);
add_assoc_long_ex(return_value, ZEND_STRS("op2"), opspec->op2);
add_assoc_long_ex(return_value, ZEND_STRS("res"), opspec->res);
add_assoc_long_ex(return_value, XCACHE_STRS("ext"), opspec->ext);
add_assoc_long_ex(return_value, XCACHE_STRS("op1"), opspec->op1);
add_assoc_long_ex(return_value, XCACHE_STRS("op2"), opspec->op2);
add_assoc_long_ex(return_value, XCACHE_STRS("res"), opspec->res);
return;
}
}

View File

@ -1,6 +1,9 @@
#include "xcache.h"
#include "xc_compatibility.h"
#define XCACHE_STRS(str) (str), sizeof(str)
#define XCACHE_STRL(str) (str), (sizeof(str) - 1)
typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC);
typedef struct _xc_compilererror_t {