source: trunk/xcache/xc_compatibility.h

Last change on this file was 1493, checked in by moo, 2 months ago

decompiler: fix leak

  • Property svn:eol-style set to native
File size: 7.7 KB
RevLine 
[991]1#ifndef XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C
2#define XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C
3
4#if _MSC_VER > 1000
5#pragma once
[1044]6#endif /* _MSC_VER > 1000 */
[991]7
8#include "php.h"
9
10/* Purpose: Privode stuffs for compatibility with different PHP version
11 */
12
[1486]13#if !defined(ZEND_ENGINE_2_6) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 6 || PHP_MAJOR_VERSION > 6)
14#   define ZEND_ENGINE_2_6
15#endif
16#if !defined(ZEND_ENGINE_2_5) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 5 || defined(ZEND_ENGINE_2_6))
[1213]17#   define ZEND_ENGINE_2_5
18#endif
19#if !defined(ZEND_ENGINE_2_4) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 4 || defined(ZEND_ENGINE_2_5))
[991]20#   define ZEND_ENGINE_2_4
21#endif
22#if !defined(ZEND_ENGINE_2_3) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 3 || defined(ZEND_ENGINE_2_4))
23#   define ZEND_ENGINE_2_3
24#endif
25#if !defined(ZEND_ENGINE_2_2) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 || defined(ZEND_ENGINE_2_3))
26#   define ZEND_ENGINE_2_2
27#endif
28#if !defined(ZEND_ENGINE_2_1) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 || defined(ZEND_ENGINE_2_2))
29#   define ZEND_ENGINE_2_1
30#endif
31
32#define NOTHING
[1321]33/* ZendEngine code Switcher */
34#ifndef ZEND_ENGINE_2
35#   define ZESW(v1, v2) v1
36#else
37#   define ZESW(v1, v2) v2
38#endif
[991]39#ifdef ZEND_ENGINE_2_4
40#   define ZEND_24(pre24, v24) v24
41#else
42#   define ZEND_24(pre24, v24) pre24
43#endif
44
45#ifdef do_alloca_with_limit
[1151]46#   define xc_do_alloca(size, use_heap) do_alloca_with_limit(size, use_heap)
47#   define xc_free_alloca(size, use_heap) free_alloca_with_limit(size, use_heap)
[991]48#elif defined(ALLOCA_FLAG)
[1151]49#   define xc_do_alloca(size, use_heap) do_alloca(size, use_heap)
50#   define xc_free_alloca(size, use_heap) free_alloca(size, use_heap)
[991]51#else
[1151]52#   define xc_do_alloca(size, use_heap) do_alloca(size)
53#   define xc_free_alloca(size, use_heap) free_alloca(size)
[991]54#   define ALLOCA_FLAG(x)
55#endif
56#ifndef Z_ISREF
57#   define Z_ISREF(z) (z).is_ref
58#endif
59#ifndef Z_SET_ISREF
60#   define Z_SET_ISREF(z) (z).is_ref = 1
61#endif
62#ifndef Z_UNSET_ISREF
63#   define Z_UNSET_ISREF(z) (z).is_ref = 0
64#endif
65#ifndef Z_REFCOUNT
66#   define Z_REFCOUNT(z) (z).refcount
67#endif
68#ifndef Z_SET_REFCOUNT
69#   define Z_SET_REFCOUNT(z, rc) (z).refcount = rc
70#endif
71#ifndef IS_CONSTANT_TYPE_MASK
72#   define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX)
73#endif
74/* {{{ dirty fix for PHP 6 */
75#ifdef add_assoc_long_ex
[1151]76static inline void xc_add_assoc_long_ex(zval *arg, char *key, uint key_len, long value)
[991]77{
78    add_assoc_long_ex(arg, key, key_len, value);
79}
80#   undef add_assoc_long_ex
[1151]81#   define add_assoc_long_ex xc_add_assoc_long_ex
[991]82#endif
83#ifdef add_assoc_bool_ex
[1151]84static inline void xc_add_assoc_bool_ex(zval *arg, char *key, uint key_len, zend_bool value)
[991]85{
86    add_assoc_bool_ex(arg, key, key_len, value);
87}
88#   undef add_assoc_bool_ex
[1151]89#   define add_assoc_bool_ex xc_add_assoc_bool_ex
[991]90#endif
91#ifdef add_assoc_null_ex
[1151]92static inline void xc_add_assoc_null_ex(zval *arg, char *key, uint key_len)
[991]93{
94    add_assoc_null_ex(arg, key, key_len);
95}
96#   undef add_assoc_null_ex
[1151]97#   define add_assoc_null_ex xc_add_assoc_null_ex
[991]98#endif
99/* }}} */
100
[1489]101#ifndef ZEND_ENGINE_2_6
102typedef void zend_ast;
103#endif
104
[991]105#ifdef ZEND_ENGINE_2_4
106#   define Z_OP(op) (op)
107#   define Z_OP_CONSTANT(op) (op).literal->constant
108#   define Z_OP_TYPE(op) op##_##type
109#   define Z_OP_TYPEOF_TYPE zend_uchar
110
111#   define Z_CLASS_INFO(className) (className).info.user
112#else
113#   define Z_OP(op) (op).u
114#   define Z_OP_CONSTANT(op) (op).u.constant
115#   define Z_OP_TYPE(op) (op).op_type
116#   define Z_OP_TYPEOF_TYPE int
117typedef znode znode_op;
118
119#   define Z_CLASS_INFO(className) (className)
[1276]120
[1281]121static inline int php_output_start_default(TSRMLS_D) { return php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); }
122static inline int php_output_get_contents(zval *p TSRMLS_DC) { return php_ob_get_buffer(p TSRMLS_CC); }
123static inline int php_output_discard(TSRMLS_D) { php_end_ob_buffer(0, 0 TSRMLS_CC); return SUCCESS; }
[991]124#endif
125
126/* unicode */
127#ifdef IS_UNICODE
128#   define UNISW(text, unicode) unicode
129#else
130#   define UNISW(text, unicode) text
131#endif
132#define BUCKET_KEY_SIZE(b) \
133        (UNISW( \
134            (b)->nKeyLength, \
135                ((b)->key.type == IS_UNICODE) \
136                ? UBYTES(b->nKeyLength) \
137                : b->nKeyLength \
138                ))
139#define BUCKET_KEY(b)      (UNISW((b)->arKey, (b)->key.arKey))
140#define BUCKET_KEY_S(b)    ZSTR_S(BUCKET_KEY(b))
141#define BUCKET_KEY_U(b)    ZSTR_U(BUCKET_KEY(b))
142#define BUCKET_KEY_TYPE(b) (UNISW(IS_STRING,  (b)->key.type))
143#ifdef IS_UNICODE
144#   define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, key.arKey)
145#else
146#   define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, arKey)
147#endif
148
149#ifdef ZEND_ENGINE_2_4
150#   define BUCKET_SIZE(b) (sizeof(Bucket) + BUCKET_KEY_SIZE(b))
151#else
152#   define BUCKET_SIZE(b) (BUCKET_HEAD_SIZE(b) + BUCKET_KEY_SIZE(b))
153#endif
154
155#ifndef IS_UNICODE
156typedef char *zstr;
157typedef const char *const_zstr;
158#ifdef ZEND_ENGINE_2_4
159typedef const char *const24_zstr;
160typedef const char *const24_str;
161#else
162typedef char *const24_zstr;
163typedef char *const24_str;
164#endif
165
166#   define ZSTR_S(s)     (s)
167#   define ZSTR_U(s)     (s)
168#   define ZSTR_V(s)     (s)
169#   define ZSTR_PS(s)    (s)
170#   define ZSTR_PU(s)    (s)
171#   define ZSTR_PV(s)    (s)
172#else
173typedef const zstr const_zstr;
174#   define ZSTR_S(zs)    ((zs).s)
175#   define ZSTR_U(zs)    ((zs).u)
176#   define ZSTR_V(zs)    ((zs).v)
177#   define ZSTR_PS(pzs)  ((pzs)->s)
178#   define ZSTR_PU(pzs)  ((pzs)->u)
179#   define ZSTR_PV(pzs)  ((pzs)->v)
180#endif
181
182#ifndef ZSTR
183#   define ZSTR(s)      (s)
184#endif
185
186#ifndef Z_UNIVAL
187#   define Z_UNIVAL(zval) (zval).value.str.val
188#   define Z_UNILEN(zval) (zval).value.str.len
189#endif
190
191/* {{{ u hash wrapper */
192#ifndef IS_UNICODE
193#   define zend_u_hash_add(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \
194       zend_hash_add(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData, nDataSize, pDest)
195
196#   define zend_u_hash_quick_add(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \
197       zend_hash_quick_add(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData, nDataSize, pDest)
198
199#   define zend_u_hash_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \
200       zend_hash_update(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData, nDataSize, pDest)
201
202#   define zend_u_hash_quick_update(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \
203       zend_hash_quick_update(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData, nDataSize, pDest)
204
205#   define zend_u_hash_find(ht, type, arKey, nKeyLength, pData) \
206       zend_hash_find(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, pData)
207
208#   define zend_u_hash_quick_find(ht, type, arKey, nKeyLength, h, pData) \
209       zend_hash_quick_find(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength, h, pData)
210
211#   define zend_u_hash_exists(ht, type, arKey, nKeyLength) \
212       zend_hash_exists(ht, ZEND_24((char *), NOTHING) arKey, nKeyLength)
213
214#   define add_u_assoc_zval_ex(arg, type, key, key_len, value) \
215        add_assoc_zval_ex(arg, key, key_len, value)
216
217#   define zend_u_is_auto_global(type, name, name_len) \
218        zend_is_auto_global(name, name_len)
219#endif
220/* }}} */
221
[1493]222#ifndef MAKE_COPY_ZVAL
223#   define MAKE_COPY_ZVAL(ppzv, pzv) \
224    *(pzv) = **(ppzv);            \
225    zval_copy_ctor((pzv));        \
226    INIT_PZVAL((pzv));
227#endif
228
[1321]229/* the class entry type to be stored in class_table */
230typedef ZESW(zend_class_entry, zend_class_entry*) xc_cest_t;
231
232/* xc_cest_t to (zend_class_entry*) */
233#define CestToCePtr(st) (ZESW(\
234            &(st), \
235            st \
236            ) )
237
238/* ZCEP=zend class entry ptr */
239#define ZCEP_REFCOUNT_PTR(pce) (ZESW( \
240            (pce)->refcount, \
241            &((pce)->refcount) \
242            ))
243
[991]244#ifndef ZEND_ENGINE_2_3
[1321]245size_t xc_dirname(char *path, size_t len);
246#define zend_dirname xc_dirname
[991]247long xc_atol(const char *str, int len);
248#define zend_atol xc_atol
249#endif
250
[1026]251#ifndef ZEND_MOD_END
252#   define ZEND_MOD_END {NULL, NULL, NULL, 0}
253#endif
254
255#ifndef PHP_FE_END
[1321]256#   ifdef ZEND_ENGINE_2
257#       define PHP_FE_END {NULL, NULL, NULL, 0, 0}
258#   else
259#       define PHP_FE_END {NULL, NULL, NULL}
260#   endif
[1026]261#endif
262
[991]263#endif /* XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C */
Note: See TracBrowser for help on using the repository browser.