source: trunk/xcache.h @ 991

Last change on this file since 991 was 991, checked in by moo, 22 months ago

refactor: split compatibility

  • Property svn:eol-style set to native
File size: 5.9 KB
RevLine 
[1]1#ifndef __XCACHE_H
2#define __XCACHE_H
3#define XCACHE_NAME       "XCache"
[923]4#ifndef XCACHE_VERSION
[967]5#   define XCACHE_VERSION "2.1.0"
[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
[987]22#include "xcache/xc_shm.h"
23#include "xcache/xc_lock.h"
[991]24#include "xcache/xc_compatibility.h"
[1]25
26#define ECALLOC_N(x, n) ((x) = ecalloc(n, sizeof((x)[0])))
27#define ECALLOC_ONE(x) ECALLOC_N(x, 1)
28
29typedef ulong xc_hash_value_t;
30typedef struct {
[917]31    size_t bits;
32    size_t size;
33    xc_hash_value_t mask;
[1]34} xc_hash_t;
35
36typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC);
37
[311]38typedef struct _xc_entry_t xc_entry_t;
39typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
[1]40/* {{{ xc_cache_t */
[11]41typedef struct {
[1]42    int cacheid;
43    xc_hash_t  *hcache; /* hash to cacheid */
44
[11]45    time_t     compiling;
[936]46    zend_ulong updates;
[1]47    zend_ulong hits;
48    zend_ulong clogs;
49    zend_ulong ooms;
[456]50    zend_ulong errors;
[1]51    xc_lock_t  *lck;
[851]52    xc_shm_t   *shm; /* which shm contains us */
53    xc_mem_t   *mem; /* which mem contains us */
[1]54
55    xc_entry_t **entries;
[32]56    int entries_count;
[311]57    xc_entry_data_php_t **phps;
58    int phps_count;
[1]59    xc_entry_t *deletes;
[32]60    int deletes_count;
[311]61    xc_hash_t  *hentry; /* hash settings to entry */
62    xc_hash_t  *hphp;   /* hash settings to php */
[114]63
64    time_t     last_gc_deletes;
65    time_t     last_gc_expires;
[522]66
67    time_t     hits_by_hour_cur_time;
68    zend_uint  hits_by_hour_cur_slot;
69    zend_ulong hits_by_hour[24];
70    time_t     hits_by_second_cur_time;
71    zend_uint  hits_by_second_cur_slot;
72    zend_ulong hits_by_second[5];
[1]73} xc_cache_t;
74/* }}} */
[832]75/* {{{ xc_op_array_info_detail_t */
76typedef struct {
77    zend_uint index;
78    zend_uint info;
79} xc_op_array_info_detail_t;
80/* }}} */
[662]81/* {{{ xc_op_array_info_t */
82typedef struct {
[721]83#ifdef ZEND_ENGINE_2_4
84    zend_uint literalinfo_cnt;
[832]85    xc_op_array_info_detail_t *literalinfos;
[721]86#else
[662]87    zend_uint oplineinfo_cnt;
[832]88    xc_op_array_info_detail_t *oplineinfos;
[721]89#endif
[662]90} xc_op_array_info_t;
91/* }}} */
[1]92/* {{{ xc_classinfo_t */
93typedef struct {
[14]94#ifdef IS_UNICODE
[846]95    zend_uchar   type;
[14]96#endif
[846]97    const24_zstr key;
98    zend_uint    key_size;
99    ulong        h;
100    zend_uint  methodinfo_cnt;
[662]101    xc_op_array_info_t *methodinfos;
[846]102    xc_cest_t    cest;
[548]103#ifndef ZEND_COMPILE_DELAYED_BINDING
[846]104    int          oplineno;
[548]105#endif
[1]106} xc_classinfo_t;
107/* }}} */
[95]108#ifdef HAVE_XCACHE_CONSTANT
109/* {{{ xc_constinfo_t */
110typedef struct {
111#ifdef IS_UNICODE
[846]112    zend_uchar    type;
[95]113#endif
[846]114    const24_zstr  key;
115    zend_uint     key_size;
116    ulong         h;
[95]117    zend_constant constant;
118} xc_constinfo_t;
119/* }}} */
120#endif
[1]121/* {{{ xc_funcinfo_t */
122typedef struct {
[14]123#ifdef IS_UNICODE
[846]124    zend_uchar     type;
[14]125#endif
[846]126    const24_zstr   key;
127    zend_uint      key_size;
128    ulong          h;
[662]129    xc_op_array_info_t op_array_info;
[1]130    zend_function func;
131} xc_funcinfo_t;
132/* }}} */
[268]133#ifdef ZEND_ENGINE_2_1
134/* {{{ xc_autoglobal_t */
135typedef struct {
136#ifdef IS_UNICODE
[846]137    zend_uchar   type;
[268]138#endif
[846]139    const24_zstr key;
140    zend_uint    key_len;
141    ulong        h;
[268]142} xc_autoglobal_t;
143/* }}} */
144#endif
[840]145typedef struct {
146    char digest[16];
147} xc_md5sum_t;
[496]148/* {{{ xc_compilererror_t */
149typedef struct {
[648]150    int type;
[496]151    uint lineno;
152    int error_len;
153    char *error;
154} xc_compilererror_t;
155/* }}} */
[1]156/* {{{ xc_entry_data_php_t */
[311]157struct _xc_entry_data_php_t {
158    xc_entry_data_php_t *next;
[854]159    xc_hash_value_t      hvalue;
[311]160
161    xc_md5sum_t md5;        /* md5sum of the source */
162    zend_ulong  refcount;   /* count of entries referencing to this data */
163
164    zend_ulong hits;        /* hits of this php */
165    size_t     size;
[1]166
[662]167    xc_op_array_info_t op_array_info;
[1]168    zend_op_array *op_array;
169
[95]170#ifdef HAVE_XCACHE_CONSTANT
171    zend_uint constinfo_cnt;
172    xc_constinfo_t *constinfos;
173#endif
174
[1]175    zend_uint funcinfo_cnt;
176    xc_funcinfo_t *funcinfos;
177
178    zend_uint classinfo_cnt;
179    xc_classinfo_t *classinfos;
[548]180#ifndef ZEND_COMPILE_DELAYED_BINDING
[212]181    zend_bool have_early_binding;
[548]182#endif
[268]183
184#ifdef ZEND_ENGINE_2_1
185    zend_uint autoglobal_cnt;
186    xc_autoglobal_t *autoglobals;
187#endif
[311]188
[496]189#ifdef E_STRICT
190    zend_uint compilererror_cnt;
191    xc_compilererror_t *compilererrors;
192#endif
193
[311]194    zend_bool  have_references;
195};
[1]196/* }}} */
197typedef zvalue_value xc_entry_name_t;
198/* {{{ xc_entry_t */
199struct _xc_entry_t {
[854]200    xc_entry_t *next;
[1]201
[854]202    size_t     size;
[851]203    time_t     ctime;           /* creation ctime of this entry */
204    time_t     atime;           /*   access atime of this entry */
205    time_t     dtime;           /*  deletion time of this entry */
[1]206    zend_ulong hits;
[917]207    zend_ulong ttl;
[1]208
209    xc_entry_name_t name;
[851]210};
[233]211
[851]212typedef struct {
213    xc_entry_t entry;
[854]214    xc_entry_data_php_t *php;
[851]215
216    zend_ulong refcount;    /* count of php instances holding this entry */
217    time_t file_mtime;
[859]218    size_t file_size;
[851]219    int file_device;
220    int file_inode;
[684]221
222    int    filepath_len;
[860]223    ZEND_24(NOTHING, const) char *filepath;
[684]224    int    dirpath_len;
225    char  *dirpath;
226#ifdef IS_UNICODE
[851]227    int    ufilepath_len;
[684]228    UChar *ufilepath;
[851]229    int    udirpath_len;
[684]230    UChar *udirpath;
231#endif
[851]232} xc_entry_php_t;
[855]233
[854]234typedef struct {
235    xc_entry_t entry;
[866]236#ifdef IS_UNICODE
237    zend_uchar name_type;
238#endif
[854]239    zval      *value;
240    zend_bool  have_references;
241} xc_entry_var_t;
242/* }}} */
243typedef struct xc_entry_hash_t { /* {{{ */
[859]244    xc_hash_value_t cacheid;
[854]245    xc_hash_value_t entryslotid;
246} xc_entry_hash_t;
247/* }}} */
[1]248
249extern zend_module_entry xcache_module_entry;
250#define phpext_xcache_ptr &xcache_module_entry
251
252int xc_is_rw(const void *p);
253int xc_is_ro(const void *p);
254int xc_is_shm(const void *p);
[662]255/* {{{ xc_gc_op_array_t */
256typedef struct {
257#ifdef ZEND_ENGINE_2
258    zend_uint num_args;
259    zend_arg_info *arg_info;
260#endif
261    zend_op *opcodes;
262} xc_gc_op_array_t;
263/* }}} */
264void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
[851]265void 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]266
267#endif /* __XCACHE_H */
Note: See TracBrowser for help on using the repository browser.