Browse Source

update func prototype for relocate

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1453 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
11bb4f0d07
  1. 8
      mod_cacher/xc_cacher.c
  2. 19
      processor/foot.m4

8
mod_cacher/xc_cacher.c

@ -179,9 +179,15 @@ static xc_entry_data_php_t *xc_php_store_unlocked(xc_cache_t *cache, xc_entry_da
#if 1
{
xc_entry_data_php_t *p = malloc(stored_php->size);
xc_entry_data_php_t *backup = 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(stored_php, 0, p, p TSRMLS_CC);
memcpy(backup, stored_php, stored_php->size);
xc_processor_relocate_xc_entry_data_php_t(stored_php, stored_php, p, 0 TSRMLS_CC);
assert(memcmp(stored_php, backup, stored_php->size) == 0);
memcpy(stored_php, p, p->size);
xc_processor_relocate_xc_entry_data_php_t(p, 0, stored_php, stored_php TSRMLS_CC);
}
#endif
if (stored_php) {

19
processor/foot.m4

@ -136,17 +136,20 @@ 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 *old_src, $1 *old_start, $1 *new_src, $1 *new_start TSRMLS_DC)') dnl {{{
/* old_src = readable element, before memcpy if any
* new_src = writable element, after memcpy if any
* virtual_old_src = brother pointers relatived to this address, before relocation
* virtual_new_src = brother pointers relatived to this address, after relocation
*/
EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *old_src, $1 *virtual_old_src, $1 *new_src, $1 *virtual_new_src TSRMLS_DC)') dnl {{{
{
ptrdiff_t offset_from_old_start = 0; /* unkown X used later */
$1 *const old_address = ptradd($1 *, offset_from_old_start, (ptrdiff_t) old_start);
ptrdiff_t offset = ptrsub(old_address, old_src);
$1 *const new_address = ptradd($1 *, new_src, offset);
char *old_address = 0; /* unkown X used later */
ptrdiff_t offset = ptrsub(old_address, (ptrdiff_t) virtual_old_src);
/* diff to new_ptr */
ptrdiff_t ptrdiff = (ptrdiff_t) new_address;
ptrdiff_t relocatediff = (ptrdiff_t) ptradd($1 *, new_start, offset);
assert(new_src == ptradd($1 *, old_src, ptrdiff));
ptrdiff_t ptrdiff = ptrsub(new_src, old_src);
ptrdiff_t relocatediff = (ptrdiff_t) ptradd($1 *, virtual_new_src, offset);
assert(ptradd($1 *, old_src, ptrdiff) == new_src);
xc_relocate_$1(new_src, ptrdiff, relocatediff TSRMLS_CC);
}

Loading…
Cancel
Save