Deleted Added
full compact
zend.h (2b9b9afa) zend.h (1e752ce9)
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998-2014 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 |

--- 8 unchanged lines hidden (view full) ---

17 +----------------------------------------------------------------------+
18*/
19
20/* $Id$ */
21
22#ifndef ZEND_H
23#define ZEND_H
24
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998-2014 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 |

--- 8 unchanged lines hidden (view full) ---

17 +----------------------------------------------------------------------+
18*/
19
20/* $Id$ */
21
22#ifndef ZEND_H
23#define ZEND_H
24
25#define ZEND_VERSION "2.7.0-dev"
25#define ZEND_VERSION "2.6.0-dev"
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()

--- 27 unchanged lines hidden (view full) ---

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>
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()

--- 27 unchanged lines hidden (view full) ---

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#include <assert.h>
70
71#ifdef HAVE_UNIX_H
72# include <unix.h>
73#endif
74
75#ifdef HAVE_STDARG_H
76# include <stdarg.h>
77#endif

--- 170 unchanged lines hidden (view full) ---

248#else
249#define ZTS_V 0
250#endif
251
252#include "zend_errors.h"
253#include "zend_alloc.h"
254
255#include "zend_types.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

--- 170 unchanged lines hidden (view full) ---

247#else
248#define ZTS_V 0
249#endif
250
251#include "zend_errors.h"
252#include "zend_alloc.h"
253
254#include "zend_types.h"
255#include "zend_string.h"
256
257#ifdef HAVE_LIMITS_H
258# include <limits.h>
259#endif
260
261#ifndef LONG_MAX
262#define LONG_MAX 2147483647L
263#endif

--- 15 unchanged lines hidden (view full) ---

279#define MAX_LENGTH_OF_DOUBLE 32
280
281typedef enum {
282 SUCCESS = 0,
283 FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */
284} ZEND_RESULT_CODE;
285
286#include "zend_hash.h"
256
257#ifdef HAVE_LIMITS_H
258# include <limits.h>
259#endif
260
261#ifndef LONG_MAX
262#define LONG_MAX 2147483647L
263#endif

--- 15 unchanged lines hidden (view full) ---

