Browse Source

adds ptrmove

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1440 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
9563ceb3c1
  1. 94
      processor/hashtable.m4
  2. 2
      processor/head.m4
  3. 42
      processor/main.m4
  4. 5
      processor/process.m4
  5. 97
      processor/processor.m4
  6. 2
      processor/string.m4
  7. 42
      processor/struct.m4

94
processor/hashtable.m4

@ -1,4 +1,4 @@
dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname] [, 4:check_function])
dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname])
define(`DEF_HASH_TABLE_FUNC', `
DEF_STRUCT_P_FUNC(`HashTable', `$1', `
pushdefFUNC_NAME(`$2', `$3')
@ -10,27 +10,8 @@ define(`DEF_HASH_TABLE_FUNC', `
char *buf = emalloc(bufsize);
int keysize;
#if defined(HARDENING_PATCH_HASH_PROTECT) && HARDENING_PATCH_HASH_PROTECT
DONE(canary)
#endif
DONE(nTableSize)
DONE(nTableMask)
DONE(nNumOfElements)
DONE(nNextFreeElement)
DONE(pInternalPointer)
DONE(pListHead)
DONE(pListTail)
DONE(arBuckets)
DONE(pDestructor)
DONE(persistent)
DONE(nApplyCount)
DONE(bApplyProtection)
#if ZEND_DEBUG
DONE(inconsistent)
#endif
#ifdef IS_UNICODE
DONE(unicode)
#endif
define(`AUTOCHECK_SKIP')
IFAUTOCHECK(`xc_autocheck_skip = 1;')
DISABLECHECK(`
for (srcBucket = SRC(`pListHead'); srcBucket != NULL; srcBucket = srcBucket->pListNext) {
@ -64,10 +45,10 @@ define(`DEF_HASH_TABLE_FUNC', `
')
efree(buf);
', `
', ` dnl IFDASM else
dnl }}}
Bucket *srcBucket;
IFCOPY(`Bucket *pnew = NULL, *prev = NULL;')
IFCOPY(`Bucket *dstBucket = NULL, *prev = NULL;')
zend_bool first = 1;
dnl only used for copy
IFCOPY(`uint n;')
@ -91,39 +72,30 @@ define(`DEF_HASH_TABLE_FUNC', `
CALLOC(`DST(`arBuckets')', Bucket*, SRC(`nTableSize'))
DONE(arBuckets)
DISABLECHECK(`
for (srcBucket = SRC(`pListHead'); srcBucket != NULL; srcBucket = srcBucket->pListNext) {
ifelse($4, `', `', `
pushdef(`BUCKET', `srcBucket')
if ($4 == ZEND_HASH_APPLY_REMOVE) {
IFCOPY(`DST(`nNumOfElements') --;')
continue;
}
popdef(`BUCKET')
')
for (srcBucket = SRCPTR(`Bucket', `pListHead'); srcBucket != NULL; srcBucket = SRCPTR_EX(`Bucket', `srcBucket->pListNext')) {
IFPTRMOVE(`Bucket *dstBucket = srcBucket;')
IFCALCCOPY(`bucketsize = BUCKET_SIZE(srcBucket);')
ALLOC(pnew, char, bucketsize, , Bucket)
ALLOC(dstBucket, char, bucketsize, , Bucket)
IFCOPY(`
#ifdef ZEND_ENGINE_2_4
memcpy(pnew, srcBucket, BUCKET_HEAD_SIZE(Bucket));
memcpy(dstBucket, srcBucket, BUCKET_HEAD_SIZE(Bucket));
if (BUCKET_KEY_SIZE(srcBucket)) {
memcpy((char *) (pnew + 1), srcBucket->arKey, BUCKET_KEY_SIZE(srcBucket));
pnew->arKey = (const char *) (pnew + 1);
memcpy((char *) (dstBucket + 1), srcBucket->arKey, BUCKET_KEY_SIZE(srcBucket));
dstBucket->arKey = (const char *) (dstBucket + 1);
}
else {
pnew->arKey = NULL;
dstBucket->arKey = NULL;
}
#else
memcpy(pnew, srcBucket, bucketsize);
memcpy(dstBucket, srcBucket, bucketsize);
#endif
n = srcBucket->h & SRC(`nTableMask');
/* pnew into hash node chain */
pnew->pLast = NULL;
pnew->pNext = DST(`arBuckets[n]');
if (pnew->pNext) {
pnew->pNext->pLast = pnew;
/* dstBucket into hash node chain */
dstBucket->pLast = NULL;
dstBucket->pNext = DST(`arBuckets[n]');
if (dstBucket->pNext) {
dstBucket->pNext->pLast = dstBucket;
}
DST(`arBuckets[n]') = pnew;
')
IFDPRINT(`
INDENT()
@ -132,32 +104,36 @@ define(`DEF_HASH_TABLE_FUNC', `
fprintf(stderr, "\" %d:h=%lu ", BUCKET_KEY_SIZE(srcBucket), srcBucket->h);
')
if (sizeof(void *) == sizeof($2)) {
IFCOPY(`pnew->pData = &pnew->pDataPtr;')
dnl no alloc
STRUCT_P_EX(`$2', pnew->pData, (($2*)srcBucket->pData), `', `$3', ` ')
IFCOPY(`dstBucket->pData = &dstBucket->pDataPtr;')
dnl $6 = `' to skip alloc
STRUCT_P_EX(`$2', dstBucket->pData, (($2*)srcBucket->pData), `', `$3', ` ')
FIXPOINTER_EX(`$2', dstBucket->pData, srcBucket->pData)
}
else {
STRUCT_P_EX(`$2', pnew->pData, (($2*)srcBucket->pData), `', `$3')
IFCOPY(`pnew->pDataPtr = NULL;')
STRUCT_P_EX(`$2', dstBucket->pData, (($2*)srcBucket->pData), `', `$3')
IFCOPY(`dstBucket->pDataPtr = NULL;')
}
if (first) {
IFCOPY(`DST(`pListHead') = pnew;')
IFCOPY(`DST(`pListHead') = dstBucket;')
first = 0;
}
IFCOPY(`
/* flat link */
pnew->pListLast = prev;
pnew->pListNext = NULL;
dstBucket->pListLast = prev;
dstBucket->pListNext = NULL;
if (prev) {
prev->pListNext = pnew;
prev->pListNext = dstBucket;
}
prev = pnew;
prev = dstBucket;
')
FIXPOINTER_EX(`Bucket', `dstBucket', `srcBucket')
IFCOPY(`
DST(`arBuckets[n]') = dstBucket;
')
}
')
dnl TODO: fix pointer on arBuckets[n]
') dnl DISABLECHECK
FIXPOINTER(Bucket *, arBuckets)
#ifdef ZEND_ENGINE_2_4
}
@ -165,7 +141,7 @@ define(`DEF_HASH_TABLE_FUNC', `
DONE(arBuckets)
}
#endif
IFCOPY(`DST(`pListTail') = pnew;') DONE(pListTail)
IFCOPY(`DST(`pListTail') = dstBucket;') DONE(pListTail)
IFCOPY(`DST(`pDestructor') = SRC(`pDestructor');') DONE(pDestructor)
PROCESS(zend_bool, persistent)
#ifdef IS_UNICODE

2
processor/head.m4

@ -114,6 +114,8 @@ struct _xc_processor_t {
IFAUTOCHECK(xc_stack_t allocsizes;)
};
/* }}} */
/* export: typedef struct _xc_ptrmove_t { ptrdiff_t src; ptrdiff_t ptrdiff; } xc_ptrmove_t; :export {{{ */
/* }}} */
/* export: typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t; :export {{{ */
/* }}} */
/* {{{ memsetptr */

42
processor/main.m4

@ -24,6 +24,14 @@ define(`SRC', `src->$1')
dnl ============
define(`INDENT', `xc_dprint_indent(indent);')
dnl }}}
dnl {{{ SRCPTR(1:type, 2:elm)
define(`SRCPTR', `SRCPTR_EX(`$1', `SRC(`$2')')')
define(`SRCPTR_EX', `IFPTRMOVE(`(($1 *) (((char *) $2) + ptrmove->src))', `$2')')
dnl }}}
dnl {{{ SRCPTR(1:type, 2:elm)
define(`DSTPTR', `DSTPTR_EX(`$1', `DST(`$2')')')
define(`DSTPTR_EX', `SRCPTR_EX($@)')
dnl }}}
dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2)
define(`ALLOC', `
pushdef(`COUNT', `ifelse(`$3', `', `1', `$3')')
@ -122,15 +130,14 @@ dnl }}}
dnl {{{ EXPORT
define(`EXPORT', `define(`EXPORT_$1')')
dnl }}}
dnl {{{ FIXPOINTER
define(`FIXPOINTER', `FIXPOINTER_EX(`$1', `DST(`$2')')')
define(`FIXPOINTER_EX', `IFSTORE(`
$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (void *)$2);
')')
define(`UNFIXPOINTER', `UNFIXPOINTER_EX(`$1', `DST(`$2')')')
define(`UNFIXPOINTER_EX', `IFSTORE(`
$2 = ($1 *) processor->shm->handlers->to_readwrite(processor->shm, (void *)$2);
')')
dnl {{{ FIXPOINTER(1:type, 2:ele)
define(`FIXPOINTER', `FIXPOINTER_EX(`$1', `DST(`$2')', `SRCPTR(`$1', `$2')')')
dnl }}}
dnl {{{ FIXPOINTER_EX(1:type, 2:dst, 3:src)
define(`FIXPOINTER_EX', `
IFSTORE(`$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (void *)$2);')
IFPTRMOVE(`$2 = ($1 *) (((char *) $3) + ptrmove->ptrdiff);')
')
dnl }}}
dnl {{{ IFNOTMEMCPY
define(`IFNOTMEMCPY', `ifdef(`USEMEMCPY', `', `$1')')
@ -138,7 +145,7 @@ dnl }}}
dnl {{{ COPY
define(`COPY', `IFNOTMEMCPY(`IFCOPY(`DST(`$1') = SRC(`$1');')')DONE(`$1')')
dnl }}}
dnl {{{ COPY_N_EX
dnl {{{ COPY_N_EX(1:count, 2:type, 3:dst)
define(`COPY_N_EX', `
ALLOC(`DST(`$3')', `$2', `SRC(`$1')')
IFCOPY(`
@ -146,26 +153,13 @@ define(`COPY_N_EX', `
')
')
dnl }}}
dnl {{{ COPY_N
define(`COPY_N', `COPY_N_EX(`$1',`$2')DONE(`$1')')
dnl }}}
dnl {{{ COPYPOINTER
define(`COPYPOINTER', `COPY(`$1')')
dnl }}}
dnl {{{ COPYARRAY_EX
define(`COPYARRAY_EX', `IFNOTMEMCPY(`IFCOPY(`memcpy(DST(`$1'), SRC(`$1'), sizeof(DST(`$1')));')')')
dnl }}}
dnl {{{ COPYARRAY
define(`COPYARRAY', `COPYARRAY_EX(`$1',`$2')DONE(`$1')')
dnl }}}
dnl {{{ SETNULL_EX
define(`SETNULL_EX', `IFCOPY(`$1 = NULL;')')
define(`SETNULL', `SETNULL_EX(`DST(`$1')')DONE(`$1')')
dnl }}}
dnl {{{ SETZERO_EX
define(`SETZERO_EX', `IFCOPY(`$1 = 0;')')
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, XCACHE_STRS("$2"));')
@ -242,6 +236,7 @@ define(`IFCALC', `ifelse(PROCESSOR_TYPE, `calc', `$1', `$2')')
define(`IFSTORE', `ifelse(PROCESSOR_TYPE, `store', `$1', `$2')')
define(`IFCALCSTORE', `IFSTORE(`$1', `IFCALC(`$1', `$2')')')
define(`IFRESTORE', `ifelse(PROCESSOR_TYPE, `restore', `$1', `$2')')
define(`IFPTRMOVE', `ifelse(PROCESSOR_TYPE, `ptrmove', `$1', `$2')')
define(`IFCOPY', `IFSTORE(`$1', `IFRESTORE(`$1', `$2')')')
define(`IFCALCCOPY', `IFCALC(`$1', `IFCOPY(`$1', `$2')')')
define(`IFDPRINT', `ifelse(PROCESSOR_TYPE, `dprint', `$1', `$2')')
@ -269,6 +264,7 @@ include(srcdir`/processor/head.m4')
REDEF(`PROCESSOR_TYPE', `calc') include(srcdir`/processor/processor.m4')
REDEF(`PROCESSOR_TYPE', `store') include(srcdir`/processor/processor.m4')
REDEF(`PROCESSOR_TYPE', `restore') include(srcdir`/processor/processor.m4')
REDEF(`PROCESSOR_TYPE', `ptrmove') include(srcdir`/processor/processor.m4')
#ifdef HAVE_XCACHE_DPRINT
REDEF(`PROCESSOR_TYPE', `dprint') include(srcdir`/processor/processor.m4')

5
processor/process.m4

@ -13,6 +13,9 @@ define(`PROCESS_SCALAR', `dnl {{{ (1:elm, 2:format=%d, 3:type=)
DONE(`$1')
')
dnl }}}
dnl {{{ PROCESS_CTEXTPOINTER
define(`PROCESS_CTEXTPOINTER', `COPY(`$1')')
dnl }}}
define(`PROCESS_xc_ztstring', `dnl {{{ (1:elm)
pushdef(`REALPTRTYPE', `zend_class_entry')
PROC_STRING(`$1')
@ -71,7 +74,7 @@ define(`PROCESS', `dnl PROCESS(1:type, 2:elm)
, `$1', `xc_zval_type_t', `PROCESS_xc_zval_type_t(`$2')'
, `$1', `xc_op_type', `PROCESS_xc_op_type(`$2')'
, `$1', `xc_opcode', `PROCESS_xc_opcode(`$2')'
, `$1', `opcode_handler_t', `/* is copying enough? */COPY(`$2')'
, `$1', `opcode_handler_t', `/* is copying enough? */PROCESS_CTEXTPOINTER(`$2')'
, `$1', `xc_md5sum_t', `COPY(`$2')'
, `', `', `m4_errprint(`AUTOCHECK ERROR: Unknown type "$1"')define(`EXIT_PENDING', 1)'
)

97
processor/processor.m4

@ -193,7 +193,7 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
zval_ptr pzv = (zval_ptr)-1;
', `
zval_ptr pzv = dst[0];
FIXPOINTER_EX(zval, pzv)
FIXPOINTER_EX(zval, pzv, dst[0])
')
if (zend_hash_add(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) {
/* first add, go on */
@ -209,7 +209,7 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
')
IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) src[0]);')
STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
FIXPOINTER_EX(zval, dst[0])
FIXPOINTER_EX(zval, dst[0], src[0])
} while (0);
')
DONE_SIZE(sizeof(zval_ptr))
@ -335,7 +335,7 @@ DEF_STRUCT_P_FUNC(`zend_trait_alias_ptr', , `dnl {{{
', `
ALLOC(dst[0], zend_trait_alias)
STRUCT_P_EX(zend_trait_alias, dst[0], src[0], `[0]', `', ` ')
FIXPOINTER_EX(zend_trait_alias, dst[0])
FIXPOINTER_EX(zend_trait_alias, dst[0], src[0])
')
DONE_SIZE(sizeof(zend_trait_alias))
')
@ -348,7 +348,7 @@ DEF_STRUCT_P_FUNC(`zend_trait_precedence_ptr', , `dnl {{{
', `
ALLOC(dst[0], zend_trait_precedence)
STRUCT_P_EX(zend_trait_precedence, dst[0], src[0], `[0]', `', ` ')
FIXPOINTER_EX(zend_trait_precedence, dst[0])
FIXPOINTER_EX(zend_trait_precedence, dst[0], src[0])
')
DONE_SIZE(sizeof(zend_trait_precedence))
')
@ -365,7 +365,7 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
IFRESTORE(`
#ifndef ZEND_ENGINE_2
/* just copy parent and resolve on install_class */
COPY(parent)
COPYPOINTER(parent)
#else
PROC_CLASS_ENTRY_P(parent)
#endif
@ -457,46 +457,46 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
/* # NOT DONE */
# ifdef ZEND_ENGINE_2_1
COPY(serialize_func)
COPY(unserialize_func)
PROCESS_CTEXTPOINTER(serialize_func)
PROCESS_CTEXTPOINTER(unserialize_func)
# endif
COPY(iterator_funcs)
COPY(create_object)
COPY(get_iterator)
COPY(interface_gets_implemented)
PROCESS_CTEXTPOINTER(iterator_funcs)
PROCESS_CTEXTPOINTER(create_object)
PROCESS_CTEXTPOINTER(get_iterator)
PROCESS_CTEXTPOINTER(interface_gets_implemented)
# ifdef ZEND_ENGINE_2_3
COPY(get_static_method)
PROCESS_CTEXTPOINTER(get_static_method)
# endif
# ifdef ZEND_ENGINE_2_1
COPY(serialize)
COPY(unserialize)
PROCESS_CTEXTPOINTER(serialize)
PROCESS_CTEXTPOINTER(unserialize)
# endif
/* deal with it inside xc_fix_method */
SETNULL(constructor)
COPY(destructor)
COPY(clone)
COPY(__get)
COPY(__set)
PROCESS_CTEXTPOINTER(destructor)
PROCESS_CTEXTPOINTER(clone)
PROCESS_CTEXTPOINTER(__get)
PROCESS_CTEXTPOINTER(__set)
/* should be >5.1 */
# ifdef ZEND_ENGINE_2_1
COPY(__unset)
COPY(__isset)
PROCESS_CTEXTPOINTER(__unset)
PROCESS_CTEXTPOINTER(__isset)
# if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
COPY(__tostring)
PROCESS_CTEXTPOINTER(__tostring)
# endif
# endif
COPY(__call)
PROCESS_CTEXTPOINTER(__call)
# ifdef ZEND_CALLSTATIC_FUNC_NAME
COPY(__callstatic)
PROCESS_CTEXTPOINTER(__callstatic)
# endif
# ifndef ZEND_ENGINE_2_4
/* # NOT DONE */
COPY(module)
PROCESS_CTEXTPOINTER(module)
# endif
#else /* ZEND_ENGINE_2 */
COPY(handle_function_call)
COPY(handle_property_get)
COPY(handle_property_set)
PROCESS_CTEXTPOINTER(handle_function_call)
PROCESS_CTEXTPOINTER(handle_property_get)
PROCESS_CTEXTPOINTER(handle_property_set)
#endif
dnl must do after SETNULL(constructor) and dst->parent
STRUCT(HashTable, function_table, HashTable_zend_function)
@ -673,7 +673,7 @@ DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
FIXPOINTER_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr')
FIXPOINTER_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr', `Z_OP(SRC(`op1')).jmp_addr')
break;
case ZEND_JMPZ:
@ -691,7 +691,7 @@ DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
FIXPOINTER_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr')
FIXPOINTER_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr', `Z_OP(SRC(`op2')).jmp_addr')
break;
default:
@ -883,9 +883,10 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
dnl SETNULL(u_twin)
#endif
IFSTORE(`pushdef(`FIXPOINTER')')
STRUCT_P(zend_uint, refcount)
IFSTORE(`
UNFIXPOINTER(zend_uint, refcount)
popdef(`FIXPOINTER')
DST(`refcount[0]') = 1;
FIXPOINTER(zend_uint, refcount)
')
@ -943,7 +944,7 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
#ifndef ZEND_ENGINE_2_4
COPY(start_op)
COPYPOINTER(start_op)
PROCESS(int, backpatch_count)
#endif
#ifdef ZEND_ENGINE_2_3
@ -961,7 +962,7 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
#ifdef IS_UNICODE
IFRESTORE(`
COPY(script_encoding)
COPYPOINTER(script_encoding)
', `
PROC_STRING(script_encoding)
')
@ -1050,7 +1051,7 @@ DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
#ifdef IS_UNICODE
PROCESS(zend_uchar, type)
#endif
IFRESTORE(`COPY(key)', `
IFRESTORE(`COPYPOINTER(key)', `
PROC_ZSTRING_N(type, key, key_size)
')
PROCESS(ulong, h)
@ -1080,11 +1081,11 @@ DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
#ifdef IS_UNICODE
PROCESS(zend_uchar, type)
#endif
IFRESTORE(`COPY(key)', `
IFRESTORE(`COPYPOINTER(key)', `
PROC_ZSTRING_N(type, key, key_size)
')
PROCESS(ulong, h)
IFRESTORE(`COPY(op_array_info)', `
IFRESTORE(`COPYPOINTER(op_array_info)', `
STRUCT(xc_op_array_info_t, op_array_info)
')
IFRESTORE(`
@ -1099,12 +1100,12 @@ DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
#ifdef IS_UNICODE
PROCESS(zend_uchar, type)
#endif
IFRESTORE(`COPY(key)', `
IFRESTORE(`COPYPOINTER(key)', `
PROC_ZSTRING_N(type, key, key_size)
')
PROCESS(ulong, h)
PROCESS(zend_uint, methodinfo_cnt)
IFRESTORE(`COPY(methodinfos)', `
IFRESTORE(`COPYPOINTER(methodinfos)', `
STRUCT_ARRAY(zend_uint, methodinfo_cnt, xc_op_array_info_t, methodinfos)
')
IFRESTORE(`
@ -1128,7 +1129,7 @@ DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
#ifdef IS_UNICODE
PROCESS(zend_uchar, type)
#endif
IFRESTORE(`COPY(key)', `
IFRESTORE(`COPYPOINTER(key)', `
PROC_ZSTRING_L(type, key, key_len)
')
PROCESS(ulong, h)
@ -1162,7 +1163,7 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
PROCESS(zend_ulong, hits)
PROCESS(size_t, size)
IFRESTORE(`COPY(op_array_info)', `
IFRESTORE(`COPYPOINTER(op_array_info)', `
STRUCT(xc_op_array_info_t, op_array_info)
')
IFRESTORE(`
@ -1184,7 +1185,7 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
#ifdef ZEND_ENGINE_2_1
PROCESS(zend_uint, autoglobal_cnt)
IFRESTORE(`
COPY(autoglobals)
COPYPOINTER(autoglobals)
', `
STRUCT_ARRAY(zend_uint, autoglobal_cnt, xc_autoglobal_t, autoglobals)
')
@ -1192,7 +1193,7 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
#ifdef XCACHE_ERROR_CACHING
PROCESS(zend_uint, compilererror_cnt)
IFRESTORE(`
COPY(compilererrors)
COPYPOINTER(compilererrors)
', `
STRUCT_ARRAY(zend_uint, compilererror_cnt, xc_compilererror_t, compilererrors)
')
@ -1220,12 +1221,12 @@ DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
STRUCT(xc_entry_t, entry)
DISABLECHECK(`
PROCESS(int, entry.name.str.len)
IFRESTORE(`COPY(entry.name.str.val)', `
IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
PROC_STRING_L(entry.name.str.val, entry.name.str.len)
')
')
IFCALCCOPY(`COPY(php)', `STRUCT_P(xc_entry_data_php_t, php)')
IFCALCCOPY(`COPYPOINTER(php)', `STRUCT_P(xc_entry_data_php_t, php)')
IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
PROCESS(time_t, file_mtime)
@ -1234,14 +1235,14 @@ DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
PROCESS(size_t, file_inode)
PROCESS(size_t, filepath_len)
IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
IFRESTORE(`COPYPOINTER(filepath)', `PROC_STRING_L(filepath, filepath_len)')
PROCESS(size_t, dirpath_len)
IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
IFRESTORE(`COPYPOINTER(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
#ifdef IS_UNICODE
PROCESS(int, ufilepath_len)
IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
IFRESTORE(`COPYPOINTER(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
PROCESS(int, udirpath_len)
IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
IFRESTORE(`COPYPOINTER(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
#endif
')
dnl }}}
@ -1263,7 +1264,7 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
#else
PROCESS(int, entry.name.str.len)
#endif
IFRESTORE(`COPY(entry.name.str.val)', `
IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
#ifdef IS_UNICODE
PROC_ZSTRING_L(name_type, entry.name.uni.val, entry.name.uni.len)
#else

2
processor/string.m4

@ -63,7 +63,7 @@ define(`PROC_STRING_N_EX', `
IFRESTORE(`
DSTPTR = ifdef(`REALPTRTYPE', `(REALPTRTYPE() *)') STRDUP() (SRCPTR, ($3) - 1);
')
FIXPOINTER_EX(ifdef(`REALPTRTYPE', `REALPTRTYPE()', `PTRTYPE'), DSTPTR)
FIXPOINTER_EX(ifdef(`REALPTRTYPE', `REALPTRTYPE()', `PTRTYPE'), DSTPTR, SRCPTR)
IFDASM(`
ifelse(STRTYPE,zstr_uchar, `
add_assoc_unicodel_ex(dst, XCACHE_STRS("$4"), ZSTR_U($2), $3-1, 1);

42
processor/struct.m4

@ -11,6 +11,7 @@ define(`DECL_STRUCT_P_FUNC', `translit(
IFCALC( `xc_processor_t *processor, const $1 * const src')
IFSTORE( `xc_processor_t *processor, $1 *dst, const $1 * const src')
IFRESTORE(`xc_processor_t *processor, $1 *dst, const $1 * const src')
IFPTRMOVE(`const xc_ptrmove_t *ptrmove, $1 * const dst, const $1 * const src')
IFDASM( `xc_dasm_t *dasm, zval *dst, const $1 * const src')
TSRMLS_DC
)ifelse(`$3', `', `;')
@ -58,26 +59,25 @@ DECL_STRUCT_P_FUNC(`$1', `$2', 1)
/* }}} */
IFRESTORE(`assert(xc_is_shm(src));')
IFCALCSTORE(`assert(!xc_is_shm(src));')
do {
')
ifdef(`SIZEOF_$1', , `m4_errprint(`AUTOCHECK WARN: $1: missing structinfo, dont panic')')
ifdef(`USEMEMCPY', `IFCOPY(`
memcpy(dst, src, sizeof($1));
do {
')')
IFDPRINT(`
fprintf(stderr, "%s", "{\n");
indent ++;
{
')
$3`'
{
$3`'
}
IFDPRINT(`
}
indent --;
INDENT()fprintf(stderr, "}\n");
')
IFAUTOCHECK(`
/* {{{ autocheck */
if (!xc_autocheck_skip) {
@ -104,22 +104,19 @@ DECL_STRUCT_P_FUNC(`$1', `$2', 1)
zend_hash_destroy(&xc_autocheck_done_names);
/* }}} */
')
ifdef(`ELEMENTSOF_$1', `
pushdef(`ELEMENTS_UNDONE', LIST_DIFF(defn(`ELEMENTSOF_$1'), defn(`ELEMENTS_DONE')))
ifelse(defn(`ELEMENTS_UNDONE'), , `m4_errprint(`AUTOCHECK INFO: $1: processor looks good')', `
m4_errprint(`AUTOCHECK ERROR: ====' PROCESSOR_TYPE `$1 =================')
m4_errprint(`AUTOCHECK expected:' defn(`ELEMENTSOF_$1'))
m4_errprint(`AUTOCHECK missing :' defn(`ELEMENTS_UNDONE'))
define(`EXIT_PENDING', 1)
ifdef(`AUTOCHECK_SKIP', `undefine(`AUTOCHECK_SKIP')', `
ifdef(`ELEMENTSOF_$1', `
pushdef(`ELEMENTS_UNDONE', LIST_DIFF(defn(`ELEMENTSOF_$1'), defn(`ELEMENTS_DONE')))
ifelse(defn(`ELEMENTS_UNDONE'), , `m4_errprint(`AUTOCHECK INFO: $1: processor looks good')', `
m4_errprint(`AUTOCHECK ERROR: ====' PROCESSOR_TYPE `$1 =================')
m4_errprint(`AUTOCHECK expected:' defn(`ELEMENTSOF_$1'))
m4_errprint(`AUTOCHECK missing :' defn(`ELEMENTS_UNDONE'))
define(`EXIT_PENDING', 1)
')
popdef(`ELEMENTS_UNDONE')
')
popdef(`ELEMENTS_UNDONE')
')
ifdef(`USEMEMCPY', `IFCOPY(`
} while (0);
')')
IFAUTOCHECK(`
} while (0);
')
popdef(`ELEMENTS_DONE')
}
/* }`}'} */
@ -145,6 +142,11 @@ ifdef(`DASM_STRUCT_DIRECT', `', `
IFCALC( `processor, $6 $3')
IFSTORE( `processor, $6 $2, $6 $3')
IFRESTORE(`processor, $6 $2, $6 $3')
IFPTRMOVE(`
ptrmove
, ifelse(`$6', `', `DSTPTR_EX(`$1', `$2')', `$6 $2')
, ifelse(`$6', `', `SRCPTR_EX(`$1', `$3')', `$6 $3')
')
IFDASM( `dasm, ifdef(`DASM_STRUCT_DIRECT', `dst', `zv'), $6 $3')
TSRMLS_CC
);
@ -155,7 +157,7 @@ ifdef(`DASM_STRUCT_DIRECT', `', `
')
')
popdef(`FUNC_NAME')
ifelse(`$6', , `FIXPOINTER_EX(`$1', `$2')')
ifelse(`$6', , `FIXPOINTER_EX(`$1', `$2', `$3')')
')
dnl }}}
dnl {{{ STRUCT_P(1:type, 2:elm, 3:name=type)

Loading…
Cancel
Save