Changeset 1446 in svn for trunk


Ignore:
Timestamp:
2013-11-07T09:44:15+01:00 (21 months ago)
Author:
Xuefer
Message:

update relocate

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1444 r1446  
    179179#if 1
    180180    {
    181         char *p = malloc(stored_php->size);
    182         fprintf(stderr, "%d\n", stored_php->size);
     181        xc_entry_data_php_t *p = malloc(stored_php->size);
     182        fprintf(stderr, "%lu\n", stored_php->size);
    183183        memcpy(p, stored_php, stored_php->size);
    184         /*
    185         xc_processor_relocate_xc_entry_data_php_t(p, p, 0, stored_php TSRMLS_CC);
    186         */
     184        xc_processor_relocate_xc_entry_data_php_t(p, stored_php, p TSRMLS_CC);
    187185    }
    188186#endif
  • trunk/processor/foot.m4

    r1444 r1446  
    137137dnl }}}
    138138define(`DEFINE_RELOCATE_API', `
    139 EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *dst, char *old_start, char *new_start TSRMLS_DC)') dnl {{{
     139EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *src, $1 *old_start, $1 *new_start TSRMLS_DC)') dnl {{{
    140140{
    141     xc_relocate_t relocate;
    142     relocate.dst = dst;
    143     relocate.old_start = old_start;
    144     relocate.new_start = new_start;
    145     xc_relocate_$1(&relocate, dst TSRMLS_CC);
     141    /*
     142    $1 *xc_addressof(offset) {
     143        return (char *) offset + (ptrdiff_t) old_start;
     144    }
     145    */
     146    ptrdiff_t ptrdiff = /* offset + */ (ptrdiff_t) old_start;
     147
     148    /*
     149    ptrdiff_t *xc_offsetof(offset) {
     150        return (char *) xc_addressof(offset) - src;
     151    }
     152
     153    $1 *xc_newoffset(offset) {
     154        return new_start + xc_offsetof(offset);
     155    }
     156    */
     157    ptrdiff_t relocatediff = new_start + (/* offset + */ ptrdiff - (ptrdiff_t) src);
     158
     159    xc_relocate_$1(src, ptrdiff, relocatediff TSRMLS_CC);
    146160}
    147161dnl }}}
  • trunk/processor/hashtable.m4

    r1444 r1446  
    105105            if (sizeof(void *) == sizeof($2)) {
    106106                IFCOPY(`dstBucket->pData = &dstBucket->pDataPtr;')
    107                 dnl $6 = `' to skip alloc
     107                IFRELOCATE(`srcBucket->pData = &srcBucket->pDataPtr;')
     108                dnl $6 = ` ' to skip alloc, skip pointer fix
    108109                STRUCT_P_EX(`$2', dstBucket->pData, (($2*)srcBucket->pData), `', `$3', ` ')
    109110                FIXPOINTER_EX(`$2', dstBucket->pData)
  • trunk/processor/head.m4

    r1444 r1446  
    111111} xc_processor_t;
    112112dnl }}}
    113 typedef struct _xc_relocate_t { /* {{{ */
    114     ptrdiff_t dst;
    115     char *old_start;
    116     char *new_start;
    117 } xc_relocate_t;
    118 /* }}} */
    119113EXPORT(`typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t;')
    120114/* {{{ memsetptr */
  • trunk/processor/main.m4

    r1444 r1446  
    2626dnl }}}
    2727dnl {{{ SRCPTR_EX(1:type, 2:elm)
    28 define(`SRCPTR_EX', `IFRELOCATE(`(($1 *) (((char *) $2) + 1))', `$2')')
     28define(`SRCPTR_EX', `IFRELOCATE(`(($1 *) (((char *) $2) + ptrdiff))', `$2')')
    2929dnl }}}
    3030dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2)
     
    139139define(`FIXPOINTER_EX', `
    140140    IFSTORE(`$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (void *)$2);')
    141     IFRELOCATE(`patsubst($2, `dst', `src') = ($1 *) (((char *) patsubst($2, `dst', `src')) + 1);')
     141    IFRELOCATE(`
     142        pushdef(`relocatee', `patsubst($2, `dst', `src')')
     143        relocatee = ($1 *) (((char *) relocatee) + relocatediff);
     144        popdef(`relocatee')
     145    ')
    142146')
    143147dnl }}}
  • trunk/processor/struct.m4

    r1444 r1446  
    1515        IFSTORE(  `xc_processor_t *processor, $1 *dst, const $1 * const src')
    1616        IFRESTORE(`xc_processor_t *processor, $1 *dst, const $1 * const src')
    17         IFRELOCATE(`const xc_relocate_t *relocate, $1 *const src')
     17        IFRELOCATE(`$1 *const src, ptrdiff_t ptrdiff, ptrdiff_t relocatediff')
    1818        IFDASM(`xc_dasm_t *dasm, zval *dst, const $1 * const src')
    1919        TSRMLS_DC
     
    149149        IFRESTORE(`processor, $6 $2, $6 $3')
    150150        IFRELOCATE(`
    151             relocate
    152             , ifelse(`$6', `', `SRCPTR_EX(`$1', `$3')', `$6 $3')
     151            ifelse(`$6', `', `SRCPTR_EX(`$1', `$3')', `$6 $3')
     152            , ptrdiff
     153            , relocatediff
    153154        ')
    154155        IFDASM(`dasm, ifdef(`DASM_STRUCT_DIRECT', `dst', `zv'), $6 $3')
Note: See TracChangeset for help on using the changeset viewer.