Changeset 4 in svn for trunk


Ignore:
Timestamp:
2006-05-13T01:54:55Z (9 years ago)
Author:
Xuefer
Message:

compatibility fix: remove the using of gnu m4 extension

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/mkstructinfo.awk

    r1 r4  
    2222            # elms = elms " `" buffer[i] "'";
    2323            elm = elm "sizeof(((" instruct "*)NULL)->" buffer[i] ")";
    24             elms = elms " " buffer[i] "";
     24
     25            if (elms == "") {
     26                elms = buffer[i];
     27            }
     28            else {
     29                elms = elms "," buffer[i];
     30            }
    2531        }
    2632        printf "define(`ELEMENTSOF_%s', `%s')\n", instruct, elms;
  • trunk/processor/hashtable.m4

    r1 r4  
    101101                IFCOPY(`pnew->pData = &pnew->pDataPtr;')
    102102                dnl no alloc
    103                 STRUCT_P_EX(`$2', pnew->pData, (($2*)b->pData), `$3', ` ')
     103                STRUCT_P_EX(`$2', pnew->pData, (($2*)b->pData), `', `$3', ` ')
    104104            }
    105105            else {
    106                 STRUCT_P_EX(`$2', pnew->pData, (($2*)b->pData), `$3')
     106                STRUCT_P_EX(`$2', pnew->pData, (($2*)b->pData), `', `$3')
    107107                IFCOPY(`pnew->pDataPtr = NULL;')
    108108            }
  • trunk/processor/head.m4

    r1 r4  
    77#include "zend_compile.h"
    88#include "zend_API.h"
     9#include "zend_ini.h"
    910
    1011#include "xcache.h"
     
    2930#undef NDEBUG
    3031#include <assert.h>
    31 include(structinfo.m4)
     32include(builddir`/structinfo.m4')
    3233')
    3334#ifndef NDEBUG
  • trunk/processor/main.m4

    r1 r4  
    8787')
    8888dnl }}}
    89 dnl {{{ PROC_CLASS_ENTRY_P
    90 define(`PROC_CLASS_ENTRY_P', `PROC_CLASS_ENTRY_P_EX(`dst->$1', `src->$1')`'DONE(`$1')')
     89dnl {{{ PROC_CLASS_ENTRY_P(1:elm)
     90define(`PROC_CLASS_ENTRY_P', `PROC_CLASS_ENTRY_P_EX(`dst->$1', `src->$1', `$1')`'DONE(`$1')')
     91dnl PROC_CLASS_ENTRY_P_EX(1:dst, 2:src, 3:elm-name)
    9192define(`PROC_CLASS_ENTRY_P_EX', `
    9293    if ($2) {
    9394        IFSTORE(`$1 = (zend_class_entry *) xc_get_class_num(processor, $2);')
    9495        IFRESTORE(`$1 = xc_get_class(processor, (zend_uint) $2);')
    95         IFDASM(`add_assoc_stringl_ex(dst, ZEND_STRS("patsubst(`$1', `dst->')"), $2->name, strlen($2->name), 1);')
     96        IFDASM(`add_assoc_stringl_ex(dst, ZEND_STRS("$3"), $2->name, strlen($2->name), 1);')
    9697    }
    9798    else {
    98         COPYNULL_EX($1)
     99        COPYNULL_EX(`$1', `$3')
    99100    }
    100101')
     
    132133define(`SETNULL', `SETNULL_EX(`dst->$1')DONE(`$1')')
    133134dnl }}}
    134 dnl {{{ COPYNULL_EX
     135dnl {{{ COPYNULL_EX(1:dst, 2:elm-name)
    135136define(`COPYNULL_EX', `
    136     IFDASM(`add_assoc_null_ex(dst, ZEND_STRS("patsubst(`$1', `dst->')"));')
     137    IFDASM(`add_assoc_null_ex(dst, ZEND_STRS("$2"));')
    137138    IFNOTMEMCPY(`IFCOPY(`$1 = NULL;')')
    138139')
     140dnl }}}
     141dnl {{{ COPYNULL(1:elm)
     142# foreach(VAR, (LIST), STMT)
     143m4_define([foreach],
     144       [m4_pushdef([$1])_foreach([$1], [$2], [$3])m4_popdef([$1])])
     145m4_define([_arg1], [$1])
     146m4_define([_foreach],
     147       [ifelse([$2], [()], ,
     148       [m4_define([$1], _arg1$2)$3[]_foreach([$1],
     149                                                       (shift$2),
     150                                                       [$3])])])
    139151define(`COPYNULL', `
    140     COPYNULL_EX(`dst->$1')DONE(`$1')
     152    COPYNULL_EX(`dst->$1', `$2')DONE(`$1')
     153')
     154dnl }}}
     155dnl {{{ LIST_DIFF(1:left-list, 2:right-list)
     156define(`foreach',
     157       `pushdef(`$1')_foreach(`$1', `$2', `$3')popdef(`$1')')
     158define(`_arg1', `$1')
     159define(`_foreach',                             
     160       `ifelse(`$2', `()', ,                       
     161       `define(`$1', _arg1$2)$3`'_foreach(`$1',
     162                                                       (shift$2),
     163                                                       `$3')')')
     164define(`LIST_DIFF', `dnl
     165foreach(`i', `($1)', `pushdef(`item_'defn(`i'))')dnl allocate variable for items in $1
     166foreach(`i', `($2)', `pushdef(`item_'defn(`i'))undefine(`item_'defn(`i'))')dnl allocate variable for items in $2, and undefine it
     167foreach(`i', `($1)', `ifdef(`item_'defn(`i'), `defn(`i') ')')dnl see what is still defined
     168foreach(`i', `($2)', `popdef(`item_'defn(`i'))')dnl
     169foreach(`i', `($1)', `popdef(`item_'defn(`i'))')dnl
    141170')
    142171dnl }}}
     
    147176')')
    148177define(`DONE', `
    149     dnl ifelse(regexp(defn(`ELEMENTS'), ` $1'), -1, m4_errprint(`Unknown $1') m4exit(1))
    150     define(`ELEMENTS', patsubst(defn(`ELEMENTS'), ` $1\>'))
     178    define(`ELEMENTS_DONE', defn(`ELEMENTS_DONE')`,$1')
    151179    DONE_SIZE(`sizeof(src->$1)')
    152180')
     
    186214EXPORT(`zval')
    187215
    188 include(hashtable.m4)
    189 include(string.m4)
    190 include(struct.m4)
    191 include(dispatch.m4)
    192 include(head.m4)
     216include(srcdir`/processor/hashtable.m4')
     217include(srcdir`/processor/string.m4')
     218include(srcdir`/processor/struct.m4')
     219include(srcdir`/processor/dispatch.m4')
     220include(srcdir`/processor/head.m4')
    193221
    194222define(`IFNOTMEMCPY', `ifdef(`USEMEMCPY', `', `$1')')
    195 REDEF(`KIND', `calc') include(processor.m4)
    196 REDEF(`KIND', `store') include(processor.m4)
    197 REDEF(`KIND', `restore') include(processor.m4)
     223REDEF(`KIND', `calc') include(srcdir`/processor/processor.m4')
     224REDEF(`KIND', `store') include(srcdir`/processor/processor.m4')
     225REDEF(`KIND', `restore') include(srcdir`/processor/processor.m4')
    198226
    199227REDEF(`IFNOTMEMCPY', `$1')
    200228#ifdef HAVE_XCACHE_DPRINT
    201 REDEF(`KIND', `dprint') include(processor.m4)
     229REDEF(`KIND', `dprint') include(srcdir`/processor/processor.m4')
    202230#endif /* HAVE_XCACHE_DPRINT */
    203231#ifdef HAVE_XCACHE_DISASSEMBLER
    204 REDEF(`KIND', `dasm') include(processor.m4)
     232REDEF(`KIND', `dasm') include(srcdir`/processor/processor.m4')
    205233#endif /* HAVE_XCACHE_DISASSEMBLER */
    206234#ifdef HAVE_XCACHE_ASSEMBLER
    207 REDEF(`KIND', `asm') include(processor.m4)
     235REDEF(`KIND', `asm') include(srcdir`/processor/processor.m4')
    208236#endif /* HAVE_XCACHE_ASSEMBLER */
    209237
  • trunk/processor/processor.m4

    r1 r4  
    184184                dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]);
    185185            ')
    186             STRUCT_P_EX(zval, dst[0], src[0], `', ` ')
     186            STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
    187187        } while (0);
    188188    ')
     
    284284        if (src->num_interfaces) {
    285285            CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces)
     286            DONE(`interfaces')
    286287        }
    287288        else {
    288             COPYNULL_EX(dst->interfaces)
     289            COPYNULL(interfaces)
    289290        }
    290291    ')
     
    302303            add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr);
    303304            */
     305            DONE(`interfaces')
    304306        }
    305307        else {
    306             COPYNULL_EX(dst->interfaces)
    307         }
    308     ')
    309     DONE(`interfaces')
     308            COPYNULL(interfaces)
     309        }
     310    ')
     311    IFRESTORE(`', `
     312        IFDASM(`', `
     313            DONE(`interfaces')
     314        ')
     315    ')
    310316    DISPATCH(zend_uint, num_interfaces)
    311317
     
    534540    dnl zend_cv.m4 is illegal to be made public, don not ask me for it
    535541    IFDASM(`
    536         sinclude(`zend_cv.m4')
     542        sinclude(srcdir`/processor/zend_cv.m4')
    537543        ')
    538544#endif
     
    647653        }
    648654    ')
    649     STRUCT_P_EX(zval_ptr, dst->value, src->value, `', `&')
     655    STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
    650656    DONE(value)
    651657')
  • trunk/processor/struct.m4

    r1 r4  
    33')
    44dnl {{{ DECL_STRUCT_P_FUNC(1:type, 2:name, 3:comma=;)
    5 define(`DECL_STRUCT_P_FUNC', `patsubst(
     5define(`DECL_STRUCT_P_FUNC', `translit(
    66    pushdefFUNC_NAME(`$1', `$2')
    77    define(`DEFINED_'ifelse(`$2', `', `$1', `$2'), `')
     
    1717    )ifelse(`$3', `', `;')
    1818    popdef(`FUNC_NAME')dnl
    19 , `[
    20      ]+', ` ')')
     19, `
     20', ` ')')
    2121dnl }}}
    2222dnl {{{ DEF_STRUCT_P_FUNC(1:type, 2:name, 3:body)
     
    3535            int assert_size = SIZEOF_$1, assert_count = COUNTOF_$1;
    3636            int done_size = 0, done_count = 0;
    37             ifdef(`ELEMENTSOF_$1', `
    38                 define(`ELEMENTS', defn(`ELEMENTSOF_$1'))
    39             ')
     37            pushdef(`ELEMENTS_DONE')
    4038            /* }}} */
    4139            IFRESTORE(`assert(xc_is_shm(src));')
     
    7573                }
    7674                ifdef(`ELEMENTSOF_$1', `
    77                     ifelse(ELEMENTS, , , `
     75                    pushdef(`ELEMENTS_UNDONE', LIST_DIFF(defn(`ELEMENTSOF_$1'), defn(`ELEMENTS_DONE')))
     76                    ifelse(defn(`ELEMENTS_UNDONE'), , , `
    7877                        m4_errprint(`====' KIND `$1 =================')
    79                         m4_errprint(`expected:' ELEMENTSOF_$1)
    80                         m4_errprint(`missing :' ELEMENTS)
     78                        m4_errprint(`expected:' defn(`ELEMENTSOF_$1'))
     79                        m4_errprint(`missing :' defn(`ELEMENTS_UNDONE'))
    8180                        define(`EXIT_PENDING', 1)
    8281                    ')
     82                    popdef(`ELEMENTS_UNDONE')
    8383                ')
    84                 undefine(`ELEMENTS')
    8584                /* }}} */
    8685        ')')
     86        IFASSERT(`
     87            undefine(`ELEMENTS_DONE')
     88        ')
    8789    }
    8890/* }`}'} */
     
    9092')
    9193dnl }}}
    92 dnl {{{ STRUCT_P_EX(1:type, 2:dst, 3:src, 4:name=type, 5:&)
     94dnl {{{ STRUCT_P_EX(1:type, 2:dst, 3:src, 4:elm-name, 5:name=type, 6:&)
    9395define(`STRUCT_P_EX', `
    9496    DBG(`$0($*)')
    95     pushdefFUNC_NAME(`$1', `$4')
    96     ifdef(`DEFINED_'ifelse(`$4', `', `$1', `$4'), `', `m4_errprint(`Unknown struct "'ifelse(`$4', `', `$1', `$4')`"')')
    97     assert(sizeof($1) == sizeof(($5 $3)[0]));
    98     ifelse(`$5', `', `ALLOC(`$2', `$1')')
     97    pushdefFUNC_NAME(`$1', `$5')
     98    ifdef(`DEFINED_'ifelse(`$5', `', `$1', `$5'), `', `m4_errprint(`Unknown struct "'ifelse(`$5', `', `$1', `$5')`"')')
     99    assert(sizeof($1) == sizeof(($6 $3)[0]));
     100    ifelse(`$6', `', `ALLOC(`$2', `$1')')
    99101    IFDASM(`do {
    100102        zval *zv;
     
    103105    ')
    104106    FUNC_NAME`'(
    105         IFDPRINT( `           $5 $3, indent')
    106         IFCALC(   `processor, $5 $3')
    107         IFSTORE(  `processor, $5 $2, $5 $3')
    108         IFRESTORE(`processor, $5 $2, $5 $3')
    109         IFDASM(   `zv, $5 $3')
    110         IFASM(    `$5 $2, $5 $3')
     107        IFDPRINT( `           $6 $3, indent')
     108        IFCALC(   `processor, $6 $3')
     109        IFSTORE(  `processor, $6 $2, $6 $3')
     110        IFRESTORE(`processor, $6 $2, $6 $3')
     111        IFDASM(   `zv, $6 $3')
     112        IFASM(    `$6 $2, $6 $3')
    111113        TSRMLS_CC
    112114    );
    113115    IFDASM(`
    114         add_assoc_zval_ex(dst, ZEND_STRS("patsubst(`$2', `dst->')"), zv);
     116        add_assoc_zval_ex(dst, ZEND_STRS("$4"), zv);
    115117    } while (0);
    116118    ')
    117119    popdef(`FUNC_NAME')
    118     ifelse(`$5', , `FIXPOINTER_EX(`$1', `$2')')
     120    ifelse(`$6', , `FIXPOINTER_EX(`$1', `$2')')
    119121')
    120122dnl }}}
     
    123125    DBG(`$0($*)')
    124126    if (src->$2) {
    125         STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$3')
     127        STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$2', `$3')
    126128        IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
    127129    }
    128130    else {
    129         COPYNULL_EX(dst->$2)
     131        COPYNULL_EX(`dst->$2', `$2')
    130132        IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2:\tNULL\n");')
    131133    }
     
    138140    assert(sizeof($1) == sizeof(src->$2));
    139141    IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
    140     STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$3', `&')
     142    STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$2', `$3', `&')
    141143    DONE(`$2')
    142144')
Note: See TracChangeset for help on using the changeset viewer.