Changeset 1555 in svn


Ignore:
Timestamp:
2014-11-09T06:49:44Z (4 years ago)
Author:
Xuefer
Message:

separate plain c code to .h files

Location:
trunk
Files:
3 added
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.frag

    r1473 r1555  
    1616
    1717$(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SOURCES)
    18     $(M4) $(XCACHE_ENABLE_TEST) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
     18    $(M4) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
    1919    mv $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT)
    2020
  • trunk/Makefile.frag.deps

    r1552 r1555  
    1919xcache/xc_mutex.lo $(builddir)/xcache/xc_mutex.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
    2020xcache/xc_opcode_spec.lo $(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_opcode_spec_def.h $(srcdir)/xcache/xc_shm.h
    21 xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C)
     21xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_util.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    2222xcache/xc_sandbox.lo $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    2323xcache/xc_shm.lo $(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
  • trunk/config.m4

    r1551 r1555  
    136136
    137137  dnl $ac_srcdir etc require PHP_NEW_EXTENSION
    138   XCACHE_PROC_SOURCES=`ls $ac_srcdir/processor/*.m4`
     138  XCACHE_PROC_SOURCES=`ls $ac_srcdir/processor/*.m4 $ac_srcdir/processor/*.h`
    139139  PHP_SUBST([XCACHE_PROC_SOURCES])
    140140fi
  • trunk/config.w32

    r1551 r1555  
    140140    ADD_FLAG("CFLAGS_XCACHE", "/I " + builddir);
    141141    /// }}}
    142     XCACHE_PROC_SOURCES=glob(srcdir + "\\processor\\*.m4").join(' ');
     142    XCACHE_PROC_SOURCES = [];
     143    XCACHE_PROC_SOURCES.concat(glob(srcdir + "\\processor\\*.m4"));
     144    XCACHE_PROC_SOURCES.concat(glob(srcdir + "\\processor\\*.h"));
     145    XCACHE_PROC_SOURCES = XCACHE_PROC_SOURCES.join(' ');
    143146    ADD_FLAG("XCACHE_PROC_SOURCES", XCACHE_PROC_SOURCES);
    144147}
  • trunk/processor/debug.h

    r1554 r1555  
    1 IFAUTOCHECK(`
    2 #define RELAYLINE_DC , int relayline
    3 #define RELAYLINE_CC , __LINE__
    4 ', `
    5 #define RELAYLINE_DC
    6 #define RELAYLINE_CC
    7 ')
     1#ifdef HAVE_XCACHE_TEST
     2#   define RELAYLINE_DC , int relayline
     3#   define RELAYLINE_CC , __LINE__
     4#else
     5#   define RELAYLINE_DC
     6#   define RELAYLINE_CC
     7#endif
    88
    9 ifdef(`XCACHE_ENABLE_TEST', `
    10 #undef NDEBUG
    11 #include <assert.h>
    12 m4_errprint(`AUTOCHECK INFO: runtime autocheck Enabled (debug build)')
    13 ', `
    14 m4_errprint(`AUTOCHECK INFO: runtime autocheck Disabled (optimized build)')
    15 ')
    16 ifdef(`DEBUG_SIZE', `static int xc_totalsize = 0;')
     9#ifdef HAVE_XCACHE_TEST
     10#   undef NDEBUG
     11#   include <assert.h>
     12#endif
    1713
    1814#ifndef NDEBUG
     
    5551/* }}} */
    5652#endif
    57 /* {{{ field name checker */
    58 IFAUTOCHECK(`dnl
    59 static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, size_t assert_names_count, HashTable *done_names)
     53#ifdef HAVE_XCACHE_TEST
     54static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, size_t assert_names_count, HashTable *done_names) /* {{{ field name checker */
    6055{
    6156    int errors = 0;
     
    9590    return errors;
    9691}
    97 ')
    9892/* }}} */
     93#endif
     94#ifdef HAVE_XCACHE_TEST
     95static void *xc_memsetptr(void *mem, void *content, size_t n) /* {{{ */
     96{
     97    void **p = (void **) mem;
     98    void **end = (void **) ((char *) mem + n);
     99    while (p < end - sizeof(content)) {
     100        *p = content;
     101        p += sizeof(content);
     102    }
     103    if (p < end) {
     104        memset(p, -1, end - p);
     105    }
     106    return mem;
     107}
     108/* }}} */
     109#endif
  • trunk/processor/head.m4

    r1554 r1555  
    1 dnl {{{ === program start ========================================
     1dnl === program start ========================================
    22divert(0)
     3ifdef(`XCACHE_ENABLE_TEST', `
     4m4_errprint(`AUTOCHECK INFO: runtime autocheck Enabled (debug build)')
     5', `
     6m4_errprint(`AUTOCHECK INFO: runtime autocheck Disabled (optimized build)')
     7')
     8
    39#include <string.h>
    410#include <stdio.h>
     
    2632extern unsigned int zend_hash_canary;
    2733#endif
    28 dnl }}}
     34dnl
    2935
    30 include(__dir__`/debug-helper.m4')
    31 include(__dir__`/type-helper.m4')
    32 include(__dir__`/string-helper.m4')
     36#ifdef DEBUG_SIZE
     37static int xc_totalsize = 0;
     38#endif
     39
     40#include "processor/debug.h"
     41#include "processor/types.h"
     42include(__dir__`/types.m4')
    3343
    3444/* {{{ call op_array ctor handler */
     
    4151}
    4252/* }}} */
    43 /* {{{ memsetptr */
    44 IFAUTOCHECK(`dnl
    45 static void *memsetptr(void *mem, void *content, size_t n)
    46 {
    47     void **p = (void **) mem;
    48     void **end = (void **) ((char *) mem + n);
    49     while (p < end - sizeof(content)) {
    50         *p = content;
    51         p += sizeof(content);
    52     }
    53     if (p < end) {
    54         memset(p, -1, end - p);
    55     }
    56     return mem;
    57 }
    58 ')
    59 /* }}} */
    60 dnl {{{ _xc_processor_t
    61 typedef struct _xc_processor_t {
    62     char *p;
    63     size_t size;
    64     HashTable zvalptrs;
    65     zend_bool handle_reference; /* enable if to deal with reference */
    66     zend_bool have_references;
    67     ptrdiff_t relocatediff;
     53#include "processor/processor-t.h"
    6854
    69     const xc_entry_php_t *entry_php_src;
    70     const xc_entry_php_t *entry_php_dst;
    71     const xc_entry_data_php_t *php_src;
    72     const xc_entry_data_php_t *php_dst;
    73     const zend_class_entry *cache_ce;
    74     zend_ulong cache_class_index;
    75 
    76     const zend_op_array    *active_op_array_src;
    77     zend_op_array          *active_op_array_dst;
    78     const zend_class_entry *active_class_entry_src;
    79     zend_class_entry       *active_class_entry_dst;
    80     zend_uint                 active_class_index;
    81     zend_uint                 active_op_array_index;
    82     const xc_op_array_info_t *active_op_array_infos_src;
    83 
    84     zend_bool readonly_protection; /* wheather it's present */
    85 
    86     STRING_HELPER_T
    87 
    88     IFAUTOCHECK(xc_vector_t allocsizes;)
    89 } xc_processor_t;
    90 dnl }}}
    91 STRING_HELPERS()
    92 
     55#include "processor/string-helper.h"
     56include(__dir__`/string-helper.m4')
    9357include(__dir__`/class-helper.m4')
  • trunk/processor/main.m4

    r1551 r1555  
    11divert(-1)
    22dnl ================ start ======================
    3 dnl define(`XCACHE_ENABLE_TEST')
     3dnl #define HAVE_XCACHE_TEST
    44dnl define(`DEBUG_SIZE')
    55define(`USEMEMCPY')
     
    7272        $1 = (REALTYPE *) (processor->p = (char *) ALIGN(processor->p));
    7373        ifelse(`$4', `', `
    74                 IFAUTOCHECK(`memsetptr($1, (void *) (unsigned long) __LINE__, SIZE);')
     74                IFAUTOCHECK(`xc_memsetptr($1, (void *) (unsigned long) __LINE__, SIZE);')
    7575            ', `
    7676                memset($1, 0, SIZE);
     
    8989                REALTYPE*COUNT, `HashTable*1', `ALLOC_HASHTABLE($1);',
    9090                `', `', `$1 = (REALTYPE *) emalloc(SIZE);')
    91             IFAUTOCHECK(`memsetptr($1, (void *) __LINE__, SIZE);')
     91            IFAUTOCHECK(`xc_memsetptr($1, (void *) __LINE__, SIZE);')
    9292        ', `
    9393            $1 = (REALTYPE *) ecalloc(COUNT, sizeof($2));
     
    119119')
    120120dnl }}}
    121 dnl {{{ IFAUTOCHECKEX
    122 define(`IFAUTOCHECKEX', `ifdef(`XCACHE_ENABLE_TEST', `$1', `$2')')
    123 dnl }}}
    124121dnl {{{ IFAUTOCHECK
    125 define(`IFAUTOCHECK', `IFAUTOCHECKEX(`
    126 #ifndef NDEBUG
    127         $1
     122define(`IFAUTOCHECK', `
     123#ifdef HAVE_XCACHE_TEST
     124    $1
     125ifelse(`$2', `', `
     126#else
     127    $2
     128')
    128129#endif
    129 ')')
     130')
    130131dnl }}}
    131132dnl {{{ DBG
    132 define(`DBG', `ifdef(`XCACHE_ENABLE_TEST', `
    133     /* `$1' */
    134 ')')
     133define(`DBG', `/* `$1' */
     134')
    135135dnl }}}
    136136dnl {{{ EXPORT(1:code)
  • trunk/processor/string-helper.m4

    r1554 r1555  
    1 #define MAX_DUP_STR_LEN 256
    2 
    3 define(`STRING_HELPER_T', `
    4 HashTable strings;
    5 ')
    6 
    7 define(`STRING_HELPERS', `
    8 static inline size_t xc_zstrlen_char(const_zstr s) /* {{{ */
    9 {
    10     return strlen(ZSTR_S(s));
    11 }
    12 /* }}} */
    13 #ifdef IS_UNICODE
    14 static inline size_t xc_zstrlen_uchar(zstr s) /* {{{ */
    15 {
    16     return u_strlen(ZSTR_U(s));
    17 }
    18 /* }}} */
    19 static inline size_t xc_zstrlen(int type, const_zstr s) /* {{{ */
    20 {
    21     return type == IS_UNICODE ? xc_zstrlen_uchar(s) : xc_zstrlen_char(s);
    22 }
    23 /* }}} */
    24 #else
    25 /* {{{ xc_zstrlen */
    26 #define xc_zstrlen(dummy, s) xc_zstrlen_char(s)
    27 /* }}} */
    28 #endif
    291static inline void xc_calc_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size RELAYLINE_DC TSRMLS_DC) { /* {{{ */
    302    pushdef(`PROCESSOR_TYPE', `calc')
     
    7749}
    7850/* }}} */
    79 ')
  • trunk/processor/types.m4

    r1554 r1555  
    1818define(`COUNTOF_xc_ztstring', `1')
    1919
    20 typedef zval *zval_ptr;
    21 typedef zval *zval_ptr_nullable;
    22 typedef char *xc_ztstring;
    23 #ifdef ZEND_ENGINE_2_4
    24 typedef zend_trait_alias *zend_trait_alias_ptr;
    25 typedef zend_trait_precedence *zend_trait_precedence_ptr;
    26 #endif
    27 #ifdef ZEND_ENGINE_2_3
    28 typedef int last_brk_cont_t;
    29 #else
    30 typedef zend_uint last_brk_cont_t;
    31 #endif
    32 
    33 typedef zend_uchar xc_zval_type_t;
    34 typedef int xc_op_type;
    35 typedef zend_uchar xc_opcode;
    36 #ifdef IS_UNICODE
    37 typedef UChar zstr_uchar;
    38 #endif
    39 typedef char  zstr_char;
    40 
    4120EXPORT(`typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t;')
    4221
Note: See TracChangeset for help on using the changeset viewer.