279#define MAX_LENGTH_OF_DOUBLE 32
280
281typedef enum {
282 SUCCESS = 0,
283 FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */
284} ZEND_RESULT_CODE;
285
286#include "zend_hash.h"
287#include "zend_ts_hash.h"
287#include "zend_llist.h"
288
288#include "zend_llist.h"
289
289#define INTERNAL_FUNCTION_PARAMETERS zend_uint param_count, zval *return_value, zval *this_ptr, int return_value_used TSRMLS_DC
290#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value, this_ptr, return_value_used TSRMLS_CC
290#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
291#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
291
292#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
293void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
294#else
295# define zend_error_noreturn zend_error
296#endif
297
292
293#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
294void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
295#else
296# define zend_error_noreturn zend_error
297#endif
298
299/*
300 * zval
301 */
302typedef struct _zend_class_entry zend_class_entry;
303
304typedef struct _zend_guard {
305 zend_bool in_get;
306 zend_bool in_set;
307 zend_bool in_unset;
308 zend_bool in_isset;
309 zend_bool dummy; /* sizeof(zend_guard) must not be equal to sizeof(void*) */
310} zend_guard;
311
312typedef struct _zend_object {
313 zend_class_entry *ce;
314 HashTable *properties;
315 zval **properties_table;
316 HashTable *guards; /* protects from __get/__set ... recursion */
317} zend_object;
318
298#include "zend_object_handlers.h"
299#include "zend_ast.h"
300
319#include "zend_object_handlers.h"
320#include "zend_ast.h"
321
301/* overloaded elements data types */
302#define OE_IS_ARRAY (1<<0)
303#define OE_IS_OBJECT (1<<1)
304#define OE_IS_METHOD (1<<2)
322typedef union _zvalue_value {
323 long lval; /* long value */
324 double dval; /* double value */
325 struct {
326 char *val;
327 int len;
328 } str;
329 HashTable *ht; /* hash table value */
330 zend_object_value obj;
331 zend_ast *ast;
332} zvalue_value;
305
333
306#define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
334struct _zval_struct {
335 /* Variable information */
336 zvalue_value value; /* value */
337 zend_uint refcount__gc;
338 zend_uchar type; /* active type */
339 zend_uchar is_ref__gc;
340};
341
342#define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz))
343#define Z_SET_REFCOUNT_PP(ppz, rc) Z_SET_REFCOUNT_P(*(ppz), rc)
344#define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz))
345#define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz))
346#define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz))
347#define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz))
348#define Z_UNSET_ISREF_PP(ppz) Z_UNSET_ISREF_P(*(ppz))
349#define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref)
350
351#define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
307#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
352#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
308#define Z_ADDREF_P(pz) zval_addref_p(pz)
309#define Z_DELREF_P(pz) zval_delref_p(pz)
353#define Z_ADDREF_P(pz) zval_addref_p(pz)
354#define Z_DELREF_P(pz) zval_delref_p(pz)
355#define Z_ISREF_P(pz) zval_isref_p(pz)
356#define Z_SET_ISREF_P(pz) zval_set_isref_p(pz)
357#define Z_UNSET_ISREF_P(pz) zval_unset_isref_p(pz)
358#define Z_SET_ISREF_TO_P(pz, isref) zval_set_isref_to_p(pz, isref)
310
359
311#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
360#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
312#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
361#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
313#define Z_ADDREF(z) Z_ADDREF_P(&(z))
314#define Z_DELREF(z) Z_DELREF_P(&(z))
362#define Z_ADDREF(z) Z_ADDREF_P(&(z))
363#define Z_DELREF(z) Z_DELREF_P(&(z))
364#define Z_ISREF(z) Z_ISREF_P(&(z))
365#define Z_SET_ISREF(z) Z_SET_ISREF_P(&(z))
366#define Z_UNSET_ISREF(z) Z_UNSET_ISREF_P(&(z))
367#define Z_SET_ISREF_TO(z, isref) Z_SET_ISREF_TO_P(&(z), isref)
315
316#if ZEND_DEBUG
317#define zend_always_inline inline
318#define zend_never_inline
319#else
320#if defined(__GNUC__)
321#if __GNUC__ >= 3
322#define zend_always_inline inline __attribute__((always_inline))

--- 14 unchanged lines hidden (view full) ---

337#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
338# define EXPECTED(condition) __builtin_expect(condition, 1)
339# define UNEXPECTED(condition) __builtin_expect(condition, 0)
340#else
341# define EXPECTED(condition) (condition)
342# define UNEXPECTED(condition) (condition)
343#endif
344
368
369#if ZEND_DEBUG
370#define zend_always_inline inline
371#define zend_never_inline
372#else
373#if defined(__GNUC__)
374#if __GNUC__ >= 3
375#define zend_always_inline inline __attribute__((always_inline))

--- 14 unchanged lines hidden (view full) ---

