Changeset 1470 for trunk


Ignore:
Timestamp:
2013-11-12T11:08:17+01:00 (10 months ago)
Author:
moo
Message:

processor: abstract store target (storage)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1468 r1470  
    160160static void xc_holds_destroy(TSRMLS_D); 
    161161 
     162static void *xc_cache_storage(void *data, size_t size) /* {{{ */ 
     163{ 
     164    xc_allocator_t *allocator = (xc_allocator_t *) data; 
     165    return allocator->vtable->malloc(allocator, size); 
     166} 
     167/* }}} */ 
     168 
    162169/* any function in *_unlocked is only safe be called within locked (single thread access) area */ 
    163170 
     
    173180{ 
    174181    xc_entry_data_php_t *stored_php; 
     182    xc_processor_storage_t storage; 
     183    storage.allocator      = &xc_cache_storage; 
     184    storage.allocator_data = (void *) cache->allocator; 
     185    storage.relocatediff   = cache->shm->readonlydiff; 
    175186 
    176187    php->hits     = 0; 
    177188    php->refcount = 0; 
    178     stored_php = xc_processor_store_xc_entry_data_php_t(cache->shm->readonlydiff, cache->allocator, php TSRMLS_CC); 
     189    stored_php = xc_processor_store_xc_entry_data_php_t(&storage, php TSRMLS_CC); 
    179190#if 0 
    180191    { 
     
    308319{ 
    309320    xc_entry_t *stored_entry; 
     321    xc_processor_storage_t storage; 
     322    storage.allocator      = &xc_cache_storage; 
     323    storage.allocator_data = (void *) cache->allocator; 
     324    storage.relocatediff   = cache->shm->readonlydiff; 
    310325 
    311326    entry->hits  = 0; 
     
    313328    entry->atime = XG(request_time); 
    314329    stored_entry = type == XC_TYPE_PHP 
    315         ? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache->shm->readonlydiff, cache->allocator, (xc_entry_php_t *) entry TSRMLS_CC) 
    316         : (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache->shm->readonlydiff, cache->allocator, (xc_entry_var_t *) entry TSRMLS_CC); 
     330        ? (xc_entry_t *) xc_processor_store_xc_entry_php_t(&storage, (xc_entry_php_t *) entry TSRMLS_CC) 
     331        : (xc_entry_t *) xc_processor_store_xc_entry_var_t(&storage, (xc_entry_var_t *) entry TSRMLS_CC); 
    317332    if (stored_entry) { 
    318333        xc_entry_add_unlocked(cache->cached, entryslotid, stored_entry); 
  • trunk/processor/foot.m4

    r1468 r1470  
     1dnl {{{ xc_store_target 
     2EXPORT(`typedef void *(*xc_processor_storage_allocator_t)(void *data, size_t size);') 
     3EXPORT(`typedef struct { xc_processor_storage_allocator_t allocator; void *allocator_data; ptrdiff_t relocatediff; } xc_processor_storage_t;') 
     4dnl }}} 
    15define(`DEFINE_STORE_API', ` 
    2 EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(ptrdiff_t relocatediff, xc_allocator_t *allocator, $1 *src TSRMLS_DC)') dnl {{{ 
     6EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(const xc_processor_storage_t *storage, $1 *src TSRMLS_DC)') dnl {{{ 
    37{ 
    48    $1 *dst; 
     
    711    memset(&processor, 0, sizeof(processor)); 
    812    processor.handle_reference = 1; 
    9     processor.relocatediff = relocatediff; 
     13    processor.relocatediff = storage->relocatediff; 
    1014 
    1115    IFAUTOCHECK(`xc_stack_init(&processor.allocsizes);') 
     
    4549 
    4650        /* allocator :) */ 
    47         processor.p = (char *) allocator->vtable->malloc(allocator, processor.size); 
     51        processor.p = (char *) storage->allocator(storage->allocator_data, processor.size); 
    4852        if (processor.p == NULL) { 
    4953            dst = NULL; 
Note: See TracChangeset for help on using the changeset viewer.