Changeset 1452


Ignore:
Timestamp:
2013-11-08T08:21:40+01:00 (5 months ago)
Author:
moo
Message:

improve readability using ptradd

Location:
trunk/processor
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/foot.m4

    r1448 r1452  
    136136} 
    137137dnl }}} 
    138 #define ptradd(type, ptr, ptrdiff) ((type) ((char *) (ptr) + (ptrdiff))) 
    139 #define ptrsub(ptr1, ptr2) ((char *) (ptr1) - (char *)(ptr2)) 
    140138define(`DEFINE_RELOCATE_API', ` 
    141139EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *old_src, $1 *old_start, $1 *new_src, $1 *new_start TSRMLS_DC)') dnl {{{ 
     
    149147    ptrdiff_t ptrdiff = (ptrdiff_t) new_address; 
    150148    ptrdiff_t relocatediff = (ptrdiff_t) ptradd($1 *, new_start, offset); 
     149    assert(new_src == ptradd($1 *, old_src, ptrdiff)); 
    151150 
    152151    xc_relocate_$1(new_src, ptrdiff, relocatediff TSRMLS_CC); 
  • trunk/processor/head.m4

    r1446 r1452  
    8181 
    8282#define MAX_DUP_STR_LEN 256 
     83 
     84#define ptradd(type, ptr, ptrdiff) ((type) (((char *) (ptr)) + (ptrdiff))) 
     85#define ptrsub(ptr1, ptr2) (((char *) (ptr1)) - ((char *) (ptr2))) 
    8386dnl }}} 
    8487dnl {{{ _xc_processor_t 
  • trunk/processor/main.m4

    r1450 r1452  
    2626dnl }}} 
    2727dnl {{{ SRCPTR_EX(1:type, 2:elm) 
    28 define(`SRCPTR_EX', `IFRELOCATE(`(($1 *) (((char *) $2) + ptrdiff))', `$2')') 
     28define(`SRCPTR_EX', `IFRELOCATE(`ptradd($1 *, $2, ptrdiff)', `$2')') 
    2929dnl }}} 
    3030dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2) 
Note: See TracChangeset for help on using the changeset viewer.