Browse Source

improve readability using ptradd

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1452 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
dae85e876d
  1. 3
      processor/foot.m4
  2. 3
      processor/head.m4
  3. 2
      processor/main.m4

3
processor/foot.m4

@ -135,8 +135,6 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_zval(zval *dst, const zval *src, z
return dst;
}
dnl }}}
#define ptradd(type, ptr, ptrdiff) ((type) ((char *) (ptr) + (ptrdiff)))
#define ptrsub(ptr1, ptr2) ((char *) (ptr1) - (char *)(ptr2))
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 {{{
{
@ -148,6 +146,7 @@ EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *old_src, $1 *old_start, $1
/* 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));
xc_relocate_$1(new_src, ptrdiff, relocatediff TSRMLS_CC);
}

3
processor/head.m4

@ -80,6 +80,9 @@ typedef UChar zstr_uchar;
typedef char zstr_char;
#define MAX_DUP_STR_LEN 256
#define ptradd(type, ptr, ptrdiff) ((type) (((char *) (ptr)) + (ptrdiff)))
#define ptrsub(ptr1, ptr2) (((char *) (ptr1)) - ((char *) (ptr2)))
dnl }}}
dnl {{{ _xc_processor_t
typedef struct _xc_processor_t {

2
processor/main.m4

@ -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) + ptrdiff))', `$2')')
define(`SRCPTR_EX', `IFRELOCATE(`ptradd($1 *, $2, ptrdiff)', `$2')')
dnl }}}
dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2)
define(`ALLOC', `

Loading…
Cancel
Save