390#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
391# define EXPECTED(condition) __builtin_expect(condition, 1)
392# define UNEXPECTED(condition) __builtin_expect(condition, 0)
393#else
394# define EXPECTED(condition) (condition)
395# define UNEXPECTED(condition) (condition)
396#endif
397
345#include "zend_string.h"
346
347static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
398static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
348 ZEND_ASSERT(Z_REFCOUNTED_P(pz));
349 return Z_COUNTED_P(pz)->refcount;
399 return pz->refcount__gc;
350}
351
352static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
400}
401
402static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
353 ZEND_ASSERT(Z_REFCOUNTED_P(pz));
354 return Z_COUNTED_P(pz)->refcount = rc;
403 return pz->refcount__gc = rc;
355}
356
357static zend_always_inline zend_uint zval_addref_p(zval* pz) {
404}
405
406static zend_always_inline zend_uint zval_addref_p(zval* pz) {
358 ZEND_ASSERT(Z_REFCOUNTED_P(pz));
359 return ++Z_COUNTED_P(pz)->refcount;
407 return ++pz->refcount__gc;
360}
361
362static zend_always_inline zend_uint zval_delref_p(zval* pz) {
408}
409
410static zend_always_inline zend_uint zval_delref_p(zval* pz) {
363 ZEND_ASSERT(Z_REFCOUNTED_P(pz));
364 return --Z_COUNTED_P(pz)->refcount;
411 return --pz->refcount__gc;
365}
366
412}
413
414static zend_always_inline zend_bool zval_isref_p(zval* pz) {
415 return pz->is_ref__gc;
416}
417
418static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
419 return pz->is_ref__gc = 1;
420}
421
422static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
423 return pz->is_ref__gc = 0;
424}
425
426static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) {
427 return pz->is_ref__gc = isref;
428}
429
367/* excpt.h on Digital Unix 4.0 defines function_table */
368#undef function_table
369
370/* A lot of stuff needs shifiting around in order to include zend_compile.h here */
371union _zend_function;
372
373#include "zend_iterators.h"
374
375struct _zend_serialize_data;
376struct _zend_unserialize_data;
377
378typedef struct _zend_serialize_data zend_serialize_data;
379typedef struct _zend_unserialize_data zend_unserialize_data;
380
381struct _zend_trait_method_reference {
430/* excpt.h on Digital Unix 4.0 defines function_table */
431#undef function_table
432
433/* A lot of stuff needs shifiting around in order to include zend_compile.h here */
434union _zend_function;
435
436#include "zend_iterators.h"
437
438struct _zend_serialize_data;
439struct _zend_unserialize_data;
440
441typedef struct _zend_serialize_data zend_serialize_data;
442typedef struct _zend_unserialize_data zend_unserialize_data;
443
444struct _zend_trait_method_reference {
382 zend_string *method_name;
445 const char* method_name;
446 unsigned int mname_len;
447
383 zend_class_entry *ce;
448 zend_class_entry *ce;
384 zend_string *class_name;
449
450 const char* class_name;
451 unsigned int cname_len;
385};
386typedef struct _zend_trait_method_reference zend_trait_method_reference;
387
388struct _zend_trait_precedence {
452};
453typedef struct _zend_trait_method_reference zend_trait_method_reference;
454
455struct _zend_trait_precedence {
389 zend_trait_method_reference *trait_method;
390 union {
391 zend_class_entry *ce;
392 zend_string *class_name;
393 } *exclude_from_classes;
456 zend_trait_method_reference *trait_method;
457
458 zend_class_entry** exclude_from_classes;
394};
395typedef struct _zend_trait_precedence zend_trait_precedence;
396
397struct _zend_trait_alias {
398 zend_trait_method_reference *trait_method;
399
400 /**
401 * name for method to be added
402 */
459};
460typedef struct _zend_trait_precedence zend_trait_precedence;
461
462struct _zend_trait_alias {
463 zend_trait_method_reference *trait_method;
464
465 /**
466 * name for method to be added
467 */
403 zend_string *alias;
468 const char* alias;
469 unsigned int alias_len;
404
405 /**
406 * modifiers to be set on trait method
407 */
408 zend_uint modifiers;
409};
410typedef struct _zend_trait_alias zend_trait_alias;
411
412struct _zend_class_entry {
413 char type;
470
471 /**
472 * modifiers to be set on trait method
473 */
474 zend_uint modifiers;
475};
476typedef struct _zend_trait_alias zend_trait_alias;
477
478struct _zend_class_entry {
479 char type;
414 zend_string *name;
480 const char *name;
481 zend_uint name_length;
415 struct _zend_class_entry *parent;
416 int refcount;
417 zend_uint ce_flags;
418
419 HashTable function_table;
420 HashTable properties_info;
482 struct _zend_class_entry *parent;
483 int refcount;
484 zend_uint ce_flags;
485
486 HashTable function_table;
487 HashTable properties_info;
421 zval *default_properties_table;
422 zval *default_static_members_table;
423 zval *static_members_table;
488 zval **default_properties_table;
489 zval **default_static_members_table;
490 zval **static_members_table;
424 HashTable constants_table;
425 int default_properties_count;
426 int default_static_members_count;
427
428 union _zend_function *constructor;
429 union _zend_function *destructor;
430 union _zend_function *clone;
431 union _zend_function *__get;
432 union _zend_function *__set;
433 union _zend_function *__unset;
434 union _zend_function *__isset;
435 union _zend_function *__call;
436 union _zend_function *__callstatic;
437 union _zend_function *__tostring;
491 HashTable constants_table;
492 int default_properties_count;
493 int default_static_members_count;
494
495 union _zend_function *constructor;
496 union _zend_function *destructor;
497 union _zend_function *clone;
498 union _zend_function *__get;
499 union _zend_function *__set;
500 union _zend_function *__unset;
501 union _zend_function *__isset;
502 union _zend_function *__call;
503 union _zend_function *__callstatic;
504 union _zend_function *__tostring;
505 union _zend_function *__debugInfo;
438 union _zend_function *serialize_func;
439 union _zend_function *unserialize_func;
440
441 zend_class_iterator_funcs iterator_funcs;
442
443 /* handlers */
506 union _zend_function *serialize_func;
507 union _zend_function *unserialize_func;
508
509 zend_class_iterator_funcs iterator_funcs;
510
511 /* handlers */
444 zend_object* (*create_object)(zend_class_entry *class_type TSRMLS_DC);
512 zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
445 zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
446 int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
513 zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
514 int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
447 union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method TSRMLS_DC);
515 union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, int method_len TSRMLS_DC);
448
449 /* serializer callbacks */
450 int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
516
517 /* serializer callbacks */
518 int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
451 int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
519 int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
452
453 zend_class_entry **interfaces;
454 zend_uint num_interfaces;
455
456 zend_class_entry **traits;
457 zend_uint num_traits;
458 zend_trait_alias **trait_aliases;
459 zend_trait_precedence **trait_precedences;
460
461 union {
462 struct {
520
521 zend_class_entry **interfaces;
522 zend_uint num_interfaces;
523
524 zend_class_entry **traits;
525 zend_uint num_traits;
526 zend_trait_alias **trait_aliases;
527 zend_trait_precedence **trait_precedences;
528
529 union {
530 struct {
463 zend_string *filename;
531 const char *filename;
464 zend_uint line_start;
465 zend_uint line_end;
532 zend_uint line_start;
533 zend_uint line_end;
466 zend_string *doc_comment;
534 const char *doc_comment;
535 zend_uint doc_comment_len;
467 } user;
468 struct {
469 const struct _zend_function_entry *builtin_functions;
470 struct _zend_module_entry *module;
471 } internal;
472 } info;
473};
474
475#include "zend_stream.h"
476typedef struct _zend_utility_functions {
477 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);
478 int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
479 int (*write_function)(const char *str, uint str_length);
480 FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
481 void (*message_handler)(long message, const void *data TSRMLS_DC);
482 void (*block_interruptions)(void);
483 void (*unblock_interruptions)(void);
484 int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
536 } user;
537 struct {
538 const struct _zend_function_entry *builtin_functions;
539 struct _zend_module_entry *module;
540 } internal;
541 } info;
542};
543
544#include "zend_stream.h"
545typedef struct _zend_utility_functions {
546 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);
547 int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
548 int (*write_function)(const char *str, uint str_length);
549 FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
550 void (*message_handler)(long message, const void *data TSRMLS_DC);
551 void (*block_interruptions)(void);
552 void (*unblock_interruptions)(void);
553 int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
485 void (*ticks_function)(int ticks TSRMLS_DC);
554 void (*ticks_function)(int ticks);
486 void (*on_timeout)(int seconds TSRMLS_DC);
487 int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
488 int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
489 char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
490 char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
491} zend_utility_functions;
492
493typedef struct _zend_utility_values {

--- 10 unchanged lines hidden (view full) ---

504#define MIN(a, b) (((a)<(b))?(a):(b))
505#define ZEND_STRL(str) (str), (sizeof(str)-1)
506#define ZEND_STRS(str) (str), (sizeof(str))
507#define ZEND_NORMALIZE_BOOL(n) \
508 ((n) ? (((n)>0) ? 1 : -1) : 0)
509#define ZEND_TRUTH(x) ((x) ? 1 : 0)
510#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
511
555 void (*on_timeout)(int seconds TSRMLS_DC);
556 int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
557 int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
558 char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
559 char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
560} zend_utility_functions;
561
562typedef struct _zend_utility_values {

--- 10 unchanged lines hidden (view full) ---

573#define MIN(a, b) (((a)<(b))?(a):(b))
574#define ZEND_STRL(str) (str), (sizeof(str)-1)
575#define ZEND_STRS(str) (str), (sizeof(str))
576#define ZEND_NORMALIZE_BOOL(n) \
577 ((n) ? (((n)>0) ? 1 : -1) : 0)
578#define ZEND_TRUTH(x) ((x) ? 1 : 0)
579#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
580
581/* data types */
582/* All data types <= IS_BOOL have their constructor/destructors skipped */
583#define IS_NULL 0
584#define IS_LONG 1
585#define IS_DOUBLE 2
586#define IS_BOOL 3
587#define IS_ARRAY 4
588#define IS_OBJECT 5
589#define IS_STRING 6
590#define IS_RESOURCE 7
591#define IS_CONSTANT 8
592#define IS_CONSTANT_ARRAY 9
593#define IS_CONSTANT_AST 10
594#define IS_CALLABLE 11
595
596/* Ugly hack to support constants as static array indices */
597#define IS_CONSTANT_TYPE_MASK 0x00f
598#define IS_CONSTANT_UNQUALIFIED 0x010
599#define IS_CONSTANT_INDEX 0x080
600#define IS_LEXICAL_VAR 0x020
601#define IS_LEXICAL_REF 0x040
602#define IS_CONSTANT_IN_NAMESPACE 0x100
603
604#define IS_CONSTANT_TYPE(type) (((type) & IS_CONSTANT_TYPE_MASK) >= IS_CONSTANT && ((type) & IS_CONSTANT_TYPE_MASK) <= IS_CONSTANT_AST)
605
606/* overloaded elements data types */
607#define OE_IS_ARRAY (1<<0)
608#define OE_IS_OBJECT (1<<1)
609#define OE_IS_METHOD (1<<2)
610
512int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC);
513void zend_shutdown(TSRMLS_D);
514void zend_register_standard_ini_entries(TSRMLS_D);
515void zend_post_startup(TSRMLS_D);
516void zend_set_utility_values(zend_utility_values *utility_values);
517
518BEGIN_EXTERN_C()
519ZEND_API void _zend_bailout(char *filename, uint lineno);

