| [1] | 1 | #ifndef __XCACHE_H |
|---|
| 2 | #define __XCACHE_H |
|---|
| 3 | #define XCACHE_NAME "XCache" |
|---|
| [923] | 4 | #ifndef XCACHE_VERSION |
|---|
| [958] | 5 | # define XCACHE_VERSION "2.0.1-rc3" |
|---|
| [923] | 6 | #endif |
|---|
| [1] | 7 | #define XCACHE_AUTHOR "mOo" |
|---|
| [883] | 8 | #define XCACHE_COPYRIGHT "Copyright (c) 2005-2012" |
|---|
| [1] | 9 | #define XCACHE_URL "http://xcache.lighttpd.net" |
|---|
| [547] | 10 | #define XCACHE_WIKI_URL XCACHE_URL "/wiki" |
|---|
| [1] | 11 | |
|---|
| 12 | #include <php.h> |
|---|
| 13 | #include <zend_compile.h> |
|---|
| 14 | #include <zend_API.h> |
|---|
| [485] | 15 | #include <zend.h> |
|---|
| [1] | 16 | #include "php_ini.h" |
|---|
| 17 | #include "zend_hash.h" |
|---|
| 18 | |
|---|
| 19 | #ifdef HAVE_CONFIG_H |
|---|
| 20 | #include <config.h> |
|---|
| 21 | #endif |
|---|
| [148] | 22 | #include "xc_shm.h" |
|---|
| [1] | 23 | #include "lock.h" |
|---|
| 24 | |
|---|
| [165] | 25 | #define HAVE_INODE |
|---|
| [822] | 26 | #if !defined(ZEND_ENGINE_2_4) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4 || PHP_MAJOR_VERSION > 5) |
|---|
| [716] | 27 | # define ZEND_ENGINE_2_4 |
|---|
| [1] | 28 | #endif |
|---|
| [716] | 29 | #if !defined(ZEND_ENGINE_2_3) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 3 || defined(ZEND_ENGINE_2_4)) |
|---|
| 30 | # define ZEND_ENGINE_2_3 |
|---|
| 31 | #endif |
|---|
| 32 | #if !defined(ZEND_ENGINE_2_2) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 || defined(ZEND_ENGINE_2_3)) |
|---|
| [78] | 33 | # define ZEND_ENGINE_2_2 |
|---|
| 34 | #endif |
|---|
| [716] | 35 | #if !defined(ZEND_ENGINE_2_1) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 || defined(ZEND_ENGINE_2_2)) |
|---|
| 36 | # define ZEND_ENGINE_2_1 |
|---|
| [480] | 37 | #endif |
|---|
| [1] | 38 | |
|---|
| [19] | 39 | #define NOTHING |
|---|
| [1] | 40 | /* ZendEngine code Switcher */ |
|---|
| 41 | #ifndef ZEND_ENGINE_2 |
|---|
| 42 | # define ZESW(v1, v2) v1 |
|---|
| 43 | #else |
|---|
| 44 | # define ZESW(v1, v2) v2 |
|---|
| 45 | #endif |
|---|
| [846] | 46 | #ifdef ZEND_ENGINE_2_4 |
|---|
| [860] | 47 | # define ZEND_24(pre24, v24) v24 |
|---|
| [846] | 48 | #else |
|---|
| [860] | 49 | # define ZEND_24(pre24, v24) pre24 |
|---|
| [846] | 50 | #endif |
|---|
| [1] | 51 | |
|---|
| [550] | 52 | #ifdef do_alloca_with_limit |
|---|
| 53 | # define my_do_alloca(size, use_heap) do_alloca_with_limit(size, use_heap) |
|---|
| 54 | # define my_free_alloca(size, use_heap) free_alloca_with_limit(size, use_heap) |
|---|
| 55 | #elif defined(ALLOCA_FLAG) |
|---|
| [485] | 56 | # define my_do_alloca(size, use_heap) do_alloca(size, use_heap) |
|---|
| 57 | # define my_free_alloca(size, use_heap) free_alloca(size, use_heap) |
|---|
| 58 | #else |
|---|
| 59 | # define my_do_alloca(size, use_heap) do_alloca(size) |
|---|
| 60 | # define my_free_alloca(size, use_heap) free_alloca(size) |
|---|
| 61 | # define ALLOCA_FLAG(x) |
|---|
| 62 | #endif |
|---|
| [798] | 63 | #ifndef Z_ISREF |
|---|
| 64 | # define Z_ISREF(z) (z).is_ref |
|---|
| 65 | #endif |
|---|
| [485] | 66 | #ifndef Z_SET_ISREF |
|---|
| [562] | 67 | # define Z_SET_ISREF(z) (z).is_ref = 1 |
|---|
| [485] | 68 | #endif |
|---|
| 69 | #ifndef Z_UNSET_ISREF |
|---|
| [562] | 70 | # define Z_UNSET_ISREF(z) (z).is_ref = 0 |
|---|
| [485] | 71 | #endif |
|---|
| [798] | 72 | #ifndef Z_REFCOUNT |
|---|
| 73 | # define Z_REFCOUNT(z) (z).refcount |
|---|
| 74 | #endif |
|---|
| [485] | 75 | #ifndef Z_SET_REFCOUNT |
|---|
| [562] | 76 | # define Z_SET_REFCOUNT(z, rc) (z).refcount = rc |
|---|
| [485] | 77 | #endif |
|---|
| [491] | 78 | #ifndef IS_CONSTANT_TYPE_MASK |
|---|
| [649] | 79 | # define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) |
|---|
| [491] | 80 | #endif |
|---|
| [485] | 81 | |
|---|
| [263] | 82 | /* {{{ dirty fix for PHP 6 */ |
|---|
| 83 | #ifdef add_assoc_long_ex |
|---|
| 84 | static inline void my_add_assoc_long_ex(zval *arg, char *key, uint key_len, long value) |
|---|
| 85 | { |
|---|
| 86 | add_assoc_long_ex(arg, key, key_len, value); |
|---|
| 87 | } |
|---|
| 88 | # undef add_assoc_long_ex |
|---|
| 89 | # define add_assoc_long_ex my_add_assoc_long_ex |
|---|
| 90 | #endif |
|---|
| 91 | #ifdef add_assoc_bool_ex |
|---|
| 92 | static inline void my_add_assoc_bool_ex(zval *arg, char *key, uint key_len, zend_bool value) |
|---|
| 93 | { |
|---|
| 94 | add_assoc_bool_ex(arg, key, key_len, value); |
|---|
| 95 | } |
|---|
| 96 | # undef add_assoc_bool_ex |
|---|
| 97 | # define add_assoc_bool_ex my_add_assoc_bool_ex |
|---|
| 98 | #endif |
|---|
| 99 | #ifdef add_assoc_null_ex |
|---|
| 100 | static inline void my_add_assoc_null_ex(zval *arg, char *key, uint key_len) |
|---|
| 101 | { |
|---|
| 102 | add_assoc_null_ex(arg, key, key_len); |
|---|
| 103 | } |
|---|
| 104 | # undef add_assoc_null_ex |
|---|
| 105 | # define add_assoc_null_ex my_add_assoc_null_ex |
|---|
| 106 | #endif |
|---|
| [716] | 107 | |
|---|
| 108 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 109 | # define Z_OP(op) (op) |
|---|
| 110 | # define Z_OP_CONSTANT(op) (op).literal->constant |
|---|
| 111 | # define Z_OP_TYPE(op) op##_##type |
|---|
| [769] | 112 | # define Z_OP_TYPEOF_TYPE zend_uchar |
|---|
| [716] | 113 | |
|---|
| 114 | # define Z_CLASS_INFO(className) (className).info.user |
|---|
| 115 | #else |
|---|
| 116 | # define Z_OP(op) (op).u |
|---|
| 117 | # define Z_OP_CONSTANT(op) (op).u.constant |
|---|
| 118 | # define Z_OP_TYPE(op) (op).op_type |
|---|
| [769] | 119 | # define Z_OP_TYPEOF_TYPE int |
|---|
| [716] | 120 | typedef znode znode_op; |
|---|
| 121 | |
|---|
| 122 | # define Z_CLASS_INFO(className) (className) |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| [263] | 125 | /* }}} */ |
|---|
| 126 | |
|---|
| [1] | 127 | /* unicode */ |
|---|
| 128 | #ifdef IS_UNICODE |
|---|
| 129 | # define UNISW(text, unicode) unicode |
|---|
| 130 | #else |
|---|
| 131 | # define UNISW(text, unicode) text |
|---|
| 132 | #endif |
|---|
| 133 | #define BUCKET_KEY_SIZE(b) \ |
|---|
| 134 | (UNISW( \ |
|---|
| 135 | (b)->nKeyLength, \ |
|---|
| 136 | ((b)->key.type == IS_UNICODE) \ |
|---|
| 137 | ? UBYTES(b->nKeyLength) \ |
|---|
| 138 | : b->nKeyLength \ |
|---|
| 139 | )) |
|---|
| [659] | 140 | #define BUCKET_KEY(b) (UNISW((b)->arKey, (b)->key.arKey)) |
|---|
| 141 | #define BUCKET_KEY_S(b) ZSTR_S(BUCKET_KEY(b)) |
|---|
| 142 | #define BUCKET_KEY_U(b) ZSTR_U(BUCKET_KEY(b)) |
|---|
| [200] | 143 | #define BUCKET_KEY_TYPE(b) (UNISW(IS_STRING, (b)->key.type)) |
|---|
| [2] | 144 | #ifdef IS_UNICODE |
|---|
| [104] | 145 | # define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, key.arKey) |
|---|
| [2] | 146 | #else |
|---|
| [11] | 147 | # define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, arKey) |
|---|
| [2] | 148 | #endif |
|---|
| [1] | 149 | |
|---|
| [823] | 150 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 151 | # define BUCKET_SIZE(b) (sizeof(Bucket) + BUCKET_KEY_SIZE(b)) |
|---|
| 152 | #else |
|---|
| 153 | # define BUCKET_SIZE(b) (BUCKET_HEAD_SIZE(b) + BUCKET_KEY_SIZE(b)) |
|---|
| 154 | #endif |
|---|
| 155 | |
|---|
| [1] | 156 | #ifndef IS_UNICODE |
|---|
| 157 | typedef char *zstr; |
|---|
| [770] | 158 | typedef const char *const_zstr; |
|---|
| [846] | 159 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 160 | typedef const char *const24_zstr; |
|---|
| 161 | typedef const char *const24_str; |
|---|
| 162 | #else |
|---|
| 163 | typedef char *const24_zstr; |
|---|
| 164 | typedef char *const24_str; |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| [103] | 167 | # define ZSTR_S(s) (s) |
|---|
| 168 | # define ZSTR_U(s) (s) |
|---|
| 169 | # define ZSTR_V(s) (s) |
|---|
| 170 | # define ZSTR_PS(s) (s) |
|---|
| 171 | # define ZSTR_PU(s) (s) |
|---|
| 172 | # define ZSTR_PV(s) (s) |
|---|
| [1] | 173 | #else |
|---|
| [770] | 174 | typedef const zstr const_zstr; |
|---|
| [103] | 175 | # define ZSTR_S(zs) ((zs).s) |
|---|
| 176 | # define ZSTR_U(zs) ((zs).u) |
|---|
| 177 | # define ZSTR_V(zs) ((zs).v) |
|---|
| 178 | # define ZSTR_PS(pzs) ((pzs)->s) |
|---|
| 179 | # define ZSTR_PU(pzs) ((pzs)->u) |
|---|
| 180 | # define ZSTR_PV(pzs) ((pzs)->v) |
|---|
| [1] | 181 | #endif |
|---|
| 182 | |
|---|
| [103] | 183 | #ifndef ZSTR |
|---|
| 184 | # define ZSTR(s) (s) |
|---|
| 185 | #endif |
|---|
| 186 | |
|---|
| 187 | #ifndef Z_UNIVAL |
|---|
| 188 | # define Z_UNIVAL(zval) (zval).value.str.val |
|---|
| 189 | # define Z_UNILEN(zval) (zval).value.str.len |
|---|
| 190 | #endif |
|---|
| 191 | |
|---|
| [1] | 192 | /* {{{ u hash wrapper */ |
|---|
| 193 | #ifndef IS_UNICODE |
|---|
| 194 | # define zend_u_hash_add(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \ |
|---|
| [860] | 195 | zend_hash_add(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData, nDataSize, pDest) |
|---|
| [1] | 196 | |
|---|
| [506] | 197 | # define zend_u_hash_quick_add(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \ |
|---|
| [860] | 198 | zend_hash_quick_add(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData, nDataSize, pDest) |
|---|
| [506] | 199 | |
|---|
| [88] | 200 | # define zend_u_hash_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \ |
|---|
| [860] | 201 | zend_hash_update(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData, nDataSize, pDest) |
|---|
| [88] | 202 | |
|---|
| [506] | 203 | # define zend_u_hash_quick_update(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \ |
|---|
| [860] | 204 | zend_hash_quick_update(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData, nDataSize, pDest) |
|---|
| [506] | 205 | |
|---|
| [1] | 206 | # define zend_u_hash_find(ht, type, arKey, nKeyLength, pData) \ |
|---|
| [860] | 207 | zend_hash_find(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData) |
|---|
| [1] | 208 | |
|---|
| [200] | 209 | # define zend_u_hash_quick_find(ht, type, arKey, nKeyLength, h, pData) \ |
|---|
| [860] | 210 | zend_hash_quick_find(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData) |
|---|
| [200] | 211 | |
|---|
| [860] | 212 | # define zend_u_hash_exists(ht, type, arKey, nKeyLength) \ |
|---|
| 213 | zend_hash_exists(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength) |
|---|
| 214 | |
|---|
| [1] | 215 | # define add_u_assoc_zval_ex(arg, type, key, key_len, value) \ |
|---|
| 216 | add_assoc_zval_ex(arg, key, key_len, value) |
|---|
| 217 | |
|---|
| [268] | 218 | # define zend_u_is_auto_global(type, name, name_len) \ |
|---|
| 219 | zend_is_auto_global(name, name_len) |
|---|
| [1] | 220 | #endif |
|---|
| 221 | /* }}} */ |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | #define ECALLOC_N(x, n) ((x) = ecalloc(n, sizeof((x)[0]))) |
|---|
| 225 | #define ECALLOC_ONE(x) ECALLOC_N(x, 1) |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | typedef ulong xc_hash_value_t; |
|---|
| 230 | typedef struct { |
|---|
| [917] | 231 | size_t bits; |
|---|
| 232 | size_t size; |
|---|
| 233 | xc_hash_value_t mask; |
|---|
| [1] | 234 | } xc_hash_t; |
|---|
| 235 | |
|---|
| 236 | /* the class entry type to be stored in class_table */ |
|---|
| 237 | typedef ZESW(zend_class_entry, zend_class_entry*) xc_cest_t; |
|---|
| 238 | |
|---|
| 239 | /* xc_cest_t to (zend_class_entry*) */ |
|---|
| 240 | #define CestToCePtr(st) (ZESW(\ |
|---|
| 241 | &(st), \ |
|---|
| 242 | st \ |
|---|
| 243 | ) ) |
|---|
| 244 | |
|---|
| 245 | /* ZCEP=zend class entry ptr */ |
|---|
| 246 | #define ZCEP_REFCOUNT_PTR(pce) (ZESW( \ |
|---|
| 247 | (pce)->refcount, \ |
|---|
| 248 | &((pce)->refcount) \ |
|---|
| 249 | )) |
|---|
| 250 | |
|---|
| 251 | #define ZCE_REFCOUNT_PTR(ce) ZCE_REFCOUNT_PTR(&ce) |
|---|
| 252 | |
|---|
| 253 | typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC); |
|---|
| 254 | |
|---|
| [311] | 255 | typedef struct _xc_entry_t xc_entry_t; |
|---|
| 256 | typedef struct _xc_entry_data_php_t xc_entry_data_php_t; |
|---|
| [1] | 257 | /* {{{ xc_cache_t */ |
|---|
| [11] | 258 | typedef struct { |
|---|
| [1] | 259 | int cacheid; |
|---|
| 260 | xc_hash_t *hcache; /* hash to cacheid */ |
|---|
| 261 | |
|---|
| [11] | 262 | time_t compiling; |
|---|
| [936] | 263 | zend_ulong updates; |
|---|
| [1] | 264 | zend_ulong hits; |
|---|
| 265 | zend_ulong clogs; |
|---|
| 266 | zend_ulong ooms; |
|---|
| [456] | 267 | zend_ulong errors; |
|---|
| [1] | 268 | xc_lock_t *lck; |
|---|
| [851] | 269 | xc_shm_t *shm; /* which shm contains us */ |
|---|
| 270 | xc_mem_t *mem; /* which mem contains us */ |
|---|
| [1] | 271 | |
|---|
| 272 | xc_entry_t **entries; |
|---|
| [32] | 273 | int entries_count; |
|---|
| [311] | 274 | xc_entry_data_php_t **phps; |
|---|
| 275 | int phps_count; |
|---|
| [1] | 276 | xc_entry_t *deletes; |
|---|
| [32] | 277 | int deletes_count; |
|---|
| [311] | 278 | xc_hash_t *hentry; /* hash settings to entry */ |
|---|
| 279 | xc_hash_t *hphp; /* hash settings to php */ |
|---|
| [114] | 280 | |
|---|
| 281 | time_t last_gc_deletes; |
|---|
| 282 | time_t last_gc_expires; |
|---|
| [522] | 283 | |
|---|
| 284 | time_t hits_by_hour_cur_time; |
|---|
| 285 | zend_uint hits_by_hour_cur_slot; |
|---|
| 286 | zend_ulong hits_by_hour[24]; |
|---|
| 287 | time_t hits_by_second_cur_time; |
|---|
| 288 | zend_uint hits_by_second_cur_slot; |
|---|
| 289 | zend_ulong hits_by_second[5]; |
|---|
| [1] | 290 | } xc_cache_t; |
|---|
| 291 | /* }}} */ |
|---|
| [832] | 292 | /* {{{ xc_op_array_info_detail_t */ |
|---|
| 293 | typedef struct { |
|---|
| 294 | zend_uint index; |
|---|
| 295 | zend_uint info; |
|---|
| 296 | } xc_op_array_info_detail_t; |
|---|
| 297 | /* }}} */ |
|---|
| [662] | 298 | /* {{{ xc_op_array_info_t */ |
|---|
| 299 | typedef struct { |
|---|
| [721] | 300 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 301 | zend_uint literalinfo_cnt; |
|---|
| [832] | 302 | xc_op_array_info_detail_t *literalinfos; |
|---|
| [721] | 303 | #else |
|---|
| [662] | 304 | zend_uint oplineinfo_cnt; |
|---|
| [832] | 305 | xc_op_array_info_detail_t *oplineinfos; |
|---|
| [721] | 306 | #endif |
|---|
| [662] | 307 | } xc_op_array_info_t; |
|---|
| 308 | /* }}} */ |
|---|
| [1] | 309 | /* {{{ xc_classinfo_t */ |
|---|
| 310 | typedef struct { |
|---|
| [14] | 311 | #ifdef IS_UNICODE |
|---|
| [846] | 312 | zend_uchar type; |
|---|
| [14] | 313 | #endif |
|---|
| [846] | 314 | const24_zstr key; |
|---|
| 315 | zend_uint key_size; |
|---|
| 316 | ulong h; |
|---|
| 317 | zend_uint methodinfo_cnt; |
|---|
| [662] | 318 | xc_op_array_info_t *methodinfos; |
|---|
| [846] | 319 | xc_cest_t cest; |
|---|
| [548] | 320 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| [846] | 321 | int oplineno; |
|---|
| [548] | 322 | #endif |
|---|
| [1] | 323 | } xc_classinfo_t; |
|---|
| 324 | /* }}} */ |
|---|
| [95] | 325 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 326 | /* {{{ xc_constinfo_t */ |
|---|
| 327 | typedef struct { |
|---|
| 328 | #ifdef IS_UNICODE |
|---|
| [846] | 329 | zend_uchar type; |
|---|
| [95] | 330 | #endif |
|---|
| [846] | 331 | const24_zstr key; |
|---|
| 332 | zend_uint key_size; |
|---|
| 333 | ulong h; |
|---|
| [95] | 334 | zend_constant constant; |
|---|
| 335 | } xc_constinfo_t; |
|---|
| 336 | /* }}} */ |
|---|
| 337 | #endif |
|---|
| [1] | 338 | /* {{{ xc_funcinfo_t */ |
|---|
| 339 | typedef struct { |
|---|
| [14] | 340 | #ifdef IS_UNICODE |
|---|
| [846] | 341 | zend_uchar type; |
|---|
| [14] | 342 | #endif |
|---|
| [846] | 343 | const24_zstr key; |
|---|
| 344 | zend_uint key_size; |
|---|
| 345 | ulong h; |
|---|
| [662] | 346 | xc_op_array_info_t op_array_info; |
|---|
| [1] | 347 | zend_function func; |
|---|
| 348 | } xc_funcinfo_t; |
|---|
| 349 | /* }}} */ |
|---|
| [268] | 350 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 351 | /* {{{ xc_autoglobal_t */ |
|---|
| 352 | typedef struct { |
|---|
| 353 | #ifdef IS_UNICODE |
|---|
| [846] | 354 | zend_uchar type; |
|---|
| [268] | 355 | #endif |
|---|
| [846] | 356 | const24_zstr key; |
|---|
| 357 | zend_uint key_len; |
|---|
| 358 | ulong h; |
|---|
| [268] | 359 | } xc_autoglobal_t; |
|---|
| 360 | /* }}} */ |
|---|
| 361 | #endif |
|---|
| [840] | 362 | typedef struct { |
|---|
| 363 | char digest[16]; |
|---|
| 364 | } xc_md5sum_t; |
|---|
| [496] | 365 | /* {{{ xc_compilererror_t */ |
|---|
| 366 | typedef struct { |
|---|
| [648] | 367 | int type; |
|---|
| [496] | 368 | uint lineno; |
|---|
| 369 | int error_len; |
|---|
| 370 | char *error; |
|---|
| 371 | } xc_compilererror_t; |
|---|
| 372 | /* }}} */ |
|---|
| [1] | 373 | /* {{{ xc_entry_data_php_t */ |
|---|
| [311] | 374 | struct _xc_entry_data_php_t { |
|---|
| 375 | xc_entry_data_php_t *next; |
|---|
| [854] | 376 | xc_hash_value_t hvalue; |
|---|
| [311] | 377 | |
|---|
| 378 | xc_md5sum_t md5; /* md5sum of the source */ |
|---|
| 379 | zend_ulong refcount; /* count of entries referencing to this data */ |
|---|
| 380 | |
|---|
| 381 | zend_ulong hits; /* hits of this php */ |
|---|
| 382 | size_t size; |
|---|
| [1] | 383 | |
|---|
| [662] | 384 | xc_op_array_info_t op_array_info; |
|---|
| [1] | 385 | zend_op_array *op_array; |
|---|
| 386 | |
|---|
| [95] | 387 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 388 | zend_uint constinfo_cnt; |
|---|
| 389 | xc_constinfo_t *constinfos; |
|---|
| 390 | #endif |
|---|
| 391 | |
|---|
| [1] | 392 | zend_uint funcinfo_cnt; |
|---|
| 393 | xc_funcinfo_t *funcinfos; |
|---|
| 394 | |
|---|
| 395 | zend_uint classinfo_cnt; |
|---|
| 396 | xc_classinfo_t *classinfos; |
|---|
| [548] | 397 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| [212] | 398 | zend_bool have_early_binding; |
|---|
| [548] | 399 | #endif |
|---|
| [268] | 400 | |
|---|
| 401 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 402 | zend_uint autoglobal_cnt; |
|---|
| 403 | xc_autoglobal_t *autoglobals; |
|---|
| 404 | #endif |
|---|
| [311] | 405 | |
|---|
| [496] | 406 | #ifdef E_STRICT |
|---|
| 407 | zend_uint compilererror_cnt; |
|---|
| 408 | xc_compilererror_t *compilererrors; |
|---|
| 409 | #endif |
|---|
| 410 | |
|---|
| [311] | 411 | zend_bool have_references; |
|---|
| 412 | }; |
|---|
| [1] | 413 | /* }}} */ |
|---|
| 414 | typedef zvalue_value xc_entry_name_t; |
|---|
| 415 | /* {{{ xc_entry_t */ |
|---|
| 416 | struct _xc_entry_t { |
|---|
| [854] | 417 | xc_entry_t *next; |
|---|
| [1] | 418 | |
|---|
| [854] | 419 | size_t size; |
|---|
| [851] | 420 | time_t ctime; /* creation ctime of this entry */ |
|---|
| 421 | time_t atime; /* access atime of this entry */ |
|---|
| 422 | time_t dtime; /* deletion time of this entry */ |
|---|
| [1] | 423 | zend_ulong hits; |
|---|
| [917] | 424 | zend_ulong ttl; |
|---|
| [1] | 425 | |
|---|
| 426 | xc_entry_name_t name; |
|---|
| [851] | 427 | }; |
|---|
| [233] | 428 | |
|---|
| [851] | 429 | typedef struct { |
|---|
| 430 | xc_entry_t entry; |
|---|
| [854] | 431 | xc_entry_data_php_t *php; |
|---|
| [851] | 432 | |
|---|
| 433 | zend_ulong refcount; /* count of php instances holding this entry */ |
|---|
| 434 | time_t file_mtime; |
|---|
| [859] | 435 | size_t file_size; |
|---|
| [311] | 436 | #ifdef HAVE_INODE |
|---|
| [851] | 437 | int file_device; |
|---|
| 438 | int file_inode; |
|---|
| [311] | 439 | #endif |
|---|
| [684] | 440 | |
|---|
| 441 | int filepath_len; |
|---|
| [860] | 442 | ZEND_24(NOTHING, const) char *filepath; |
|---|
| [684] | 443 | int dirpath_len; |
|---|
| 444 | char *dirpath; |
|---|
| 445 | #ifdef IS_UNICODE |
|---|
| [851] | 446 | int ufilepath_len; |
|---|
| [684] | 447 | UChar *ufilepath; |
|---|
| [851] | 448 | int udirpath_len; |
|---|
| [684] | 449 | UChar *udirpath; |
|---|
| 450 | #endif |
|---|
| [851] | 451 | } xc_entry_php_t; |
|---|
| [855] | 452 | |
|---|
| [854] | 453 | typedef struct { |
|---|
| 454 | xc_entry_t entry; |
|---|
| [866] | 455 | #ifdef IS_UNICODE |
|---|
| 456 | zend_uchar name_type; |
|---|
| 457 | #endif |
|---|
| [854] | 458 | zval *value; |
|---|
| 459 | zend_bool have_references; |
|---|
| 460 | } xc_entry_var_t; |
|---|
| 461 | /* }}} */ |
|---|
| 462 | typedef struct xc_entry_hash_t { /* {{{ */ |
|---|
| [859] | 463 | xc_hash_value_t cacheid; |
|---|
| [854] | 464 | xc_hash_value_t entryslotid; |
|---|
| 465 | } xc_entry_hash_t; |
|---|
| 466 | /* }}} */ |
|---|
| [1] | 467 | |
|---|
| 468 | extern zend_module_entry xcache_module_entry; |
|---|
| 469 | #define phpext_xcache_ptr &xcache_module_entry |
|---|
| 470 | |
|---|
| 471 | int xc_is_rw(const void *p); |
|---|
| 472 | int xc_is_ro(const void *p); |
|---|
| 473 | int xc_is_shm(const void *p); |
|---|
| [662] | 474 | /* {{{ xc_gc_op_array_t */ |
|---|
| 475 | typedef struct { |
|---|
| 476 | #ifdef ZEND_ENGINE_2 |
|---|
| 477 | zend_uint num_args; |
|---|
| 478 | zend_arg_info *arg_info; |
|---|
| 479 | #endif |
|---|
| 480 | zend_op *opcodes; |
|---|
| 481 | } xc_gc_op_array_t; |
|---|
| 482 | /* }}} */ |
|---|
| 483 | void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC); |
|---|
| [851] | 484 | void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC); |
|---|
| [1] | 485 | |
|---|
| 486 | #endif /* __XCACHE_H */ |
|---|