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.

66 lines
2.5 KiB

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