--- 50 unchanged lines hidden (view full) ---

570#if ZEND_DEBUG
571#define Z_DBG(expr) (expr)
572#else
573#define Z_DBG(expr)
574#endif
575
576BEGIN_EXTERN_C()
577ZEND_API void free_estring(char **str_p);
611int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC);
612void zend_shutdown(TSRMLS_D);
613void zend_register_standard_ini_entries(TSRMLS_D);
614void zend_post_startup(TSRMLS_D);
615void zend_set_utility_values(zend_utility_values *utility_values);
616
617BEGIN_EXTERN_C()
618ZEND_API void _zend_bailout(char *filename, uint lineno);

--- 50 unchanged lines hidden (view full) ---

669#if ZEND_DEBUG
670#define Z_DBG(expr) (expr)
671#else
672#define Z_DBG(expr)
673#endif
674
675BEGIN_EXTERN_C()
676ZEND_API void free_estring(char **str_p);
578ZEND_API void free_string_zval(zval *zv);
579END_EXTERN_C()
580
581/* FIXME: Check if we can save if (ptr) too */
582
677END_EXTERN_C()
678
679/* FIXME: Check if we can save if (ptr) too */
680
583//???#define STR_FREE(ptr) if (ptr) { str_efree(ptr); }
584//???#define STR_FREE_REL(ptr) if (ptr) { str_efree_rel(ptr); }
681#define STR_FREE(ptr) if (ptr) { str_efree(ptr); }
682#define STR_FREE_REL(ptr) if (ptr) { str_efree_rel(ptr); }
585
683
684#ifndef ZTS
685#define STR_EMPTY_ALLOC() CG(interned_empty_string)? CG(interned_empty_string) : estrndup("", sizeof("")-1)
686#else
687#define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
688#endif
689
690#define STR_REALLOC(ptr, size) \
691 ptr = (char *) erealloc(ptr, size);
692
586/* output support */
587#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
588#define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
589#define ZEND_PUTS(str) zend_write((str), strlen((str)))
590#define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
591#define ZEND_PUTC(c) zend_write(&(c), 1)
592
593BEGIN_EXTERN_C()
594extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
595extern ZEND_API zend_write_func_t zend_write;
596extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
597extern ZEND_API void (*zend_block_interruptions)(void);
598extern ZEND_API void (*zend_unblock_interruptions)(void);
693/* output support */
694#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
695#define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
696#define ZEND_PUTS(str) zend_write((str), strlen((str)))
697#define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
698#define ZEND_PUTC(c) zend_write(&(c), 1)
699
700BEGIN_EXTERN_C()
701extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
702extern ZEND_API zend_write_func_t zend_write;
703extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
704extern ZEND_API void (*zend_block_interruptions)(void);
705extern ZEND_API void (*zend_unblock_interruptions)(void);
599extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
706extern ZEND_API void (*zend_ticks_function)(int ticks);
600extern 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);
601extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
602extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
603extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
604extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
605extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
606
607ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);

