summaryrefslogtreecommitdiff
path: root/mod_cacher/xc_cache.h
blob: bf98415fd8978df6253eb8e71a7e4272ead552bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#ifndef XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE
#define XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE

#if _MSC_VER > 1000
#pragma once
#endif /* _MSC_VER > 1000 */

#include "xcache.h"
#include "xcache/xc_compatibility.h"

typedef ulong xc_hash_value_t;
typedef struct _xc_hash_t xc_hash_t;
typedef struct _xc_cached_t xc_cached_t;
typedef struct _xc_entry_t xc_entry_t;
typedef struct _xc_entry_data_php_t xc_entry_data_php_t;

struct _xc_lock_t;
struct _xc_shm_t;
/* {{{ xc_constant_info_t */
typedef struct {
	zend_uint index;
	zend_uint info;
} xc_constant_info_t;
/* }}} */
/* {{{ xc_op_array_info_t */
typedef struct {
	zend_uint           constantinfo_cnt;
	xc_constant_info_t *constantinfos;
} xc_op_array_info_t;
/* }}} */
/* {{{ xc_classinfo_t */
typedef struct {
#ifdef IS_UNICODE
	zend_uchar          type;
#endif
	const24_zstr        key;
	zend_uint           key_size;
	ulong               h;
	zend_uint           methodinfo_cnt;
	xc_op_array_info_t *methodinfos;
#ifdef ZEND_ENGINE_2
	zend_uint           constantinfo_cnt;
	xc_constant_info_t *constantinfos;
#endif
	xc_cest_t           cest;
#ifndef ZEND_COMPILE_DELAYED_BINDING
	int                 oplineno;
#endif
} xc_classinfo_t;
/* }}} */
#ifdef HAVE_XCACHE_CONSTANT
/* {{{ xc_constinfo_t */
typedef struct {
#ifdef IS_UNICODE
	zend_uchar    type;
#endif
	const24_zstr  key;
	zend_uint     key_size;
	ulong         h;
	zend_constant constant;
} xc_constinfo_t;
/* }}} */
#endif
/* {{{ xc_funcinfo_t */
typedef struct {
#ifdef IS_UNICODE
	zend_uchar     type;
#endif
	const24_zstr   key;
	zend_uint      key_size;
	ulong          h;
	xc_op_array_info_t op_array_info;
	zend_function func;
} xc_funcinfo_t;
/* }}} */
#ifdef ZEND_ENGINE_2_1
/* {{{ xc_autoglobal_t */
typedef struct {
#ifdef IS_UNICODE
	zend_uchar   type;
#endif
	const24_zstr key;
	zend_uint    key_len;
	ulong        h;
} xc_autoglobal_t;
/* }}} */
#endif

typedef struct {
	char digest[16];
} xc_md5sum_t;
struct _xc_compilererror_t;
/* {{{ xc_entry_data_php_t */
struct _xc_entry_data_php_t {
	xc_entry_data_php_t *next;
	xc_hash_value_t      hvalue;

	xc_md5sum_t md5;        /* md5sum of the source */
	zend_ulong  refcount;   /* count of entries referencing to this data */

	zend_ulong hits;        /* hits of this php */
	size_t     size;

	xc_op_array_info_t op_array_info;
	zend_op_array *op_array;

#ifdef HAVE_XCACHE_CONSTANT
	zend_uint constinfo_cnt;
	xc_constinfo_t *constinfos;
#endif

	zend_uint funcinfo_cnt;
	xc_funcinfo_t *funcinfos;

	zend_uint classinfo_cnt;
	xc_classinfo_t *classinfos;
#ifndef ZEND_COMPILE_DELAYED_BINDING
	zend_bool have_early_binding;
#endif

#ifdef ZEND_ENGINE_2_1
	zend_uint autoglobal_cnt;
	xc_autoglobal_t *autoglobals;
#endif

#ifdef XCACHE_ERROR_CACHING
	zend_uint compilererror_cnt;
	struct _xc_compilererror_t *compilererrors;
#endif

	zend_bool  have_references;
};
/* }}} */
typedef zvalue_value xc_entry_name_t;
/* {{{ xc_entry_t */
struct _xc_entry_t {
	xc_entry_t *next;

	size_t     size;
	time_t     ctime;           /* creation ctime of this entry */
	time_t     atime;           /*   access atime of this entry */
	time_t     dtime;           /*  deletion time of this entry */
	zend_ulong hits;
	zend_ulong ttl;

	xc_entry_name_t name;
};

typedef struct {
	char  *str;
	size_t len;
} xc_constant_string_t;

#ifdef IS_UNICODE
typedef struct {
	UChar  *str;
	size_t len;
} xc_constant_u_string_t;
#endif

typedef struct {
	xc_entry_t entry;
	xc_entry_data_php_t *php;

	zend_ulong refcount;    /* count of php instances holding this entry */
	time_t file_mtime;
	size_t file_size;
	size_t file_device;
	size_t file_inode;

	xc_constant_string_t filepath;
#ifdef ZEND_ENGINE_2_3
	xc_constant_string_t dirpath;
#endif
#ifdef IS_UNICODE
	xc_constant_u_string_t u_filepath;
	xc_constant_u_string_t u_dirpath;
#endif
} xc_entry_php_t;

typedef struct {
	xc_entry_t entry;
#ifdef IS_UNICODE
	zend_uchar name_type;
#endif
	zval      *value;

#ifdef ZEND_ENGINE_2
	zend_uint objects_count;
	zend_object *objects;
#endif
	zend_uint class_names_count;
	xc_constant_string_t *class_names;

	zend_bool  have_references;
} xc_entry_var_t;
/* }}} */
typedef struct xc_entry_hash_t { /* {{{ */
	xc_hash_value_t cacheid;
	xc_hash_value_t entryslotid;
} xc_entry_hash_t;
/* }}} */

zend_bool xc_is_rw(const void *p);
zend_bool xc_is_ro(const void *p);
zend_bool xc_is_shm(const void *p);
/* {{{ xc_gc_op_array_t */
typedef struct {
#ifdef ZEND_ENGINE_2
	zend_uint num_args;
	zend_arg_info *arg_info;
#endif
#ifdef ZEND_ENGINE_2_4
	zend_literal *literals;
#endif
	zend_op *opcodes;
} xc_gc_op_array_t;
/* }}} */
void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
#ifdef ZEND_ENGINE_2
void xc_fix_class_info(const xc_entry_php_t *entry_php, xc_classinfo_t *classinfo, int shallow_copy TSRMLS_DC);
#endif
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);

#endif /* XC_CACHE_H_684B099102B4651FB10058EF6F7E80CE */