XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.7 KiB

  1. #include "xc_shm.h"
  2. typedef struct _xc_mem_handlers_t xc_mem_handlers_t;
  3. #ifndef XC_MEM_IMPL
  4. struct _xc_mem_t {
  5. const xc_mem_handlers_t *handlers;
  6. xc_shm_t *shm;
  7. };
  8. # define XC_MEM_IMPL _xc_mem_t
  9. #endif
  10. #ifndef XC_MEMBLOCK_IMPL
  11. # define XC_MEMBLOCK_IMPL _xc_block_t
  12. #endif
  13. typedef struct XC_MEM_IMPL xc_mem_t;
  14. typedef struct XC_MEMBLOCK_IMPL xc_block_t;
  15. typedef xc_shmsize_t xc_memsize_t;
  16. /* shm::mem */
  17. #define XC_MEM_MALLOC(func) void *func(xc_mem_t *mem, xc_memsize_t size)
  18. #define XC_MEM_FREE(func) xc_memsize_t func(xc_mem_t *mem, const void *p)
  19. #define XC_MEM_CALLOC(func) void *func(xc_mem_t *mem, xc_memsize_t memb, xc_memsize_t size)
  20. #define XC_MEM_REALLOC(func) void *func(xc_mem_t *mem, const void *p, xc_memsize_t size)
  21. #define XC_MEM_STRNDUP(func) char *func(xc_mem_t *mem, const char *str, xc_memsize_t len)
  22. #define XC_MEM_STRDUP(func) char *func(xc_mem_t *mem, const char *str)
  23. #define XC_MEM_AVAIL(func) xc_memsize_t func(xc_mem_t *mem)
  24. #define XC_MEM_SIZE(func) xc_memsize_t func(xc_mem_t *mem)
  25. #define XC_MEM_FREEBLOCK_FIRST(func) const xc_block_t *func(xc_mem_t *mem)
  26. #define XC_MEM_FREEBLOCK_NEXT(func) const xc_block_t *func(const xc_block_t *block)
  27. #define XC_MEM_BLOCK_SIZE(func) xc_memsize_t func(const xc_block_t *block)
  28. #define XC_MEM_BLOCK_OFFSET(func) xc_memsize_t func(const xc_mem_t *mem, const xc_block_t *block)
  29. #define XC_MEM_INIT(func) xc_mem_t *func(xc_shm_t *shm, xc_mem_t *mem, xc_memsize_t size)
  30. #define XC_MEM_DESTROY(func) void func(xc_mem_t *mem)
  31. #define XC_MEM_HANDLERS(name) { \
  32. xc_##name##_malloc \
  33. , xc_##name##_free \
  34. , xc_##name##_calloc \
  35. , xc_##name##_realloc \
  36. , xc_##name##_strndup \
  37. , xc_##name##_strdup \
  38. , xc_##name##_avail \
  39. , xc_##name##_size \
  40. , xc_##name##_freeblock_first \
  41. , xc_##name##_freeblock_next \
  42. , xc_##name##_block_size \
  43. , xc_##name##_block_offset \
  44. \
  45. , xc_##name##_init \
  46. , xc_##name##_destroy \
  47. }
  48. struct _xc_mem_handlers_t {
  49. XC_MEM_MALLOC((*malloc));
  50. XC_MEM_FREE((*free));
  51. XC_MEM_CALLOC((*calloc));
  52. XC_MEM_REALLOC((*realloc));
  53. XC_MEM_STRNDUP((*strndup));
  54. XC_MEM_STRDUP((*strdup));
  55. XC_MEM_AVAIL((*avail));
  56. XC_MEM_SIZE((*size));
  57. XC_MEM_FREEBLOCK_FIRST((*freeblock_first));
  58. XC_MEM_FREEBLOCK_NEXT((*freeblock_next));
  59. XC_MEM_BLOCK_SIZE((*block_size));
  60. XC_MEM_BLOCK_OFFSET((*block_offset));
  61. XC_MEM_INIT((*init));
  62. XC_MEM_DESTROY((*destroy));
  63. };
  64. int xc_mem_scheme_register(const char *name, const xc_mem_handlers_t *handlers);
  65. const xc_mem_handlers_t *xc_mem_scheme_find(const char *name);