--- 30 unchanged lines hidden (view full) ---

638#define ZMSG_FAILED_INCLUDE_FOPEN 1L
639#define ZMSG_FAILED_REQUIRE_FOPEN 2L
640#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
641#define ZMSG_MEMORY_LEAK_DETECTED 4L
642#define ZMSG_MEMORY_LEAK_REPEATED 5L
643#define ZMSG_LOG_SCRIPT_NAME 6L
644#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
645
707extern 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);
708extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
709extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
710extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
711extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
712extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
713
714ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);

--- 30 unchanged lines hidden (view full) ---

745#define ZMSG_FAILED_INCLUDE_FOPEN 1L
746#define ZMSG_FAILED_REQUIRE_FOPEN 2L
747#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
748#define ZMSG_MEMORY_LEAK_DETECTED 4L
749#define ZMSG_MEMORY_LEAK_REPEATED 5L
750#define ZMSG_LOG_SCRIPT_NAME 6L
751#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
752
753#define INIT_PZVAL(z) \
754 (z)->refcount__gc = 1; \
755 (z)->is_ref__gc = 0;
756
757#define INIT_ZVAL(z) z = zval_used_for_init;
758
759#define ALLOC_INIT_ZVAL(zp) \
760 ALLOC_ZVAL(zp); \
761 INIT_ZVAL(*zp);
762
763#define MAKE_STD_ZVAL(zv) \
764 ALLOC_ZVAL(zv); \
765 INIT_PZVAL(zv);
766
767#define PZVAL_IS_REF(z) Z_ISREF_P(z)
768
646#define ZVAL_COPY_VALUE(z, v) \
647 do { \
648 (z)->value = (v)->value; \
649 Z_TYPE_P(z) = Z_TYPE_P(v); \
650 } while (0)
651
769#define ZVAL_COPY_VALUE(z, v) \
770 do { \
771 (z)->value = (v)->value; \
772 Z_TYPE_P(z) = Z_TYPE_P(v); \
773 } while (0)
774
652#define ZVAL_COPY(z, v) \
653 do { \
654 ZVAL_COPY_VALUE(z, v); \
655 if (Z_REFCOUNTED_P(z)) { \
656 Z_ADDREF_P(z); \
657 } \
658 } while (0)
659
660#define ZVAL_DUP(z, v) \
661 do { \
662 ZVAL_COPY_VALUE(z, v); \
663 zval_copy_ctor(z); \
664 } while (0)
665
666#define ZVAL_DUP_DEREF(z, v) \
667 do { \
668 if (Z_ISREF_P(v)) { \
669 ZVAL_COPY_VALUE(z, Z_REFVAL_P(v)); \
670 } else { \
671 ZVAL_COPY_VALUE(z, v); \
672 } \
673 zval_copy_ctor(z); \
674 } while (0)
675
676#define INIT_PZVAL_COPY(z, v) \
677 do { \
678 ZVAL_COPY_VALUE(z, v); \
679 Z_SET_REFCOUNT_P(z, 1); \
680 Z_UNSET_ISREF_P(z); \
681 } while (0)
682
775#define INIT_PZVAL_COPY(z, v) \
776 do { \
777 ZVAL_COPY_VALUE(z, v); \
778 Z_SET_REFCOUNT_P(z, 1); \
779 Z_UNSET_ISREF_P(z); \
780 } while (0)
781
683// TODO: support objects and resources???
684#define SEPARATE_ZVAL(zv) do { \
685 if (Z_REFCOUNTED_P(zv)) { \
686 if (Z_REFCOUNT_P(zv) > 1) { \
687 Z_DELREF_P(zv); \
688 zval_copy_ctor(zv); \
689 Z_SET_REFCOUNT_P(zv, 1); \
690 } \
782#define SEPARATE_ZVAL(ppzv) \
783 do { \
784 if (Z_REFCOUNT_PP((ppzv)) > 1) { \
785 zval *new_zv; \
786 Z_DELREF_PP(ppzv); \
787 ALLOC_ZVAL(new_zv); \
788 INIT_PZVAL_COPY(new_zv, *(ppzv)); \
789 *(ppzv) = new_zv; \
790 zval_copy_ctor(new_zv); \
691 } \
692 } while (0)
693
791 } \
792 } while (0)
793
694#define SEPARATE_ZVAL_IF_NOT_REF(zv) \
695 if (!Z_ISREF_P(zv)) { \
696 SEPARATE_ZVAL(zv); \
794#define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
795 if (!PZVAL_IS_REF(*ppzv)) { \
796 SEPARATE_ZVAL(ppzv); \
697 }
698
797 }
798
699#define SEPARATE_ZVAL_IF_REF(zv) \
700 if (Z_ISREF_P(zv)) { \
701 SEPARATE_ZVAL(zv); \
799#define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
800 if (!PZVAL_IS_REF(*ppzv)) { \
801 SEPARATE_ZVAL(ppzv); \
802 Z_SET_ISREF_PP((ppzv)); \
702 }
703
803 }
804
704#define SEPARATE_ZVAL_TO_MAKE_IS_REF(zv) \
705 if (!Z_ISREF_P(zv)) { \
706 zval ref; \
707 ZVAL_COPY_VALUE(&ref, zv); \
708 SEPARATE_ZVAL(&ref); \
709 ZVAL_NEW_REF(zv, &ref); \
710 }
711
712#define COPY_PZVAL_TO_ZVAL(zv, pzv) \
805#define COPY_PZVAL_TO_ZVAL(zv, pzv) \
713 ZVAL_COPY_VALUE(&(zv), (pzv)); \
806 (zv) = *(pzv); \
714 if (Z_REFCOUNT_P(pzv)>1) { \
715 zval_copy_ctor(&(zv)); \
716 Z_DELREF_P((pzv)); \
807 if (Z_REFCOUNT_P(pzv)>1) { \
808 zval_copy_ctor(&(zv)); \
809 Z_DELREF_P((pzv)); \
810 } else { \
811 FREE_ZVAL(pzv); \
717 } \
812 } \
813 INIT_PZVAL(&(zv));
814
815#define MAKE_COPY_ZVAL(ppzv, pzv) \
816 INIT_PZVAL_COPY(pzv, *(ppzv)); \
817 zval_copy_ctor((pzv));
718
719#define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
720 int is_ref, refcount; \
721 \
722 SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
723 is_ref = Z_ISREF_PP(ppzv_dest); \
724 refcount = Z_REFCOUNT_PP(ppzv_dest); \
725 zval_dtor(*ppzv_dest); \
726 ZVAL_COPY_VALUE(*ppzv_dest, pzv_src); \
727 if (copy) { \
728 zval_copy_ctor(*ppzv_dest); \
729 } \
730 Z_SET_ISREF_TO_PP(ppzv_dest, is_ref); \
731 Z_SET_REFCOUNT_PP(ppzv_dest, refcount); \
732}
733
734#define SEPARATE_ARG_IF_REF(varptr) \
818
819#define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
820 int is_ref, refcount; \
821 \
822 SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
823 is_ref = Z_ISREF_PP(ppzv_dest); \
824 refcount = Z_REFCOUNT_PP(ppzv_dest); \
825 zval_dtor(*ppzv_dest); \
826 ZVAL_COPY_VALUE(*ppzv_dest, pzv_src); \
827 if (copy) { \
828 zval_copy_ctor(*ppzv_dest); \
829 } \
830 Z_SET_ISREF_TO_PP(ppzv_dest, is_ref); \
831 Z_SET_REFCOUNT_PP(ppzv_dest, refcount); \
832}
833
834#define SEPARATE_ARG_IF_REF(varptr) \
735 if (Z_ISREF_P(varptr)) { \
736 ZVAL_DUP(varptr, Z_REFVAL_P(varptr)); \
835 if (PZVAL_IS_REF(varptr)) { \
836 zval *original_var = varptr; \
837 ALLOC_ZVAL(varptr); \
838 INIT_PZVAL_COPY(varptr, original_var); \
839 zval_copy_ctor(varptr); \
737 } else { \
738 Z_ADDREF_P(varptr); \
739 }
740
741#define READY_TO_DESTROY(zv) \
742 (Z_REFCOUNT_P(zv) == 1 && \
743 (Z_TYPE_P(zv) != IS_OBJECT || \
744 zend_objects_store_get_refcount(zv TSRMLS_CC) == 1))

--- 8 unchanged lines hidden (view full) ---

753 EH_NORMAL = 0,
754 EH_SUPPRESS,
755 EH_THROW
756} zend_error_handling_t;
757
758typedef struct {
759 zend_error_handling_t handling;
760 zend_class_entry *exception;
840 } else { \
841 Z_ADDREF_P(varptr); \
842 }
843
844#define READY_TO_DESTROY(zv) \
845 (Z_REFCOUNT_P(zv) == 1 && \
846 (Z_TYPE_P(zv) != IS_OBJECT || \
847 zend_objects_store_get_refcount(zv TSRMLS_CC) == 1))

--- 8 unchanged lines hidden (view full) ---

856 EH_NORMAL = 0,
857 EH_SUPPRESS,
858 EH_THROW
859} zend_error_handling_t;
860
861typedef struct {
862 zend_error_handling_t handling;
863 zend_class_entry *exception;
761 zval user_handler;
864 zval *user_handler;
762} zend_error_handling;
763
764ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
765ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
766ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
767
768#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
769#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
770
771#endif /* ZEND_H */
772
773/*
774 * Local variables:
775 * tab-width: 4
776 * c-basic-offset: 4
777 * indent-tabs-mode: t
778 * End:
779 */
865} zend_error_handling;
866
867ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
868ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
869ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
870
871#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
872#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
873
874#endif /* ZEND_H */
875
876/*
877 * Local variables:
878 * tab-width: 4
879 * c-basic-offset: 4
880 * indent-tabs-mode: t
881 * End:
882 */