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