Annotation of embedaddon/php/Zend/zend.h, revision 1.1.1.2.2.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | Zend Engine |
4: +----------------------------------------------------------------------+
5: | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
6: +----------------------------------------------------------------------+
7: | This source file is subject to version 2.00 of the Zend license, |
8: | that is bundled with this package in the file LICENSE, and is |
9: | available through the world-wide-web at the following url: |
10: | http://www.zend.com/license/2_00.txt. |
11: | If you did not receive a copy of the Zend license and are unable to |
12: | obtain it through the world-wide-web, please send a note to |
13: | license@zend.com so we can mail you a copy immediately. |
14: +----------------------------------------------------------------------+
15: | Authors: Andi Gutmans <andi@zend.com> |
16: | Zeev Suraski <zeev@zend.com> |
17: +----------------------------------------------------------------------+
18: */
19:
1.1.1.2.2.1! misho 20: /* $Id: zend.h,v 1.1.1.2 2012/05/29 12:34:35 misho Exp $ */
1.1 misho 21:
22: #ifndef ZEND_H
23: #define ZEND_H
24:
1.1.1.2 misho 25: #define ZEND_VERSION "2.4.0"
1.1 misho 26:
27: #define ZEND_ENGINE_2
28:
29: #ifdef __cplusplus
30: #define BEGIN_EXTERN_C() extern "C" {
31: #define END_EXTERN_C() }
32: #else
33: #define BEGIN_EXTERN_C()
34: #define END_EXTERN_C()
35: #endif
36:
37: /*
38: * general definitions
39: */
40:
41: #ifdef ZEND_WIN32
42: # include "zend_config.w32.h"
43: # define ZEND_PATHS_SEPARATOR ';'
44: #elif defined(NETWARE)
45: # include <zend_config.h>
46: # define ZEND_PATHS_SEPARATOR ';'
47: #elif defined(__riscos__)
48: # include <zend_config.h>
49: # define ZEND_PATHS_SEPARATOR ';'
50: #else
51: # include <zend_config.h>
52: # define ZEND_PATHS_SEPARATOR ':'
53: #endif
54:
55: #ifdef ZEND_WIN32
56: /* Only use this macro if you know for sure that all of the switches values
57: are covered by its case statements */
58: #define EMPTY_SWITCH_DEFAULT_CASE() \
59: default: \
60: __assume(0); \
61: break;
62: #else
63: #define EMPTY_SWITCH_DEFAULT_CASE()
64: #endif
65:
66: /* all HAVE_XXX test have to be after the include of zend_config above */
67:
68: #include <stdio.h>
69:
70: #ifdef HAVE_UNIX_H
71: # include <unix.h>
72: #endif
73:
74: #ifdef HAVE_STDARG_H
75: # include <stdarg.h>
76: #endif
77:
78: #ifdef HAVE_DLFCN_H
79: # include <dlfcn.h>
80: #endif
81:
82: #if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
83:
84: # ifndef RTLD_LAZY
85: # define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
86: # endif
87:
88: # ifndef RTLD_GLOBAL
89: # define RTLD_GLOBAL 0
90: # endif
91:
92: # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
93: # define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
94: # elif defined(RTLD_DEEPBIND)
95: # define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
96: # else
97: # define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
98: # endif
99: # define DL_UNLOAD dlclose
100: # if defined(DLSYM_NEEDS_UNDERSCORE)
101: # define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
102: # else
103: # define DL_FETCH_SYMBOL dlsym
104: # endif
105: # define DL_ERROR dlerror
106: # define DL_HANDLE void *
107: # define ZEND_EXTENSIONS_SUPPORT 1
108: #elif defined(ZEND_WIN32)
109: # define DL_LOAD(libname) LoadLibrary(libname)
110: # define DL_FETCH_SYMBOL GetProcAddress
111: # define DL_UNLOAD FreeLibrary
112: # define DL_HANDLE HMODULE
113: # define ZEND_EXTENSIONS_SUPPORT 1
114: #else
115: # define DL_HANDLE void *
116: # define ZEND_EXTENSIONS_SUPPORT 0
117: #endif
118:
119: #if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
120: # include <alloca.h>
121: #endif
122:
123: /* AIX requires this to be the first thing in the file. */
124: #ifndef __GNUC__
125: # ifndef HAVE_ALLOCA_H
126: # ifdef _AIX
127: #pragma alloca
128: # else
129: # ifndef alloca /* predefined by HP cc +Olibcalls */
130: char *alloca ();
131: # endif
132: # endif
133: # endif
134: #endif
135:
136: /* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */
137: #ifdef __GNUC__
138: # define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
139: #else
140: # define ZEND_GCC_VERSION 0
141: #endif
142:
143: #if ZEND_GCC_VERSION >= 2096
144: # define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
145: #else
146: # define ZEND_ATTRIBUTE_MALLOC
147: #endif
148:
149: #if ZEND_GCC_VERSION >= 2007
150: # define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
151: #else
152: # define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
153: #endif
154:
155: #if ZEND_GCC_VERSION >= 3001 && !defined(__INTEL_COMPILER)
156: # define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
157: #else
158: # define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
159: #endif
160:
161: #if ZEND_GCC_VERSION >= 3001
162: # define ZEND_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
163: #elif defined(ZEND_WIN32) && defined(_MSC_VER) && _MSC_VER >= 1300
164: # define ZEND_ATTRIBUTE_DEPRECATED __declspec(deprecated)
165: #else
166: # define ZEND_ATTRIBUTE_DEPRECATED
167: #endif
168:
169: #if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
170: # define ZEND_FASTCALL __attribute__((fastcall))
171: #elif defined(_MSC_VER) && defined(_M_IX86)
172: # define ZEND_FASTCALL __fastcall
173: #else
174: # define ZEND_FASTCALL
175: #endif
176:
177: #if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004
178: #else
179: # define __restrict__
180: #endif
181: #define restrict __restrict__
182:
1.1.1.2.2.1! misho 183: #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
1.1 misho 184: # define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
185: # define ALLOCA_FLAG(name) \
186: zend_bool name;
187: # define SET_ALLOCA_FLAG(name) \
188: name = 1
189: # define do_alloca_ex(size, limit, use_heap) \
190: ((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
191: # define do_alloca(size, use_heap) \
192: do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
193: # define free_alloca(p, use_heap) \
194: do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
195: #else
196: # define ALLOCA_FLAG(name)
197: # define SET_ALLOCA_FLAG(name)
198: # define do_alloca(p, use_heap) emalloc(p)
199: # define free_alloca(p, use_heap) efree(p)
200: #endif
201:
202: #if ZEND_DEBUG
1.1.1.2 misho 203: #define ZEND_FILE_LINE_D const char *__zend_filename, const uint __zend_lineno
1.1 misho 204: #define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
1.1.1.2 misho 205: #define ZEND_FILE_LINE_ORIG_D const char *__zend_orig_filename, const uint __zend_orig_lineno
1.1 misho 206: #define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
207: #define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
208: #define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
209: #define ZEND_FILE_LINE_C __FILE__, __LINE__
210: #define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
211: #define ZEND_FILE_LINE_EMPTY_C NULL, 0
212: #define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
213: #define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
214: #define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
215: #else
216: #define ZEND_FILE_LINE_D
217: #define ZEND_FILE_LINE_DC
218: #define ZEND_FILE_LINE_ORIG_D
219: #define ZEND_FILE_LINE_ORIG_DC
220: #define ZEND_FILE_LINE_RELAY_C
221: #define ZEND_FILE_LINE_RELAY_CC
222: #define ZEND_FILE_LINE_C
223: #define ZEND_FILE_LINE_CC
224: #define ZEND_FILE_LINE_EMPTY_C
225: #define ZEND_FILE_LINE_EMPTY_CC
226: #define ZEND_FILE_LINE_ORIG_RELAY_C
227: #define ZEND_FILE_LINE_ORIG_RELAY_CC
228: #endif /* ZEND_DEBUG */
229:
230: #ifdef ZTS
231: #define ZTS_V 1
232: #else
233: #define ZTS_V 0
234: #endif
235:
236: #include "zend_errors.h"
237: #include "zend_alloc.h"
238:
239: #include "zend_types.h"
1.1.1.2 misho 240: #include "zend_string.h"
1.1 misho 241:
242: #ifdef HAVE_LIMITS_H
243: # include <limits.h>
244: #endif
245:
246: #ifndef LONG_MAX
247: #define LONG_MAX 2147483647L
248: #endif
249:
250: #ifndef LONG_MIN
251: #define LONG_MIN (- LONG_MAX - 1)
252: #endif
253:
254: #if SIZEOF_LONG == 4
255: #define MAX_LENGTH_OF_LONG 11
256: static const char long_min_digits[] = "2147483648";
257: #elif SIZEOF_LONG == 8
258: #define MAX_LENGTH_OF_LONG 20
259: static const char long_min_digits[] = "9223372036854775808";
260: #else
261: #error "Unknown SIZEOF_LONG"
262: #endif
263:
264: #define MAX_LENGTH_OF_DOUBLE 32
265:
266: #undef SUCCESS
267: #undef FAILURE
268: #define SUCCESS 0
269: #define FAILURE -1 /* this MUST stay a negative number, or it may affect functions! */
270:
271: #include "zend_hash.h"
272: #include "zend_ts_hash.h"
273: #include "zend_llist.h"
274:
275: #define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
276: #define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
277:
278: #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
279: void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
280: #else
281: # define zend_error_noreturn zend_error
282: #endif
283:
284: /*
285: * zval
286: */
287: typedef struct _zval_struct zval;
288: typedef struct _zend_class_entry zend_class_entry;
289:
290: typedef struct _zend_guard {
291: zend_bool in_get;
292: zend_bool in_set;
293: zend_bool in_unset;
294: zend_bool in_isset;
295: zend_bool dummy; /* sizeof(zend_guard) must not be equal to sizeof(void*) */
296: } zend_guard;
297:
298: typedef struct _zend_object {
299: zend_class_entry *ce;
300: HashTable *properties;
1.1.1.2 misho 301: zval **properties_table;
1.1 misho 302: HashTable *guards; /* protects from __get/__set ... recursion */
303: } zend_object;
304:
305: #include "zend_object_handlers.h"
306:
307: typedef union _zvalue_value {
308: long lval; /* long value */
309: double dval; /* double value */
310: struct {
311: char *val;
312: int len;
313: } str;
314: HashTable *ht; /* hash table value */
315: zend_object_value obj;
316: } zvalue_value;
317:
318: struct _zval_struct {
319: /* Variable information */
320: zvalue_value value; /* value */
321: zend_uint refcount__gc;
322: zend_uchar type; /* active type */
323: zend_uchar is_ref__gc;
324: };
325:
326: #define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz))
327: #define Z_SET_REFCOUNT_PP(ppz, rc) Z_SET_REFCOUNT_P(*(ppz), rc)
328: #define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz))
329: #define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz))
330: #define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz))
331: #define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz))
332: #define Z_UNSET_ISREF_PP(ppz) Z_UNSET_ISREF_P(*(ppz))
333: #define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref)
334:
335: #define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
336: #define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
337: #define Z_ADDREF_P(pz) zval_addref_p(pz)
338: #define Z_DELREF_P(pz) zval_delref_p(pz)
339: #define Z_ISREF_P(pz) zval_isref_p(pz)
340: #define Z_SET_ISREF_P(pz) zval_set_isref_p(pz)
341: #define Z_UNSET_ISREF_P(pz) zval_unset_isref_p(pz)
342: #define Z_SET_ISREF_TO_P(pz, isref) zval_set_isref_to_p(pz, isref)
343:
344: #define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
345: #define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
346: #define Z_ADDREF(z) Z_ADDREF_P(&(z))
347: #define Z_DELREF(z) Z_DELREF_P(&(z))
348: #define Z_ISREF(z) Z_ISREF_P(&(z))
349: #define Z_SET_ISREF(z) Z_SET_ISREF_P(&(z))
350: #define Z_UNSET_ISREF(z) Z_UNSET_ISREF_P(&(z))
351: #define Z_SET_ISREF_TO(z, isref) Z_SET_ISREF_TO_P(&(z), isref)
352:
353: #if defined(__GNUC__)
354: #if __GNUC__ >= 3
355: #define zend_always_inline inline __attribute__((always_inline))
1.1.1.2 misho 356: #define zend_never_inline __attribute__((noinline))
1.1 misho 357: #else
358: #define zend_always_inline inline
1.1.1.2 misho 359: #define zend_never_inline
1.1 misho 360: #endif
361:
362: #elif defined(_MSC_VER)
363: #define zend_always_inline __forceinline
1.1.1.2 misho 364: #define zend_never_inline
1.1 misho 365: #else
366: #define zend_always_inline inline
1.1.1.2 misho 367: #define zend_never_inline
1.1 misho 368: #endif
369:
1.1.1.2 misho 370: #if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
1.1 misho 371: # define EXPECTED(condition) __builtin_expect(condition, 1)
372: # define UNEXPECTED(condition) __builtin_expect(condition, 0)
373: #else
374: # define EXPECTED(condition) (condition)
375: # define UNEXPECTED(condition) (condition)
376: #endif
377:
378: static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
379: return pz->refcount__gc;
380: }
381:
382: static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
383: return pz->refcount__gc = rc;
384: }
385:
386: static zend_always_inline zend_uint zval_addref_p(zval* pz) {
387: return ++pz->refcount__gc;
388: }
389:
390: static zend_always_inline zend_uint zval_delref_p(zval* pz) {
391: return --pz->refcount__gc;
392: }
393:
394: static zend_always_inline zend_bool zval_isref_p(zval* pz) {
395: return pz->is_ref__gc;
396: }
397:
398: static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
399: return pz->is_ref__gc = 1;
400: }
401:
402: static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
403: return pz->is_ref__gc = 0;
404: }
405:
406: static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) {
407: return pz->is_ref__gc = isref;
408: }
409:
410: /* excpt.h on Digital Unix 4.0 defines function_table */
411: #undef function_table
412:
413: /* A lot of stuff needs shifiting around in order to include zend_compile.h here */
414: union _zend_function;
415:
416: #include "zend_iterators.h"
417:
418: struct _zend_serialize_data;
419: struct _zend_unserialize_data;
420:
421: typedef struct _zend_serialize_data zend_serialize_data;
422: typedef struct _zend_unserialize_data zend_unserialize_data;
423:
1.1.1.2 misho 424: struct _zend_trait_method_reference {
425: const char* method_name;
426: unsigned int mname_len;
427:
428: zend_class_entry *ce;
429:
430: const char* class_name;
431: unsigned int cname_len;
432: };
433: typedef struct _zend_trait_method_reference zend_trait_method_reference;
434:
435: struct _zend_trait_precedence {
436: zend_trait_method_reference *trait_method;
437:
438: zend_class_entry** exclude_from_classes;
439:
440: union _zend_function* function;
441: };
442: typedef struct _zend_trait_precedence zend_trait_precedence;
443:
444: struct _zend_trait_alias {
445: zend_trait_method_reference *trait_method;
446:
447: /**
448: * name for method to be added
449: */
450: const char* alias;
451: unsigned int alias_len;
452:
453: /**
454: * modifiers to be set on trait method
455: */
456: zend_uint modifiers;
457:
458: union _zend_function* function;
459: };
460: typedef struct _zend_trait_alias zend_trait_alias;
461:
1.1 misho 462: struct _zend_class_entry {
463: char type;
1.1.1.2 misho 464: const char *name;
1.1 misho 465: zend_uint name_length;
466: struct _zend_class_entry *parent;
467: int refcount;
468: zend_uint ce_flags;
469:
470: HashTable function_table;
471: HashTable properties_info;
1.1.1.2 misho 472: zval **default_properties_table;
473: zval **default_static_members_table;
474: zval **static_members_table;
1.1 misho 475: HashTable constants_table;
1.1.1.2 misho 476: int default_properties_count;
477: int default_static_members_count;
1.1 misho 478:
479: union _zend_function *constructor;
480: union _zend_function *destructor;
481: union _zend_function *clone;
482: union _zend_function *__get;
483: union _zend_function *__set;
484: union _zend_function *__unset;
485: union _zend_function *__isset;
486: union _zend_function *__call;
487: union _zend_function *__callstatic;
488: union _zend_function *__tostring;
489: union _zend_function *serialize_func;
490: union _zend_function *unserialize_func;
491:
492: zend_class_iterator_funcs iterator_funcs;
493:
494: /* handlers */
495: zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
496: zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
497: int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
498: union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, int method_len TSRMLS_DC);
499:
500: /* serializer callbacks */
501: int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
502: int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
503:
504: zend_class_entry **interfaces;
505: zend_uint num_interfaces;
1.1.1.2 misho 506:
507: zend_class_entry **traits;
508: zend_uint num_traits;
509: zend_trait_alias **trait_aliases;
510: zend_trait_precedence **trait_precedences;
511:
512: union {
513: struct {
514: const char *filename;
515: zend_uint line_start;
516: zend_uint line_end;
517: const char *doc_comment;
518: zend_uint doc_comment_len;
519: } user;
520: struct {
521: const struct _zend_function_entry *builtin_functions;
522: struct _zend_module_entry *module;
523: } internal;
524: } info;
1.1 misho 525: };
526:
527: #include "zend_stream.h"
528: typedef struct _zend_utility_functions {
529: void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
530: int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
531: int (*write_function)(const char *str, uint str_length);
532: FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
1.1.1.2 misho 533: void (*message_handler)(long message, const void *data TSRMLS_DC);
1.1 misho 534: void (*block_interruptions)(void);
535: void (*unblock_interruptions)(void);
536: int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
537: void (*ticks_function)(int ticks);
538: void (*on_timeout)(int seconds TSRMLS_DC);
539: int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
540: int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
541: char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
542: char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
543: } zend_utility_functions;
544:
545: typedef struct _zend_utility_values {
546: char *import_use_extension;
547: uint import_use_extension_length;
548: zend_bool html_errors;
549: } zend_utility_values;
550:
551: typedef int (*zend_write_func_t)(const char *str, uint str_length);
552:
553: #undef MIN
554: #undef MAX
555: #define MAX(a, b) (((a)>(b))?(a):(b))
556: #define MIN(a, b) (((a)<(b))?(a):(b))
557: #define ZEND_STRL(str) (str), (sizeof(str)-1)
558: #define ZEND_STRS(str) (str), (sizeof(str))
559: #define ZEND_NORMALIZE_BOOL(n) \
560: ((n) ? (((n)>0) ? 1 : -1) : 0)
561: #define ZEND_TRUTH(x) ((x) ? 1 : 0)
562: #define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
563:
564: /* data types */
565: /* All data types <= IS_BOOL have their constructor/destructors skipped */
566: #define IS_NULL 0
567: #define IS_LONG 1
568: #define IS_DOUBLE 2
569: #define IS_BOOL 3
570: #define IS_ARRAY 4
571: #define IS_OBJECT 5
572: #define IS_STRING 6
573: #define IS_RESOURCE 7
574: #define IS_CONSTANT 8
575: #define IS_CONSTANT_ARRAY 9
1.1.1.2 misho 576: #define IS_CALLABLE 10
1.1 misho 577:
578: /* Ugly hack to support constants as static array indices */
1.1.1.2 misho 579: #define IS_CONSTANT_TYPE_MASK 0x00f
580: #define IS_CONSTANT_UNQUALIFIED 0x010
581: #define IS_CONSTANT_INDEX 0x080
582: #define IS_LEXICAL_VAR 0x020
583: #define IS_LEXICAL_REF 0x040
584: #define IS_CONSTANT_IN_NAMESPACE 0x100
1.1 misho 585:
586: /* overloaded elements data types */
587: #define OE_IS_ARRAY (1<<0)
588: #define OE_IS_OBJECT (1<<1)
589: #define OE_IS_METHOD (1<<2)
590:
591: int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC);
592: void zend_shutdown(TSRMLS_D);
593: void zend_register_standard_ini_entries(TSRMLS_D);
594: void zend_post_startup(TSRMLS_D);
595: void zend_set_utility_values(zend_utility_values *utility_values);
596:
597: BEGIN_EXTERN_C()
598: ZEND_API void _zend_bailout(char *filename, uint lineno);
599: END_EXTERN_C()
600:
601: #define zend_bailout() _zend_bailout(__FILE__, __LINE__)
602:
603: #ifdef HAVE_SIGSETJMP
604: # define SETJMP(a) sigsetjmp(a, 0)
605: # define LONGJMP(a,b) siglongjmp(a, b)
606: # define JMP_BUF sigjmp_buf
607: #else
608: # define SETJMP(a) setjmp(a)
609: # define LONGJMP(a,b) longjmp(a, b)
610: # define JMP_BUF jmp_buf
611: #endif
612:
613: #define zend_try \
614: { \
615: JMP_BUF *__orig_bailout = EG(bailout); \
616: JMP_BUF __bailout; \
617: \
618: EG(bailout) = &__bailout; \
619: if (SETJMP(__bailout)==0) {
620: #define zend_catch \
621: } else { \
622: EG(bailout) = __orig_bailout;
623: #define zend_end_try() \
624: } \
625: EG(bailout) = __orig_bailout; \
626: }
627: #define zend_first_try EG(bailout)=NULL; zend_try
628:
629: BEGIN_EXTERN_C()
630: ZEND_API char *get_zend_version(void);
631: ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
632: ZEND_API int zend_print_zval(zval *expr, int indent);
633: ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
634: ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
635: ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
636: ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
637: ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
638: END_EXTERN_C()
639:
640: void zend_activate(TSRMLS_D);
641: void zend_deactivate(TSRMLS_D);
642: void zend_call_destructors(TSRMLS_D);
643: void zend_activate_modules(TSRMLS_D);
644: void zend_deactivate_modules(TSRMLS_D);
645: void zend_post_deactivate_modules(TSRMLS_D);
646:
647: #if ZEND_DEBUG
648: #define Z_DBG(expr) (expr)
649: #else
650: #define Z_DBG(expr)
651: #endif
652:
653: BEGIN_EXTERN_C()
654: ZEND_API void free_estring(char **str_p);
655: END_EXTERN_C()
656:
657: /* FIXME: Check if we can save if (ptr) too */
658:
1.1.1.2 misho 659: #define STR_FREE(ptr) if (ptr && !IS_INTERNED(ptr)) { efree(ptr); }
660: #define STR_FREE_REL(ptr) if (ptr && !IS_INTERNED(ptr)) { efree_rel(ptr); }
1.1 misho 661:
662: #define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
663:
664: #define STR_REALLOC(ptr, size) \
665: ptr = (char *) erealloc(ptr, size);
666:
667: /* output support */
668: #define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
669: #define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
670: #define ZEND_PUTS(str) zend_write((str), strlen((str)))
671: #define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
672: #define ZEND_PUTC(c) zend_write(&(c), 1), (c)
673:
674: BEGIN_EXTERN_C()
675: extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
676: extern ZEND_API zend_write_func_t zend_write;
677: extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
678: extern ZEND_API void (*zend_block_interruptions)(void);
679: extern ZEND_API void (*zend_unblock_interruptions)(void);
680: extern ZEND_API void (*zend_ticks_function)(int ticks);
681: extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
1.1.1.2 misho 682: extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
1.1 misho 683: extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
684: extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
685: extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
686: extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
687:
688: ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
689:
690: void zenderror(const char *error);
691:
692: /* The following #define is used for code duality in PHP for Engine 1 & 2 */
693: #define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
694: extern ZEND_API zend_class_entry *zend_standard_class_def;
695: extern ZEND_API zend_utility_values zend_uv;
696: extern ZEND_API zval zval_used_for_init;
697:
698: END_EXTERN_C()
699:
700: #define ZEND_UV(name) (zend_uv.name)
701:
1.1.1.2 misho 702: #ifndef ZEND_SIGNALS
1.1 misho 703: #define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
704: #define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
1.1.1.2 misho 705: #else
706: #include "zend_signal.h"
707:
708: #define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPUTIONS()
709: #define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
710: #endif
1.1 misho 711:
712: BEGIN_EXTERN_C()
1.1.1.2 misho 713: ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
1.1 misho 714:
715: ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
716: END_EXTERN_C()
717:
718: /* Messages for applications of Zend */
719: #define ZMSG_FAILED_INCLUDE_FOPEN 1L
720: #define ZMSG_FAILED_REQUIRE_FOPEN 2L
721: #define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
722: #define ZMSG_MEMORY_LEAK_DETECTED 4L
723: #define ZMSG_MEMORY_LEAK_REPEATED 5L
724: #define ZMSG_LOG_SCRIPT_NAME 6L
725: #define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
726:
727: #define INIT_PZVAL(z) \
728: (z)->refcount__gc = 1; \
729: (z)->is_ref__gc = 0;
730:
731: #define INIT_ZVAL(z) z = zval_used_for_init;
732:
733: #define ALLOC_INIT_ZVAL(zp) \
734: ALLOC_ZVAL(zp); \
735: INIT_ZVAL(*zp);
736:
737: #define MAKE_STD_ZVAL(zv) \
738: ALLOC_ZVAL(zv); \
739: INIT_PZVAL(zv);
740:
741: #define PZVAL_IS_REF(z) Z_ISREF_P(z)
742:
1.1.1.2 misho 743: #define ZVAL_COPY_VALUE(z, v) \
744: do { \
745: (z)->value = (v)->value; \
746: Z_TYPE_P(z) = Z_TYPE_P(v); \
747: } while (0)
748:
749: #define INIT_PZVAL_COPY(z, v) \
750: do { \
751: ZVAL_COPY_VALUE(z, v); \
752: Z_SET_REFCOUNT_P(z, 1); \
753: Z_UNSET_ISREF_P(z); \
754: } while (0)
755:
756: #define SEPARATE_ZVAL(ppzv) \
757: do { \
758: if (Z_REFCOUNT_PP((ppzv)) > 1) { \
759: zval *new_zv; \
760: Z_DELREF_PP(ppzv); \
761: ALLOC_ZVAL(new_zv); \
762: INIT_PZVAL_COPY(new_zv, *(ppzv)); \
763: *(ppzv) = new_zv; \
764: zval_copy_ctor(new_zv); \
765: } \
766: } while (0)
1.1 misho 767:
768: #define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
769: if (!PZVAL_IS_REF(*ppzv)) { \
770: SEPARATE_ZVAL(ppzv); \
771: }
772:
773: #define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
774: if (!PZVAL_IS_REF(*ppzv)) { \
775: SEPARATE_ZVAL(ppzv); \
776: Z_SET_ISREF_PP((ppzv)); \
777: }
778:
779: #define COPY_PZVAL_TO_ZVAL(zv, pzv) \
780: (zv) = *(pzv); \
781: if (Z_REFCOUNT_P(pzv)>1) { \
782: zval_copy_ctor(&(zv)); \
783: Z_DELREF_P((pzv)); \
784: } else { \
785: FREE_ZVAL(pzv); \
786: } \
787: INIT_PZVAL(&(zv));
788:
1.1.1.2 misho 789: #define MAKE_COPY_ZVAL(ppzv, pzv) \
790: INIT_PZVAL_COPY(pzv, *(ppzv)); \
791: zval_copy_ctor((pzv));
1.1 misho 792:
793: #define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
794: int is_ref, refcount; \
795: \
796: SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
797: is_ref = Z_ISREF_PP(ppzv_dest); \
798: refcount = Z_REFCOUNT_PP(ppzv_dest); \
799: zval_dtor(*ppzv_dest); \
1.1.1.2 misho 800: ZVAL_COPY_VALUE(*ppzv_dest, pzv_src); \
1.1 misho 801: if (copy) { \
802: zval_copy_ctor(*ppzv_dest); \
803: } \
804: Z_SET_ISREF_TO_PP(ppzv_dest, is_ref); \
805: Z_SET_REFCOUNT_PP(ppzv_dest, refcount); \
806: }
807:
808: #define SEPARATE_ARG_IF_REF(varptr) \
809: if (PZVAL_IS_REF(varptr)) { \
810: zval *original_var = varptr; \
811: ALLOC_ZVAL(varptr); \
1.1.1.2 misho 812: INIT_PZVAL_COPY(varptr, original_var); \
1.1 misho 813: zval_copy_ctor(varptr); \
814: } else { \
815: Z_ADDREF_P(varptr); \
816: }
817:
818: #define READY_TO_DESTROY(zv) \
819: (Z_REFCOUNT_P(zv) == 1 && \
820: (Z_TYPE_P(zv) != IS_OBJECT || \
821: zend_objects_store_get_refcount(zv TSRMLS_CC) == 1))
822:
823: #define ZEND_MAX_RESERVED_RESOURCES 4
824:
825: #include "zend_gc.h"
826: #include "zend_operators.h"
827: #include "zend_variables.h"
828:
829: typedef enum {
830: EH_NORMAL = 0,
831: EH_SUPPRESS,
832: EH_THROW
833: } zend_error_handling_t;
834:
835: typedef struct {
836: zend_error_handling_t handling;
837: zend_class_entry *exception;
838: zval *user_handler;
839: } zend_error_handling;
840:
841: ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
842: ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
843: ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
844:
845: #define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
846: #define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
847:
848: #endif /* ZEND_H */
849:
850: /*
851: * Local variables:
852: * tab-width: 4
853: * c-basic-offset: 4
854: * indent-tabs-mode: t
855: * End:
856: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>