Annotation of embedaddon/php/Zend/zend.h, revision 1.1.1.3.2.1.2.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | Zend Engine |
4: +----------------------------------------------------------------------+
1.1.1.3 misho 5: | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) |
1.1 misho 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.3.2.1.2 1(misho 20:4): /* $Id: zend.h,v 1.1.1.3.2.1 2013/10/14 08:17:38 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.3.2.1.2 1(misho 183:4): #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:
1.1.1.3 misho 353: #if ZEND_DEBUG
354: #define zend_always_inline inline
355: #define zend_never_inline
356: #else
1.1 misho 357: #if defined(__GNUC__)
358: #if __GNUC__ >= 3
359: #define zend_always_inline inline __attribute__((always_inline))
1.1.1.2 misho 360: #define zend_never_inline __attribute__((noinline))
1.1 misho 361: #else
362: #define zend_always_inline inline
1.1.1.2 misho 363: #define zend_never_inline
1.1 misho 364: #endif
365: #elif defined(_MSC_VER)
366: #define zend_always_inline __forceinline
1.1.1.2 misho 367: #define zend_never_inline
1.1 misho 368: #else
369: #define zend_always_inline inline
1.1.1.2 misho 370: #define zend_never_inline
1.1 misho 371: #endif
1.1.1.3 misho 372: #endif /* ZEND_DEBUG */
1.1 misho 373:
1.1.1.2 misho 374: #if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
1.1 misho 375: # define EXPECTED(condition) __builtin_expect(condition, 1)
376: # define UNEXPECTED(condition) __builtin_expect(condition, 0)
377: #else
378: # define EXPECTED(condition) (condition)
379: # define UNEXPECTED(condition) (condition)
380: #endif
381:
382: static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
383: return pz->refcount__gc;
384: }
385:
386: static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
387: return pz->refcount__gc = rc;
388: }
389:
390: static zend_always_inline zend_uint zval_addref_p(zval* pz) {
391: return ++pz->refcount__gc;
392: }
393:
394: static zend_always_inline zend_uint zval_delref_p(zval* pz) {
395: return --pz->refcount__gc;
396: }
397:
398: static zend_always_inline zend_bool zval_isref_p(zval* pz) {
399: return pz->is_ref__gc;
400: }
401:
402: static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
403: return pz->is_ref__gc = 1;
404: }
405:
406: static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
407: return pz->is_ref__gc = 0;
408: }
409:
410: static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) {
411: return pz->is_ref__gc = isref;
412: }
413:
414: /* excpt.h on Digital Unix 4.0 defines function_table */
415: #undef function_table
416:
417: /* A lot of stuff needs shifiting around in order to include zend_compile.h here */
418: union _zend_function;
419:
420: #include "zend_iterators.h"
421:
422: struct _zend_serialize_data;
423: struct _zend_unserialize_data;
424:
425: typedef struct _zend_serialize_data zend_serialize_data;
426: typedef struct _zend_unserialize_data zend_unserialize_data;
427:
1.1.1.2 misho 428: struct _zend_trait_method_reference {
429: const char* method_name;
430: unsigned int mname_len;
431:
432: zend_class_entry *ce;
433:
434: const char* class_name;
435: unsigned int cname_len;
436: };
437: typedef struct _zend_trait_method_reference zend_trait_method_reference;
438:
439: struct _zend_trait_precedence {
440: zend_trait_method_reference *trait_method;
441:
442: zend_class_entry** exclude_from_classes;
443:
1.1.1.3 misho 444: union _zend_function* function; /* FIXME: kept in 5.4 for BC, not used */
1.1.1.2 misho 445: };
446: typedef struct _zend_trait_precedence zend_trait_precedence;
447:
448: struct _zend_trait_alias {
449: zend_trait_method_reference *trait_method;
450:
451: /**
452: * name for method to be added
453: */
454: const char* alias;
455: unsigned int alias_len;
456:
457: /**
458: * modifiers to be set on trait method
459: */
460: zend_uint modifiers;
461:
1.1.1.3 misho 462: union _zend_function* function; /* FIXME: kept in 5.4 for BC, not used */
1.1.1.2 misho 463: };
464: typedef struct _zend_trait_alias zend_trait_alias;
465:
1.1 misho 466: struct _zend_class_entry {
467: char type;
1.1.1.2 misho 468: const char *name;
1.1 misho 469: zend_uint name_length;
470: struct _zend_class_entry *parent;
471: int refcount;
472: zend_uint ce_flags;
473:
474: HashTable function_table;
475: HashTable properties_info;
1.1.1.2 misho 476: zval **default_properties_table;
477: zval **default_static_members_table;
478: zval **static_members_table;
1.1 misho 479: HashTable constants_table;
1.1.1.2 misho 480: int default_properties_count;
481: int default_static_members_count;
1.1 misho 482:
483: union _zend_function *constructor;
484: union _zend_function *destructor;
485: union _zend_function *clone;
486: union _zend_function *__get;
487: union _zend_function *__set;
488: union _zend_function *__unset;
489: union _zend_function *__isset;
490: union _zend_function *__call;
491: union _zend_function *__callstatic;
492: union _zend_function *__tostring;
493: union _zend_function *serialize_func;
494: union _zend_function *unserialize_func;
495:
496: zend_class_iterator_funcs iterator_funcs;
497:
498: /* handlers */
499: zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
500: zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
501: int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
502: union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, int method_len TSRMLS_DC);
503:
504: /* serializer callbacks */
505: int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
506: int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
507:
508: zend_class_entry **interfaces;
509: zend_uint num_interfaces;
1.1.1.2 misho 510:
511: zend_class_entry **traits;
512: zend_uint num_traits;
513: zend_trait_alias **trait_aliases;
514: zend_trait_precedence **trait_precedences;
515:
516: union {
517: struct {
518: const char *filename;
519: zend_uint line_start;
520: zend_uint line_end;
521: const char *doc_comment;
522: zend_uint doc_comment_len;
523: } user;
524: struct {
525: const struct _zend_function_entry *builtin_functions;
526: struct _zend_module_entry *module;
527: } internal;
528: } info;
1.1 misho 529: };
530:
531: #include "zend_stream.h"
532: typedef struct _zend_utility_functions {
533: 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);
534: int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
535: int (*write_function)(const char *str, uint str_length);
536: FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
1.1.1.2 misho 537: void (*message_handler)(long message, const void *data TSRMLS_DC);
1.1 misho 538: void (*block_interruptions)(void);
539: void (*unblock_interruptions)(void);
540: int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
541: void (*ticks_function)(int ticks);
542: void (*on_timeout)(int seconds TSRMLS_DC);
543: int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
544: int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
545: char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
546: char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
547: } zend_utility_functions;
548:
549: typedef struct _zend_utility_values {
550: char *import_use_extension;
551: uint import_use_extension_length;
552: zend_bool html_errors;
553: } zend_utility_values;
554:
555: typedef int (*zend_write_func_t)(const char *str, uint str_length);
556:
557: #undef MIN
558: #undef MAX
559: #define MAX(a, b) (((a)>(b))?(a):(b))
560: #define MIN(a, b) (((a)<(b))?(a):(b))
561: #define ZEND_STRL(str) (str), (sizeof(str)-1)
562: #define ZEND_STRS(str) (str), (sizeof(str))
563: #define ZEND_NORMALIZE_BOOL(n) \
564: ((n) ? (((n)>0) ? 1 : -1) : 0)
565: #define ZEND_TRUTH(x) ((x) ? 1 : 0)
566: #define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
567:
568: /* data types */
569: /* All data types <= IS_BOOL have their constructor/destructors skipped */
570: #define IS_NULL 0
571: #define IS_LONG 1
572: #define IS_DOUBLE 2
573: #define IS_BOOL 3
574: #define IS_ARRAY 4
575: #define IS_OBJECT 5
576: #define IS_STRING 6
577: #define IS_RESOURCE 7
578: #define IS_CONSTANT 8
579: #define IS_CONSTANT_ARRAY 9
1.1.1.2 misho 580: #define IS_CALLABLE 10
1.1 misho 581:
582: /* Ugly hack to support constants as static array indices */
1.1.1.2 misho 583: #define IS_CONSTANT_TYPE_MASK 0x00f
584: #define IS_CONSTANT_UNQUALIFIED 0x010
585: #define IS_CONSTANT_INDEX 0x080
586: #define IS_LEXICAL_VAR 0x020
587: #define IS_LEXICAL_REF 0x040
588: #define IS_CONSTANT_IN_NAMESPACE 0x100
1.1 misho 589:
590: /* overloaded elements data types */
591: #define OE_IS_ARRAY (1<<0)
592: #define OE_IS_OBJECT (1<<1)
593: #define OE_IS_METHOD (1<<2)
594:
595: int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC);
596: void zend_shutdown(TSRMLS_D);
597: void zend_register_standard_ini_entries(TSRMLS_D);
598: void zend_post_startup(TSRMLS_D);
599: void zend_set_utility_values(zend_utility_values *utility_values);
600:
601: BEGIN_EXTERN_C()
602: ZEND_API void _zend_bailout(char *filename, uint lineno);
603: END_EXTERN_C()
604:
605: #define zend_bailout() _zend_bailout(__FILE__, __LINE__)
606:
607: #ifdef HAVE_SIGSETJMP
608: # define SETJMP(a) sigsetjmp(a, 0)
609: # define LONGJMP(a,b) siglongjmp(a, b)
610: # define JMP_BUF sigjmp_buf
611: #else
612: # define SETJMP(a) setjmp(a)
613: # define LONGJMP(a,b) longjmp(a, b)
614: # define JMP_BUF jmp_buf
615: #endif
616:
617: #define zend_try \
618: { \
619: JMP_BUF *__orig_bailout = EG(bailout); \
620: JMP_BUF __bailout; \
621: \
622: EG(bailout) = &__bailout; \
623: if (SETJMP(__bailout)==0) {
624: #define zend_catch \
625: } else { \
626: EG(bailout) = __orig_bailout;
627: #define zend_end_try() \
628: } \
629: EG(bailout) = __orig_bailout; \
630: }
631: #define zend_first_try EG(bailout)=NULL; zend_try
632:
633: BEGIN_EXTERN_C()
634: ZEND_API char *get_zend_version(void);
635: ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
636: ZEND_API int zend_print_zval(zval *expr, int indent);
637: ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
638: ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
639: ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
640: ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
641: ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
642: END_EXTERN_C()
643:
644: void zend_activate(TSRMLS_D);
645: void zend_deactivate(TSRMLS_D);
646: void zend_call_destructors(TSRMLS_D);
647: void zend_activate_modules(TSRMLS_D);
648: void zend_deactivate_modules(TSRMLS_D);
649: void zend_post_deactivate_modules(TSRMLS_D);
650:
651: #if ZEND_DEBUG
652: #define Z_DBG(expr) (expr)
653: #else
654: #define Z_DBG(expr)
655: #endif
656:
657: BEGIN_EXTERN_C()
658: ZEND_API void free_estring(char **str_p);
659: END_EXTERN_C()
660:
661: /* FIXME: Check if we can save if (ptr) too */
662:
1.1.1.2 misho 663: #define STR_FREE(ptr) if (ptr && !IS_INTERNED(ptr)) { efree(ptr); }
664: #define STR_FREE_REL(ptr) if (ptr && !IS_INTERNED(ptr)) { efree_rel(ptr); }
1.1 misho 665:
666: #define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
667:
668: #define STR_REALLOC(ptr, size) \
669: ptr = (char *) erealloc(ptr, size);
670:
671: /* output support */
672: #define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
673: #define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
674: #define ZEND_PUTS(str) zend_write((str), strlen((str)))
675: #define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
676: #define ZEND_PUTC(c) zend_write(&(c), 1), (c)
677:
678: BEGIN_EXTERN_C()
679: extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
680: extern ZEND_API zend_write_func_t zend_write;
681: extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
682: extern ZEND_API void (*zend_block_interruptions)(void);
683: extern ZEND_API void (*zend_unblock_interruptions)(void);
684: extern ZEND_API void (*zend_ticks_function)(int ticks);
685: 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 686: extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
1.1 misho 687: extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
688: extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
689: extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
690: extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
691:
692: ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
693:
694: void zenderror(const char *error);
695:
696: /* The following #define is used for code duality in PHP for Engine 1 & 2 */
697: #define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
698: extern ZEND_API zend_class_entry *zend_standard_class_def;
699: extern ZEND_API zend_utility_values zend_uv;
700: extern ZEND_API zval zval_used_for_init;
701:
702: END_EXTERN_C()
703:
704: #define ZEND_UV(name) (zend_uv.name)
705:
1.1.1.2 misho 706: #ifndef ZEND_SIGNALS
1.1 misho 707: #define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
708: #define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
1.1.1.2 misho 709: #else
710: #include "zend_signal.h"
711:
712: #define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPUTIONS()
713: #define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
714: #endif
1.1 misho 715:
716: BEGIN_EXTERN_C()
1.1.1.2 misho 717: ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
1.1 misho 718:
719: ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
720: END_EXTERN_C()
721:
722: /* Messages for applications of Zend */
723: #define ZMSG_FAILED_INCLUDE_FOPEN 1L
724: #define ZMSG_FAILED_REQUIRE_FOPEN 2L
725: #define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
726: #define ZMSG_MEMORY_LEAK_DETECTED 4L
727: #define ZMSG_MEMORY_LEAK_REPEATED 5L
728: #define ZMSG_LOG_SCRIPT_NAME 6L
729: #define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
730:
731: #define INIT_PZVAL(z) \
732: (z)->refcount__gc = 1; \
733: (z)->is_ref__gc = 0;
734:
735: #define INIT_ZVAL(z) z = zval_used_for_init;
736:
737: #define ALLOC_INIT_ZVAL(zp) \
738: ALLOC_ZVAL(zp); \
739: INIT_ZVAL(*zp);
740:
741: #define MAKE_STD_ZVAL(zv) \
742: ALLOC_ZVAL(zv); \
743: INIT_PZVAL(zv);
744:
745: #define PZVAL_IS_REF(z) Z_ISREF_P(z)
746:
1.1.1.2 misho 747: #define ZVAL_COPY_VALUE(z, v) \
748: do { \
749: (z)->value = (v)->value; \
750: Z_TYPE_P(z) = Z_TYPE_P(v); \
751: } while (0)
752:
753: #define INIT_PZVAL_COPY(z, v) \
754: do { \
755: ZVAL_COPY_VALUE(z, v); \
756: Z_SET_REFCOUNT_P(z, 1); \
757: Z_UNSET_ISREF_P(z); \
758: } while (0)
759:
760: #define SEPARATE_ZVAL(ppzv) \
761: do { \
762: if (Z_REFCOUNT_PP((ppzv)) > 1) { \
763: zval *new_zv; \
764: Z_DELREF_PP(ppzv); \
765: ALLOC_ZVAL(new_zv); \
766: INIT_PZVAL_COPY(new_zv, *(ppzv)); \
767: *(ppzv) = new_zv; \
768: zval_copy_ctor(new_zv); \
769: } \
770: } while (0)
1.1 misho 771:
772: #define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
773: if (!PZVAL_IS_REF(*ppzv)) { \
774: SEPARATE_ZVAL(ppzv); \
775: }
776:
777: #define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
778: if (!PZVAL_IS_REF(*ppzv)) { \
779: SEPARATE_ZVAL(ppzv); \
780: Z_SET_ISREF_PP((ppzv)); \
781: }
782:
783: #define COPY_PZVAL_TO_ZVAL(zv, pzv) \
784: (zv) = *(pzv); \
785: if (Z_REFCOUNT_P(pzv)>1) { \
786: zval_copy_ctor(&(zv)); \
787: Z_DELREF_P((pzv)); \
788: } else { \
789: FREE_ZVAL(pzv); \
790: } \
791: INIT_PZVAL(&(zv));
792:
1.1.1.2 misho 793: #define MAKE_COPY_ZVAL(ppzv, pzv) \
794: INIT_PZVAL_COPY(pzv, *(ppzv)); \
795: zval_copy_ctor((pzv));
1.1 misho 796:
797: #define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
798: int is_ref, refcount; \
799: \
800: SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
801: is_ref = Z_ISREF_PP(ppzv_dest); \
802: refcount = Z_REFCOUNT_PP(ppzv_dest); \
803: zval_dtor(*ppzv_dest); \
1.1.1.2 misho 804: ZVAL_COPY_VALUE(*ppzv_dest, pzv_src); \
1.1 misho 805: if (copy) { \
806: zval_copy_ctor(*ppzv_dest); \
807: } \
808: Z_SET_ISREF_TO_PP(ppzv_dest, is_ref); \
809: Z_SET_REFCOUNT_PP(ppzv_dest, refcount); \
810: }
811:
812: #define SEPARATE_ARG_IF_REF(varptr) \
813: if (PZVAL_IS_REF(varptr)) { \
814: zval *original_var = varptr; \
815: ALLOC_ZVAL(varptr); \
1.1.1.2 misho 816: INIT_PZVAL_COPY(varptr, original_var); \
1.1 misho 817: zval_copy_ctor(varptr); \
818: } else { \
819: Z_ADDREF_P(varptr); \
820: }
821:
822: #define READY_TO_DESTROY(zv) \
823: (Z_REFCOUNT_P(zv) == 1 && \
824: (Z_TYPE_P(zv) != IS_OBJECT || \
825: zend_objects_store_get_refcount(zv TSRMLS_CC) == 1))
826:
827: #define ZEND_MAX_RESERVED_RESOURCES 4
828:
829: #include "zend_gc.h"
830: #include "zend_operators.h"
831: #include "zend_variables.h"
832:
833: typedef enum {
834: EH_NORMAL = 0,
835: EH_SUPPRESS,
836: EH_THROW
837: } zend_error_handling_t;
838:
839: typedef struct {
840: zend_error_handling_t handling;
841: zend_class_entry *exception;
842: zval *user_handler;
843: } zend_error_handling;
844:
845: ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
846: ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
847: ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
848:
849: #define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
850: #define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
851:
852: #endif /* ZEND_H */
853:
854: /*
855: * Local variables:
856: * tab-width: 4
857: * c-basic-offset: 4
858: * indent-tabs-mode: t
859: * End:
860: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>