Browse Source

simplify export code

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1443 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
b5f6974ff9
  1. 55
      processor/head.m4
  2. 39
      processor/main.m4
  3. 2
      processor/struct.m4

55
processor/head.m4

@ -9,13 +9,13 @@ divert(0)
#include "zend_API.h"
#include "zend_ini.h"
/* export: #include "xcache.h" :export */
EXPORT(`#include "xcache.h"')
#include "xcache.h"
/* export: #include "mod_cacher/xc_cache.h" :export */
EXPORT(`#include "mod_cacher/xc_cache.h"')
#include "mod_cacher/xc_cache.h"
/* export: #include "xcache/xc_shm.h" :export */
EXPORT(`#include "xcache/xc_shm.h"')
#include "xcache/xc_shm.h"
/* export: #include "xcache/xc_allocator.h" :export */
EXPORT(`#include "xcache/xc_allocator.h"')
#include "xcache/xc_allocator.h"
#include "xcache/xc_const_string.h"
#include "xcache/xc_utils.h"
@ -85,7 +85,8 @@ typedef char zstr_char;
#define MAX_DUP_STR_LEN 256
dnl }}}
/* export: typedef struct _xc_processor_t xc_processor_t; :export {{{ */
dnl {{{ _xc_processor_t
EXPORT(`typedef struct _xc_processor_t xc_processor_t;')
struct _xc_processor_t {
char *p;
size_t size;
@ -113,11 +114,9 @@ struct _xc_processor_t {
zend_bool readonly_protection; /* wheather it's present */
IFAUTOCHECK(xc_stack_t allocsizes;)
};
/* }}} */
/* export: typedef struct _xc_relocate_t { ptrdiff_t src; ptrdiff_t dst; ptrdiff_t ptrdiff; } xc_relocate_t; :export {{{ */
/* }}} */
/* export: typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t; :export {{{ */
/* }}} */
dnl }}}
EXPORT(`typedef struct _xc_relocate_t { ptrdiff_t src; ptrdiff_t dst; ptrdiff_t ptrdiff; } xc_relocate_t;')
EXPORT(`typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t;')
/* {{{ memsetptr */
IFAUTOCHECK(`dnl
static void *memsetptr(void *mem, void *content, size_t n)
@ -396,8 +395,8 @@ static int xc_check_names(const char *file, int line, const char *functionName,
/* }}} */
dnl ================ export API
define(`DEFINE_STORE_API', `
/* export: $1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC); :export {{{ */
$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC) {
EXPORTED(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC)') dnl {{{
{
$1 *dst;
xc_processor_t processor;
@ -475,13 +474,13 @@ err_alloc:
return dst;
}
/* }}} */
dnl }}}
')
DEFINE_STORE_API(`xc_entry_var_t')
DEFINE_STORE_API(`xc_entry_php_t')
DEFINE_STORE_API(`xc_entry_data_php_t')
/* export: xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC); :export {{{ */
xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC) {
EXPORTED(`xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC)') dnl {{{
{
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
@ -489,9 +488,9 @@ xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const x
return dst;
}
/* }}} */
/* export: xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *entry_php, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC); :export {{{ */
xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *entry_php, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC) {
dnl }}}
EXPORTED(`xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *entry_php, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC)') dnl {{{
{
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
@ -511,9 +510,9 @@ xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php
}
return dst;
}
/* }}} */
/* export: zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC); :export {{{ */
zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC) {
dnl }}}
EXPORTED(`zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC)') dnl {{{
{
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
@ -531,21 +530,21 @@ zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_refer
return dst;
}
/* }}} */
dnl }}}
define(`DEFINE_RELOCATE_API', `
/* export: void xc_processor_relocate_$1(int a TSRMLS_DC); :export {{{ */
void xc_processor_relocate_$1(int a TSRMLS_DC) {
EXPORTED(`void xc_processor_relocate_$1(int a TSRMLS_DC)') dnl {{{
{
}
/* }}} */
dnl }}}
')
DEFINE_RELOCATE_API(`xc_entry_var_t')
DEFINE_RELOCATE_API(`xc_entry_php_t')
DEFINE_RELOCATE_API(`xc_entry_data_php_t')
/* export: void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC); :export {{{ */
#ifdef HAVE_XCACHE_DPRINT
void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC) {
EXPORTED(`void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC)') dnl {{{
{
IFDPRINT(`INDENT()`'fprintf(stderr, "xc_entry_php_t:src");')
xc_dprint_xc_entry_php_t(src, indent TSRMLS_CC);
}
#endif
/* }}} */
dnl }}}

39
processor/main.m4

@ -127,8 +127,13 @@ define(`DBG', `ifdef(`XCACHE_ENABLE_TEST', `
/* `$1' */
')')
dnl }}}
dnl {{{ EXPORT(1:type, 2:processor)
define(`EXPORT', `define(`EXPORT_$1_$2', 1)')
dnl {{{ EXPORT(1:code)
define(`EXPORT', `/* export: $1 :export */')
define(`EXPORTED', `EXPORT(`$1;')
$1')
dnl }}}
dnl {{{ EXPORT_PROCESSOR(1:type, 2:processor)
define(`EXPORT_PROCESSOR', `define(`EXPORT_$1_$2', 1)')
dnl }}}
dnl {{{ FIXPOINTER(1:type, 2:ele)
define(`FIXPOINTER', `FIXPOINTER_EX(`$1', `DST(`$2')', `SRCPTR(`$1', `$2')')')
@ -243,23 +248,23 @@ define(`IFDPRINT', `ifelse(PROCESSOR_TYPE, `dprint', `$1', `$2')')
define(`IFDASM', `ifelse(PROCESSOR_TYPE, `dasm', `$1', `$2')')
dnl }}}
EXPORT(`dasm', `zend_op_array')
EXPORT(`dasm', `zend_function')
EXPORT(`dasm', `zend_class_entry')
EXPORT_PROCESSOR(`dasm', `zend_op_array')
EXPORT_PROCESSOR(`dasm', `zend_function')
EXPORT_PROCESSOR(`dasm', `zend_class_entry')
EXPORT(`calc', `xc_entry_data_php_t')
EXPORT(`calc', `xc_entry_php_t')
EXPORT(`calc', `xc_entry_var_t')
EXPORT(`store', `xc_entry_data_php_t')
EXPORT(`store', `xc_entry_php_t')
EXPORT(`store', `xc_entry_var_t')
EXPORT(`restore', `xc_entry_data_php_t')
EXPORT(`restore', `xc_entry_php_t')
EXPORT(`dasm', `xc_entry_data_php_t')
EXPORT(`dprint', `xc_entry_php_t')
EXPORT_PROCESSOR(`calc', `xc_entry_data_php_t')
EXPORT_PROCESSOR(`calc', `xc_entry_php_t')
EXPORT_PROCESSOR(`calc', `xc_entry_var_t')
EXPORT_PROCESSOR(`store', `xc_entry_data_php_t')
EXPORT_PROCESSOR(`store', `xc_entry_php_t')
EXPORT_PROCESSOR(`store', `xc_entry_var_t')
EXPORT_PROCESSOR(`restore', `xc_entry_data_php_t')
EXPORT_PROCESSOR(`restore', `xc_entry_php_t')
EXPORT_PROCESSOR(`dasm', `xc_entry_data_php_t')
EXPORT_PROCESSOR(`dprint', `xc_entry_php_t')
EXPORT(`restore', `zval')
EXPORT(`dprint', `zval')
EXPORT_PROCESSOR(`restore', `zval')
EXPORT_PROCESSOR(`dprint', `zval')
include(srcdir`/processor/hashtable.m4')
include(srcdir`/processor/string.m4')

2
processor/struct.m4

@ -29,7 +29,7 @@ define(`DEF_STRUCT_P_FUNC', `
pushdef(`type', `ifelse(`$2', `', `$1', `$2')')
define(`DEFINED_'type, `')
ifelse(ifdef(`EXPORT_'PROCESSOR_TYPE`_'type,1)ifdef(`EXPORT_'PROCESSOR_TYPE`_',1)ifdef(`EXPORT__'type,1), `', `',
`', `', `/* export: DECL_STRUCT_P_FUNC(`$1', `$2') :export */')
`', `', `EXPORT(`DECL_STRUCT_P_FUNC(`$1', `$2')')')
popdef(`type')
DECL_STRUCT_P_FUNC(`$1', `$2', ` ')
{

Loading…
Cancel
Save