update relocate
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1446 c26eb9a1-5813-0410-bd6c-c2e55f420ca7master
parent
417ef5b280
commit
6413478cd7
|
@ -178,12 +178,10 @@ static xc_entry_data_php_t *xc_php_store_unlocked(xc_cache_t *cache, xc_entry_da
|
|||
stored_php = xc_processor_store_xc_entry_data_php_t(cache->shm, cache->allocator, php TSRMLS_CC);
|
||||
#if 1
|
||||
{
|
||||
char *p = malloc(stored_php->size);
|
||||
fprintf(stderr, "%d\n", stored_php->size);
|
||||
xc_entry_data_php_t *p = malloc(stored_php->size);
|
||||
fprintf(stderr, "%lu\n", stored_php->size);
|
||||
memcpy(p, stored_php, stored_php->size);
|
||||
/*
|
||||
xc_processor_relocate_xc_entry_data_php_t(p, p, 0, stored_php TSRMLS_CC);
|
||||
*/
|
||||
xc_processor_relocate_xc_entry_data_php_t(p, stored_php, p TSRMLS_CC);
|
||||
}
|
||||
#endif
|
||||
if (stored_php) {
|
||||
|
|
|
@ -136,13 +136,27 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_zval(zval *dst, const zval *src, z
|
|||
}
|
||||
dnl }}}
|
||||
define(`DEFINE_RELOCATE_API', `
|
||||
EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *dst, char *old_start, char *new_start TSRMLS_DC)') dnl {{{
|
||||
EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *src, $1 *old_start, $1 *new_start TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
xc_relocate_t relocate;
|
||||
relocate.dst = dst;
|
||||
relocate.old_start = old_start;
|
||||
relocate.new_start = new_start;
|
||||
xc_relocate_$1(&relocate, dst TSRMLS_CC);
|
||||
/*
|
||||
$1 *xc_addressof(offset) {
|
||||
return (char *) offset + (ptrdiff_t) old_start;
|
||||
}
|
||||
*/
|
||||
ptrdiff_t ptrdiff = /* offset + */ (ptrdiff_t) old_start;
|
||||
|
||||
/*
|
||||
ptrdiff_t *xc_offsetof(offset) {
|
||||
return (char *) xc_addressof(offset) - src;
|
||||
}
|
||||
|
||||
$1 *xc_newoffset(offset) {
|
||||
return new_start + xc_offsetof(offset);
|
||||
}
|
||||
*/
|
||||
ptrdiff_t relocatediff = new_start + (/* offset + */ ptrdiff - (ptrdiff_t) src);
|
||||
|
||||
xc_relocate_$1(src, ptrdiff, relocatediff TSRMLS_CC);
|
||||
}
|
||||
dnl }}}
|
||||
')
|
||||
|
|
|
@ -104,7 +104,8 @@ define(`DEF_HASH_TABLE_FUNC', `
|
|||
')
|
||||
if (sizeof(void *) == sizeof($2)) {
|
||||
IFCOPY(`dstBucket->pData = &dstBucket->pDataPtr;')
|
||||
dnl $6 = `' to skip alloc
|
||||
IFRELOCATE(`srcBucket->pData = &srcBucket->pDataPtr;')
|
||||
dnl $6 = ` ' to skip alloc, skip pointer fix
|
||||
STRUCT_P_EX(`$2', dstBucket->pData, (($2*)srcBucket->pData), `', `$3', ` ')
|
||||
FIXPOINTER_EX(`$2', dstBucket->pData)
|
||||
}
|
||||
|
|
|
@ -110,12 +110,6 @@ typedef struct _xc_processor_t {
|
|||
IFAUTOCHECK(xc_stack_t allocsizes;)
|
||||
} xc_processor_t;
|
||||
dnl }}}
|
||||
typedef struct _xc_relocate_t { /* {{{ */
|
||||
ptrdiff_t dst;
|
||||
char *old_start;
|
||||
char *new_start;
|
||||
} xc_relocate_t;
|
||||
/* }}} */
|
||||
EXPORT(`typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t;')
|
||||
/* {{{ memsetptr */
|
||||
IFAUTOCHECK(`dnl
|
||||
|
|
|
@ -25,7 +25,7 @@ dnl ============
|
|||
define(`INDENT', `xc_dprint_indent(indent);')
|
||||
dnl }}}
|
||||
dnl {{{ SRCPTR_EX(1:type, 2:elm)
|
||||
define(`SRCPTR_EX', `IFRELOCATE(`(($1 *) (((char *) $2) + 1))', `$2')')
|
||||
define(`SRCPTR_EX', `IFRELOCATE(`(($1 *) (((char *) $2) + ptrdiff))', `$2')')
|
||||
dnl }}}
|
||||
dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2)
|
||||
define(`ALLOC', `
|
||||
|
@ -138,7 +138,11 @@ dnl }}}
|
|||
dnl {{{ FIXPOINTER_EX(1:type, 2:dst)
|
||||
define(`FIXPOINTER_EX', `
|
||||
IFSTORE(`$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (void *)$2);')
|
||||
IFRELOCATE(`patsubst($2, `dst', `src') = ($1 *) (((char *) patsubst($2, `dst', `src')) + 1);')
|
||||
IFRELOCATE(`
|
||||
pushdef(`relocatee', `patsubst($2, `dst', `src')')
|
||||
relocatee = ($1 *) (((char *) relocatee) + relocatediff);
|
||||
popdef(`relocatee')
|
||||
')
|
||||
')
|
||||
dnl }}}
|
||||
dnl {{{ IFNOTMEMCPY
|
||||
|
|
|
@ -14,7 +14,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')
|
||||
IFRELOCATE(`const xc_relocate_t *relocate, $1 *const src')
|
||||
IFRELOCATE(`$1 *const src, ptrdiff_t ptrdiff, ptrdiff_t relocatediff')
|
||||
IFDASM(`xc_dasm_t *dasm, zval *dst, const $1 * const src')
|
||||
TSRMLS_DC
|
||||
)ifelse(`$3', `', `;')
|
||||
|
@ -148,8 +148,9 @@ ifdef(`DASM_STRUCT_DIRECT', `', `
|
|||
IFSTORE( `processor, $6 $2, $6 $3')
|
||||
IFRESTORE(`processor, $6 $2, $6 $3')
|
||||
IFRELOCATE(`
|
||||
relocate
|
||||
, ifelse(`$6', `', `SRCPTR_EX(`$1', `$3')', `$6 $3')
|
||||
ifelse(`$6', `', `SRCPTR_EX(`$1', `$3')', `$6 $3')
|
||||
, ptrdiff
|
||||
, relocatediff
|
||||
')
|
||||
IFDASM(`dasm, ifdef(`DASM_STRUCT_DIRECT', `dst', `zv'), $6 $3')
|
||||
TSRMLS_CC
|
||||
|
|
Loading…
Reference in New Issue