|
| 1 | +/* |
| 2 | + +----------------------------------------------------------------------+ |
| 3 | + | Zend Engine | |
| 4 | + +----------------------------------------------------------------------+ |
| 5 | + | Copyright (c) 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 | + | [email protected] so we can mail you a copy immediately. | |
| 14 | + +----------------------------------------------------------------------+ |
| 15 | +*/ |
| 16 | + |
| 17 | +#ifndef ZEND_RC_DEBUG_H |
| 18 | +#define ZEND_RC_DEBUG_H |
| 19 | + |
| 20 | +#ifndef ZEND_RC_DEBUG |
| 21 | +# define ZEND_RC_DEBUG 0 |
| 22 | +#endif |
| 23 | + |
| 24 | +#if ZEND_RC_DEBUG |
| 25 | + |
| 26 | +#ifdef PHP_WIN32 |
| 27 | +# include "zend_config.w32.h" |
| 28 | +#else |
| 29 | +# include "zend_config.h" |
| 30 | +#endif |
| 31 | + |
| 32 | +#include <stdbool.h> |
| 33 | +#include <stdint.h> |
| 34 | + |
| 35 | +extern ZEND_API bool zend_rc_debug; |
| 36 | + |
| 37 | +/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects. |
| 38 | + * Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */ |
| 39 | +# define ZEND_RC_MOD_CHECK(p) do { \ |
| 40 | + if (zend_rc_debug) { \ |
| 41 | + uint8_t type = zval_gc_type((p)->u.type_info); \ |
| 42 | + if (type != IS_OBJECT && type != IS_NULL) { \ |
| 43 | + ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \ |
| 44 | + ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \ |
| 45 | + } \ |
| 46 | + } \ |
| 47 | + } while (0) |
| 48 | +#else |
| 49 | +# define ZEND_RC_MOD_CHECK(p) \ |
| 50 | + do { } while (0) |
| 51 | +#endif |
| 52 | + |
| 53 | +#endif /* ZEND_RC_DEBUG_H */ |
0 commit comments