source: trunk/xcache.h @ 1035

Last change on this file since 1035 was 1035, checked in by moo, 21 months ago

bump version to 3.0.0

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