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.
 
 
 
 
 
 

226 lines
4.9 KiB

  1. #ifndef XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
  2. #define XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif /* _MSC_VER > 1000 */
  6. #include "xcache.h"
  7. #include "xcache/xc_compatibility.h"
  8. typedef ulong xc_hash_value_t;
  9. typedef struct _xc_hash_t xc_hash_t;
  10. typedef struct _xc_cached_t xc_cached_t;
  11. typedef struct _xc_entry_t xc_entry_t;
  12. typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
  13. struct _xc_lock_t;
  14. struct _xc_shm_t;
  15. /* {{{ xc_constant_info_t */
  16. typedef struct {
  17. zend_uint index;
  18. zend_uint info;
  19. } xc_constant_info_t;
  20. /* }}} */
  21. /* {{{ xc_op_array_info_t */
  22. typedef struct {
  23. zend_uint constantinfo_cnt;
  24. xc_constant_info_t *constantinfos;
  25. } xc_op_array_info_t;
  26. /* }}} */
  27. /* {{{ xc_classinfo_t */
  28. typedef struct {
  29. #ifdef IS_UNICODE
  30. zend_uchar type;
  31. #endif
  32. const24_zstr key;
  33. zend_uint key_size;
  34. ulong h;
  35. zend_uint methodinfo_cnt;
  36. xc_op_array_info_t *methodinfos;
  37. #ifdef ZEND_ENGINE_2
  38. zend_uint constantinfo_cnt;
  39. xc_constant_info_t *constantinfos;
  40. #endif
  41. xc_cest_t cest;
  42. #ifndef ZEND_COMPILE_DELAYED_BINDING
  43. int oplineno;
  44. #endif
  45. } xc_classinfo_t;
  46. /* }}} */
  47. #ifdef HAVE_XCACHE_CONSTANT
  48. /* {{{ xc_constinfo_t */
  49. typedef struct {
  50. #ifdef IS_UNICODE
  51. zend_uchar type;
  52. #endif
  53. const24_zstr key;
  54. zend_uint key_size;
  55. ulong h;
  56. zend_constant constant;
  57. } xc_constinfo_t;
  58. /* }}} */
  59. #endif
  60. /* {{{ xc_funcinfo_t */
  61. typedef struct {
  62. #ifdef IS_UNICODE
  63. zend_uchar type;
  64. #endif
  65. const24_zstr key;
  66. zend_uint key_size;
  67. ulong h;
  68. xc_op_array_info_t op_array_info;
  69. zend_function func;
  70. } xc_funcinfo_t;
  71. /* }}} */
  72. #ifdef ZEND_ENGINE_2_1
  73. /* {{{ xc_autoglobal_t */
  74. typedef struct {
  75. #ifdef IS_UNICODE
  76. zend_uchar type;
  77. #endif
  78. const24_zstr key;
  79. zend_uint key_len;
  80. ulong h;
  81. } xc_autoglobal_t;
  82. /* }}} */
  83. #endif
  84. typedef struct {
  85. char digest[16];
  86. } xc_md5sum_t;
  87. struct _xc_compilererror_t;
  88. /* {{{ xc_entry_data_php_t */
  89. struct _xc_entry_data_php_t {
  90. xc_entry_data_php_t *next;
  91. xc_hash_value_t hvalue;
  92. xc_md5sum_t md5; /* md5sum of the source */
  93. zend_ulong refcount; /* count of entries referencing to this data */
  94. zend_ulong hits; /* hits of this php */
  95. size_t size;
  96. xc_op_array_info_t op_array_info;
  97. zend_op_array *op_array;
  98. #ifdef HAVE_XCACHE_CONSTANT
  99. zend_uint constinfo_cnt;
  100. xc_constinfo_t *constinfos;
  101. #endif
  102. zend_uint funcinfo_cnt;
  103. xc_funcinfo_t *funcinfos;
  104. zend_uint classinfo_cnt;
  105. xc_classinfo_t *classinfos;
  106. #ifndef ZEND_COMPILE_DELAYED_BINDING
  107. zend_bool have_early_binding;
  108. #endif
  109. #ifdef ZEND_ENGINE_2_1
  110. zend_uint autoglobal_cnt;
  111. xc_autoglobal_t *autoglobals;
  112. #endif
  113. #ifdef XCACHE_ERROR_CACHING
  114. zend_uint compilererror_cnt;
  115. struct _xc_compilererror_t *compilererrors;
  116. #endif
  117. zend_bool have_references;
  118. };
  119. /* }}} */
  120. typedef zvalue_value xc_entry_name_t;
  121. /* {{{ xc_entry_t */
  122. struct _xc_entry_t {
  123. xc_entry_t *next;
  124. size_t size;
  125. time_t ctime; /* creation ctime of this entry */
  126. time_t atime; /* access atime of this entry */
  127. time_t dtime; /* deletion time of this entry */
  128. zend_ulong hits;
  129. zend_ulong ttl;
  130. xc_entry_name_t name;
  131. };
  132. typedef struct {
  133. char *str;
  134. size_t len;
  135. } xc_constant_string_t;
  136. #ifdef IS_UNICODE
  137. typedef struct {
  138. UChar *str;
  139. size_t len;
  140. } xc_constant_u_string_t;
  141. #endif
  142. typedef struct {
  143. xc_entry_t entry;
  144. xc_entry_data_php_t *php;
  145. zend_ulong refcount; /* count of php instances holding this entry */
  146. time_t file_mtime;
  147. size_t file_size;
  148. size_t file_device;
  149. size_t file_inode;
  150. xc_constant_string_t filepath;
  151. #ifdef ZEND_ENGINE_2_3
  152. xc_constant_string_t dirpath;
  153. #endif
  154. #ifdef IS_UNICODE
  155. xc_constant_u_string_t u_filepath;
  156. xc_constant_u_string_t u_dirpath;
  157. #endif
  158. } xc_entry_php_t;
  159. typedef struct {
  160. xc_entry_t entry;
  161. #ifdef IS_UNICODE
  162. zend_uchar name_type;
  163. #endif
  164. zval *value;
  165. #ifdef ZEND_ENGINE_2
  166. zend_uint objects_count;
  167. zend_object *objects;
  168. #endif
  169. zend_uint class_names_count;
  170. xc_constant_string_t *class_names;
  171. zend_bool have_references;
  172. } xc_entry_var_t;
  173. /* }}} */
  174. typedef struct xc_entry_hash_t { /* {{{ */
  175. xc_hash_value_t cacheid;
  176. xc_hash_value_t entryslotid;
  177. } xc_entry_hash_t;
  178. /* }}} */
  179. zend_bool xc_is_rw(const void *p);
  180. zend_bool xc_is_ro(const void *p);
  181. zend_bool xc_is_shm(const void *p);
  182. /* {{{ xc_gc_op_array_t */
  183. typedef struct {
  184. #ifdef ZEND_ENGINE_2
  185. zend_uint num_args;
  186. zend_arg_info *arg_info;
  187. #endif
  188. #ifdef ZEND_ENGINE_2_4
  189. zend_literal *literals;
  190. #endif
  191. zend_op *opcodes;
  192. } xc_gc_op_array_t;
  193. /* }}} */
  194. void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
  195. #ifdef ZEND_ENGINE_2
  196. void xc_fix_class_info(const xc_entry_php_t *entry_php, xc_classinfo_t *classinfo, int shallow_copy TSRMLS_DC);
  197. #endif
  198. void xc_fix_op_array_info(const xc_entry_php_t *xce, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);
  199. #endif /* XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE */