summaryrefslogtreecommitdiff
path: root/processor
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2013-11-12 09:46:04 +0000
committerXuefer <xuefer@gmail.com>2013-11-12 09:46:04 +0000
commitd19d64546d0d0fb4ab67ef8e4a8c8de744ee35af (patch)
treea6cae53ed4f7dc379e01490df89342e120bab3e7 /processor
parent548985cdb75cca0937d9cd5a97330fcdb006351e (diff)
downloadxcache-d19d64546d0d0fb4ab67ef8e4a8c8de744ee35af.tar.gz
xcache-d19d64546d0d0fb4ab67ef8e4a8c8de744ee35af.zip
clean up shm handlers
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1468 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'processor')
-rw-r--r--processor/foot.m429
-rw-r--r--processor/head.m46
-rw-r--r--processor/main.m44
-rw-r--r--processor/processor.m44
4 files changed, 22 insertions, 21 deletions
diff --git a/processor/foot.m4 b/processor/foot.m4
index 6c96e24..a774978 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -1,19 +1,18 @@
define(`DEFINE_STORE_API', `
-EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC)') dnl {{{
+EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(ptrdiff_t relocatediff, xc_allocator_t *allocator, $1 *src TSRMLS_DC)') dnl {{{
{
$1 *dst;
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
- processor.reference = 1;
- processor.shm = shm;
- processor.allocator = allocator;
+ processor.handle_reference = 1;
+ processor.relocatediff = relocatediff;
IFAUTOCHECK(`xc_stack_init(&processor.allocsizes);')
/* calc size */ {
zend_hash_init(&processor.strings, 0, NULL, NULL, 0);
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
}
@@ -22,7 +21,7 @@ EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allo
processor.size = ALIGN(processor.size + sizeof(src[0]));
xc_calc_$1(&processor, src TSRMLS_CC);
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
zend_hash_destroy(&processor.strings);
@@ -40,12 +39,12 @@ EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allo
{
IFAUTOCHECK(`char *oldp;')
zend_hash_init(&processor.strings, 0, NULL, NULL, 0);
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
}
/* allocator :) */
- processor.p = (char *) processor.allocator->vtable->malloc(processor.allocator, processor.size);
+ processor.p = (char *) allocator->vtable->malloc(allocator, processor.size);
if (processor.p == NULL) {
dst = NULL;
goto err_alloc;
@@ -67,7 +66,7 @@ EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allo
}
}')
err_alloc:
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
zend_hash_destroy(&processor.strings);
@@ -101,15 +100,15 @@ EXPORTED_FUNCTION(`xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t
processor.readonly_protection = readonly_protection;
/* this function is used for php data only */
if (SRC(`have_references')) {
- processor.reference = 1;
+ processor.handle_reference = 1;
}
processor.entry_php_src = entry_php;
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
}
xc_restore_xc_entry_data_php_t(&processor, dst, src TSRMLS_CC);
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
return dst;
@@ -120,15 +119,15 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_zval(zval *dst, const zval *src, z
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
- processor.reference = have_references;
+ processor.handle_reference = have_references;
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
dnl fprintf(stderr, "mark[%p] = %p\n", src, dst);
zend_hash_add(&processor.zvalptrs, (char *)src, sizeof(src), (void*)&dst, sizeof(dst), NULL);
}
xc_restore_zval(&processor, dst, src TSRMLS_CC);
- if (processor.reference) {
+ if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
diff --git a/processor/head.m4 b/processor/head.m4
index 648c55e..a5220b4 100644
--- a/processor/head.m4
+++ b/processor/head.m4
@@ -100,14 +100,14 @@ typedef struct _xc_processor_t {
size_t size;
HashTable strings;
HashTable zvalptrs;
- zend_bool reference; /* enable if to deal with reference */
+ zend_bool handle_reference; /* enable if to deal with reference */
zend_bool have_references;
+ ptrdiff_t relocatediff;
+
const xc_entry_php_t *entry_php_src;
const xc_entry_php_t *entry_php_dst;
const xc_entry_data_php_t *php_src;
const xc_entry_data_php_t *php_dst;
- xc_shm_t *shm;
- xc_allocator_t *allocator;
const zend_class_entry *cache_ce;
zend_ulong cache_class_index;
diff --git a/processor/main.m4 b/processor/main.m4
index 71d5dd9..b41f2bb 100644
--- a/processor/main.m4
+++ b/processor/main.m4
@@ -259,7 +259,7 @@ include(srcdir`/processor/head.m4')
REDEF(`PROCESSOR_TYPE', `calc') include(srcdir`/processor/processor.m4')
-pushdef(`FIXPOINTER_EX', `$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (void *)$2);')
+pushdef(`FIXPOINTER_EX', `$2 = ptradd($1 *, notnullable($2), processor->relocatediff);')
REDEF(`PROCESSOR_TYPE', `store') include(srcdir`/processor/processor.m4')
popdef(`FIXPOINTER_EX')
@@ -280,6 +280,8 @@ REDEF(`PROCESSOR_TYPE', `dprint') include(srcdir`/processor/processor.m4')
REDEF(`PROCESSOR_TYPE', `dasm') include(srcdir`/processor/processor.m4')
#endif /* HAVE_XCACHE_DISASSEMBLER */
+undefine(`PROCESSOR_TYPE')
+
include(srcdir`/processor/foot.m4')
ifdef(`EXIT_PENDING', `m4exit(EXIT_PENDING)')
diff --git a/processor/processor.m4 b/processor/processor.m4
index 0316669..ffc371e 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -169,7 +169,7 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
', `
do {
IFCALCCOPY(`
- if (processor->reference) {
+ if (processor->handle_reference) {
zval_ptr *ppzv;
if (zend_hash_find(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void **) &ppzv) == SUCCESS) {
IFCOPY(`
@@ -187,7 +187,7 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
ALLOC(DST()[0], zval)
IFCALCCOPY(`
- if (processor->reference) {
+ if (processor->handle_reference) {
IFCALC(`
/* make dummy */
zval_ptr pzv = (zval_ptr)-1;