Ignore:
Timestamp:
2013-11-12T10:46:04+01:00 (12 months ago)
Author:
moo
Message:

clean up shm handlers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache/xc_shm_mmap.c

    r1154 r1468  
    3030 
    3131#include "php.h" 
    32 #define XC_SHM_IMPL _xc_mmap_shm_t 
     32 
     33typedef struct xc_mmap_shm_t xc_shm_t; 
     34#define XC_SHM_T_DEFINED 
    3335#include "xc_shm.h" 
    3436#include "xc_utils.h" 
     
    3941 
    4042/* {{{ xc_shm_t */ 
    41 struct _xc_mmap_shm_t { 
    42     xc_shm_handlers_t *handlers; 
    43     zend_bool disabled; 
     43struct xc_mmap_shm_t { 
     44    xc_shm_base_t base; 
    4445    void *ptr; 
    4546    void *ptr_ro; 
    46     long  diff; 
    4747    xc_shmsize_t size; 
    4848    xc_shmsize_t memoffset; 
     
    6161#define PTR_SUB(ptr, v) (((char *) (ptr)) - (v)) 
    6262 
    63 static XC_SHM_CAN_READONLY(xc_mmap_can_readonly) /* {{{ */ 
    64 { 
    65     return shm->ptr_ro != NULL; 
    66 } 
    67 /* }}} */ 
    6863static XC_SHM_IS_READWRITE(xc_mmap_is_readwrite) /* {{{ */ 
    6964{ 
     
    7368static XC_SHM_IS_READONLY(xc_mmap_is_readonly) /* {{{ */ 
    7469{ 
    75     return xc_mmap_can_readonly(shm) && p >= shm->ptr_ro && (char *)p < (char *)shm->ptr_ro + shm->size; 
    76 } 
    77 /* }}} */ 
    78 static XC_SHM_TO_READWRITE(xc_mmap_to_readwrite) /* {{{ */ 
    79 { 
    80     if (shm->diff) { 
    81         assert(xc_mmap_is_readonly(shm, p)); 
    82         p = PTR_SUB(p, shm->diff); 
    83     } 
    84     assert(xc_mmap_is_readwrite(shm, p)); 
    85     return p; 
    86 } 
    87 /* }}} */ 
    88 static XC_SHM_TO_READONLY(xc_mmap_to_readonly) /* {{{ */ 
    89 { 
    90     assert(xc_mmap_is_readwrite(shm, p)); 
    91     if (shm->diff) { 
    92         p = PTR_ADD(p, shm->diff); 
    93         assert(xc_mmap_is_readonly(shm, p)); 
    94     } 
    95     return p; 
     70    return xc_shm_can_readonly(shm) && p >= shm->ptr_ro && (char *)p < (char *)shm->ptr_ro + shm->size; 
    9671} 
    9772/* }}} */ 
     
    133108    /* 
    134109    shm->size = NULL; 
    135     shm->diff = 0; 
     110    shm->base.readonlydiff = 0; 
    136111    */ 
    137112 
     
    243218 
    244219        if (ro_ok) { 
    245             shm->diff = PTR_SUB(shm->ptr_ro, (char *) shm->ptr); 
     220            shm->base.readonlydiff = PTR_SUB(shm->ptr_ro, (char *) shm->ptr); 
    246221            /* no overlap */ 
    247             assert((xc_shmsize_t) abs(shm->diff) >= size); 
     222            assert((xc_shmsize_t) abs(shm->base.readonlydiff) >= size); 
    248223        } 
    249224        else { 
     
    257232#endif 
    258233            shm->ptr_ro = NULL; 
    259             shm->diff = 0; 
     234            shm->base.readonlydiff = 0; 
    260235        } 
    261236    } 
     
    309284/* }}} */ 
    310285 
    311 static xc_shm_handlers_t xc_shm_mmap_handlers = XC_SHM_HANDLERS(mmap); 
     286static xc_shm_vtable_t xc_shm_mmap_vtable = XC_SHM_VTABLE(mmap); 
    312287void xc_shm_mmap_register() /* {{{ */ 
    313288{ 
    314     if (xc_shm_scheme_register("mmap", &xc_shm_mmap_handlers) == 0) { 
     289    if (xc_shm_scheme_register("mmap", &xc_shm_mmap_vtable) == 0) { 
    315290        zend_error(E_ERROR, "XCache: failed to register mmap shm_scheme"); 
    316291    } 
Note: See TracChangeset for help on using the changeset viewer.