Changeset 1455 in svn for trunk


Ignore:
Timestamp:
2013-11-08T09:30:06Z (22 months ago)
Author:
Xuefer
Message:

relocate: update proto to like memcpy/store/restore, update test code

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1453 r1455  
    182182        xc_entry_data_php_t *backup = malloc(stored_php->size);
    183183        fprintf(stderr, "%lu\n", stored_php->size);
    184         memcpy(p, stored_php, stored_php->size);
    185184        memcpy(backup, stored_php, stored_php->size);
    186         xc_processor_relocate_xc_entry_data_php_t(stored_php, stored_php, p, 0 TSRMLS_CC);
    187         assert(memcmp(stored_php, backup, stored_php->size) == 0);
    188 
    189         memcpy(stored_php, p, p->size);
    190         xc_processor_relocate_xc_entry_data_php_t(p, 0, stored_php, stored_php TSRMLS_CC);
     185
     186        {
     187            memcpy(p, stored_php, stored_php->size);
     188            xc_processor_relocate_xc_entry_data_php_t(p, p , stored_php, stored_php TSRMLS_CC);
     189            assert(memcmp(stored_php, backup, stored_php->size) == 0);
     190
     191            memcpy(stored_php, p, p->size);
     192            xc_processor_relocate_xc_entry_data_php_t(stored_php, stored_php, p, p TSRMLS_CC);
     193        }
     194
     195        {
     196            memcpy(p, stored_php, stored_php->size);
     197            xc_processor_relocate_xc_entry_data_php_t(p, 0, stored_php, stored_php TSRMLS_CC);
     198            assert(memcmp(stored_php, backup, stored_php->size) == 0);
     199
     200            memcpy(stored_php, p, p->size);
     201            xc_processor_relocate_xc_entry_data_php_t(stored_php, stored_php, p, 0 TSRMLS_CC);
     202        }
    191203    }
    192204#endif
  • trunk/processor/foot.m4

    r1453 r1455  
    137137dnl }}}
    138138define(`DEFINE_RELOCATE_API', `
    139 /* old_src = readable element, before memcpy if any
    140  * new_src = writable element, after memcpy if any
    141  * virtual_old_src = brother pointers relatived to this address, before relocation
    142  * virtual_new_src = brother pointers relatived to this address, after  relocation
     139/* src = readable element, before memcpy if any
     140 * dst = writable element, after memcpy if any
     141 * virtual_src = brother pointers relatived to this address, before relocation
     142 * virtual_dst = brother pointers relatived to this address, after  relocation
    143143 */
    144 EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *old_src, $1 *virtual_old_src, $1 *new_src, $1 *virtual_new_src TSRMLS_DC)') dnl {{{
     144EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *dst, $1 *virtual_dst, $1 *src, $1 *virtual_src TSRMLS_DC)') dnl {{{
    145145{
    146146    char *old_address = 0; /* unkown X used later */
    147     ptrdiff_t offset = ptrsub(old_address, (ptrdiff_t) virtual_old_src);
     147    ptrdiff_t offset = ptrsub(old_address, (ptrdiff_t) virtual_src);
    148148
    149149    /* diff to new_ptr */
    150     ptrdiff_t ptrdiff = ptrsub(new_src, old_src);
    151     ptrdiff_t relocatediff = (ptrdiff_t) ptradd($1 *, virtual_new_src, offset);
    152     assert(ptradd($1 *, old_src, ptrdiff) == new_src);
     150    ptrdiff_t ptrdiff = ptrsub(dst, src);
     151    ptrdiff_t relocatediff = (ptrdiff_t) ptradd($1 *, virtual_dst, offset);
     152    assert(ptradd($1 *, src, ptrdiff) == dst);
    153153
    154     xc_relocate_$1(new_src, ptrdiff, relocatediff TSRMLS_CC);
     154    xc_relocate_$1(dst, ptrdiff, relocatediff TSRMLS_CC);
    155155}
    156156dnl }}}
Note: See TracChangeset for help on using the changeset viewer.