| [1051] | 1 | #ifndef XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE |
|---|
| 2 | #define XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE |
|---|
| 3 | |
|---|
| 4 | #if _MSC_VER > 1000 |
|---|
| 5 | #pragma once |
|---|
| 6 | #endif /* _MSC_VER > 1000 */ |
|---|
| 7 | |
|---|
| 8 | #include "xcache.h" |
|---|
| 9 | #include "xcache/xc_compatibility.h" |
|---|
| 10 | |
|---|
| 11 | typedef ulong xc_hash_value_t; |
|---|
| 12 | typedef struct _xc_hash_t xc_hash_t; |
|---|
| 13 | typedef struct _xc_entry_t xc_entry_t; |
|---|
| 14 | typedef struct _xc_entry_data_php_t xc_entry_data_php_t; |
|---|
| 15 | |
|---|
| 16 | struct _xc_lock_t; |
|---|
| 17 | struct _xc_shm_t; |
|---|
| 18 | /* {{{ xc_cache_t */ |
|---|
| 19 | typedef struct { |
|---|
| 20 | int cacheid; |
|---|
| 21 | xc_hash_t *hcache; /* hash to cacheid */ |
|---|
| 22 | |
|---|
| 23 | time_t compiling; |
|---|
| 24 | zend_ulong updates; |
|---|
| 25 | zend_ulong hits; |
|---|
| 26 | zend_ulong clogs; |
|---|
| 27 | zend_ulong ooms; |
|---|
| 28 | zend_ulong errors; |
|---|
| 29 | struct _xc_lock_t *lck; |
|---|
| 30 | struct _xc_shm_t *shm; /* which shm contains us */ |
|---|
| 31 | struct _xc_mem_t *mem; /* which mem contains us */ |
|---|
| 32 | |
|---|
| 33 | xc_entry_t **entries; |
|---|
| 34 | int entries_count; |
|---|
| 35 | xc_entry_data_php_t **phps; |
|---|
| 36 | int phps_count; |
|---|
| 37 | xc_entry_t *deletes; |
|---|
| 38 | int deletes_count; |
|---|
| 39 | xc_hash_t *hentry; /* hash settings to entry */ |
|---|
| 40 | xc_hash_t *hphp; /* hash settings to php */ |
|---|
| 41 | |
|---|
| 42 | time_t last_gc_deletes; |
|---|
| 43 | time_t last_gc_expires; |
|---|
| 44 | |
|---|
| 45 | time_t hits_by_hour_cur_time; |
|---|
| 46 | zend_uint hits_by_hour_cur_slot; |
|---|
| 47 | zend_ulong hits_by_hour[24]; |
|---|
| 48 | time_t hits_by_second_cur_time; |
|---|
| 49 | zend_uint hits_by_second_cur_slot; |
|---|
| 50 | zend_ulong hits_by_second[5]; |
|---|
| 51 | } xc_cache_t; |
|---|
| 52 | /* }}} */ |
|---|
| 53 | /* {{{ xc_op_array_info_detail_t */ |
|---|
| 54 | typedef struct { |
|---|
| 55 | zend_uint index; |
|---|
| 56 | zend_uint info; |
|---|
| 57 | } xc_op_array_info_detail_t; |
|---|
| 58 | /* }}} */ |
|---|
| 59 | /* {{{ xc_op_array_info_t */ |
|---|
| 60 | typedef struct { |
|---|
| 61 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 62 | zend_uint literalinfo_cnt; |
|---|
| 63 | xc_op_array_info_detail_t *literalinfos; |
|---|
| 64 | #else |
|---|
| 65 | zend_uint oplineinfo_cnt; |
|---|
| 66 | xc_op_array_info_detail_t *oplineinfos; |
|---|
| 67 | #endif |
|---|
| 68 | } xc_op_array_info_t; |
|---|
| 69 | /* }}} */ |
|---|
| 70 | /* {{{ xc_classinfo_t */ |
|---|
| 71 | typedef struct { |
|---|
| 72 | #ifdef IS_UNICODE |
|---|
| 73 | zend_uchar type; |
|---|
| 74 | #endif |
|---|
| 75 | const24_zstr key; |
|---|
| 76 | zend_uint key_size; |
|---|
| 77 | ulong h; |
|---|
| 78 | zend_uint methodinfo_cnt; |
|---|
| 79 | xc_op_array_info_t *methodinfos; |
|---|
| 80 | xc_cest_t cest; |
|---|
| 81 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 82 | int oplineno; |
|---|
| 83 | #endif |
|---|
| 84 | } xc_classinfo_t; |
|---|
| 85 | /* }}} */ |
|---|
| 86 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 87 | /* {{{ xc_constinfo_t */ |
|---|
| 88 | typedef struct { |
|---|
| 89 | #ifdef IS_UNICODE |
|---|
| 90 | zend_uchar type; |
|---|
| 91 | #endif |
|---|
| 92 | const24_zstr key; |
|---|
| 93 | zend_uint key_size; |
|---|
| 94 | ulong h; |
|---|
| 95 | zend_constant constant; |
|---|
| 96 | } xc_constinfo_t; |
|---|
| 97 | /* }}} */ |
|---|
| 98 | #endif |
|---|
| 99 | /* {{{ xc_funcinfo_t */ |
|---|
| 100 | typedef struct { |
|---|
| 101 | #ifdef IS_UNICODE |
|---|
| 102 | zend_uchar type; |
|---|
| 103 | #endif |
|---|
| 104 | const24_zstr key; |
|---|
| 105 | zend_uint key_size; |
|---|
| 106 | ulong h; |
|---|
| 107 | xc_op_array_info_t op_array_info; |
|---|
| 108 | zend_function func; |
|---|
| 109 | } xc_funcinfo_t; |
|---|
| 110 | /* }}} */ |
|---|
| 111 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 112 | /* {{{ xc_autoglobal_t */ |
|---|
| 113 | typedef struct { |
|---|
| 114 | #ifdef IS_UNICODE |
|---|
| 115 | zend_uchar type; |
|---|
| 116 | #endif |
|---|
| 117 | const24_zstr key; |
|---|
| 118 | zend_uint key_len; |
|---|
| 119 | ulong h; |
|---|
| 120 | } xc_autoglobal_t; |
|---|
| 121 | /* }}} */ |
|---|
| 122 | #endif |
|---|
| 123 | |
|---|
| 124 | typedef struct { |
|---|
| 125 | char digest[16]; |
|---|
| 126 | } xc_md5sum_t; |
|---|
| 127 | struct _xc_compilererror_t; |
|---|
| 128 | /* {{{ xc_entry_data_php_t */ |
|---|
| 129 | struct _xc_entry_data_php_t { |
|---|
| 130 | xc_entry_data_php_t *next; |
|---|
| 131 | xc_hash_value_t hvalue; |
|---|
| 132 | |
|---|
| 133 | xc_md5sum_t md5; /* md5sum of the source */ |
|---|
| 134 | zend_ulong refcount; /* count of entries referencing to this data */ |
|---|
| 135 | |
|---|
| 136 | zend_ulong hits; /* hits of this php */ |
|---|
| 137 | size_t size; |
|---|
| 138 | |
|---|
| 139 | xc_op_array_info_t op_array_info; |
|---|
| 140 | zend_op_array *op_array; |
|---|
| 141 | |
|---|
| 142 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 143 | zend_uint constinfo_cnt; |
|---|
| 144 | xc_constinfo_t *constinfos; |
|---|
| 145 | #endif |
|---|
| 146 | |
|---|
| 147 | zend_uint funcinfo_cnt; |
|---|
| 148 | xc_funcinfo_t *funcinfos; |
|---|
| 149 | |
|---|
| 150 | zend_uint classinfo_cnt; |
|---|
| 151 | xc_classinfo_t *classinfos; |
|---|
| 152 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 153 | zend_bool have_early_binding; |
|---|
| 154 | #endif |
|---|
| 155 | |
|---|
| 156 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 157 | zend_uint autoglobal_cnt; |
|---|
| 158 | xc_autoglobal_t *autoglobals; |
|---|
| 159 | #endif |
|---|
| 160 | |
|---|
| 161 | #ifdef XCACHE_ERROR_CACHING |
|---|
| 162 | zend_uint compilererror_cnt; |
|---|
| 163 | struct _xc_compilererror_t *compilererrors; |
|---|
| 164 | #endif |
|---|
| 165 | |
|---|
| 166 | zend_bool have_references; |
|---|
| 167 | }; |
|---|
| 168 | /* }}} */ |
|---|
| 169 | typedef zvalue_value xc_entry_name_t; |
|---|
| 170 | /* {{{ xc_entry_t */ |
|---|
| 171 | struct _xc_entry_t { |
|---|
| 172 | xc_entry_t *next; |
|---|
| 173 | |
|---|
| 174 | size_t size; |
|---|
| 175 | time_t ctime; /* creation ctime of this entry */ |
|---|
| 176 | time_t atime; /* access atime of this entry */ |
|---|
| 177 | time_t dtime; /* deletion time of this entry */ |
|---|
| 178 | zend_ulong hits; |
|---|
| 179 | zend_ulong ttl; |
|---|
| 180 | |
|---|
| 181 | xc_entry_name_t name; |
|---|
| 182 | }; |
|---|
| 183 | |
|---|
| 184 | typedef struct { |
|---|
| 185 | xc_entry_t entry; |
|---|
| 186 | xc_entry_data_php_t *php; |
|---|
| 187 | |
|---|
| 188 | zend_ulong refcount; /* count of php instances holding this entry */ |
|---|
| 189 | time_t file_mtime; |
|---|
| 190 | size_t file_size; |
|---|
| 191 | int file_device; |
|---|
| 192 | int file_inode; |
|---|
| 193 | |
|---|
| 194 | int filepath_len; |
|---|
| 195 | ZEND_24(NOTHING, const) char *filepath; |
|---|
| 196 | int dirpath_len; |
|---|
| 197 | char *dirpath; |
|---|
| 198 | #ifdef IS_UNICODE |
|---|
| 199 | int ufilepath_len; |
|---|
| 200 | UChar *ufilepath; |
|---|
| 201 | int udirpath_len; |
|---|
| 202 | UChar *udirpath; |
|---|
| 203 | #endif |
|---|
| 204 | } xc_entry_php_t; |
|---|
| 205 | |
|---|
| 206 | typedef struct { |
|---|
| 207 | xc_entry_t entry; |
|---|
| 208 | #ifdef IS_UNICODE |
|---|
| 209 | zend_uchar name_type; |
|---|
| 210 | #endif |
|---|
| 211 | zval *value; |
|---|
| 212 | zend_bool have_references; |
|---|
| 213 | } xc_entry_var_t; |
|---|
| 214 | /* }}} */ |
|---|
| 215 | typedef struct xc_entry_hash_t { /* {{{ */ |
|---|
| 216 | xc_hash_value_t cacheid; |
|---|
| 217 | xc_hash_value_t entryslotid; |
|---|
| 218 | } xc_entry_hash_t; |
|---|
| 219 | /* }}} */ |
|---|
| 220 | |
|---|
| 221 | int xc_is_rw(const void *p); |
|---|
| 222 | int xc_is_ro(const void *p); |
|---|
| 223 | int xc_is_shm(const void *p); |
|---|
| 224 | /* {{{ xc_gc_op_array_t */ |
|---|
| 225 | typedef struct { |
|---|
| 226 | #ifdef ZEND_ENGINE_2 |
|---|
| 227 | zend_uint num_args; |
|---|
| 228 | zend_arg_info *arg_info; |
|---|
| 229 | #endif |
|---|
| 230 | zend_op *opcodes; |
|---|
| 231 | } xc_gc_op_array_t; |
|---|
| 232 | /* }}} */ |
|---|
| 233 | void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC); |
|---|
| 234 | 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); |
|---|
| 235 | |
|---|
| 236 | #endif /* XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE */ |
|---|