Skip to content

Commit aab3c55

Browse files
committed
Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h
1 parent ae6f27b commit aab3c55

File tree

8 files changed

+76
-23
lines changed

8 files changed

+76
-23
lines changed

Zend/zend.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ void (*zend_on_timeout)(int seconds);
9292
static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
9393
static zval *(*zend_get_configuration_directive_p)(zend_string *name);
9494

95-
#if ZEND_RC_DEBUG
96-
ZEND_API bool zend_rc_debug = 0;
97-
#endif
98-
9995
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
10096
{
10197
if (!new_value) {

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "zend_ini.h"
3131
#include "zend_enum.h"
3232
#include "zend_observer.h"
33+
#include "zend_rc_debug.h"
3334

3435
#include <stdarg.h>
3536

Zend/zend_rc_debug.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
| license@zend.com so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#include "zend_rc_debug.h"
18+
19+
#if ZEND_RC_DEBUG
20+
ZEND_API bool zend_rc_debug = false;
21+
#endif

Zend/zend_rc_debug.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
| license@zend.com 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+
#ifdef PHP_WIN32
21+
# include "zend_config.w32.h"
22+
#else
23+
# include "php_config.h" // for ZEND_API
24+
#endif
25+
26+
#include <stdbool.h>
27+
28+
#ifndef ZEND_RC_DEBUG
29+
# define ZEND_RC_DEBUG 0
30+
#endif
31+
32+
#if ZEND_RC_DEBUG
33+
extern ZEND_API bool zend_rc_debug;
34+
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
35+
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
36+
# define ZEND_RC_MOD_CHECK(p) do { \
37+
if (zend_rc_debug) { \
38+
zend_uchar type = zval_gc_type((p)->u.type_info); \
39+
if (type != IS_OBJECT && type != IS_NULL) { \
40+
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
41+
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
42+
} \
43+
} \
44+
} while (0)
45+
#else
46+
# define ZEND_RC_MOD_CHECK(p) \
47+
do { } while (0)
48+
#endif
49+
50+
#endif /* ZEND_RC_DEBUG_H */

Zend/zend_string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "zend_string.h"
2020
#include "zend_globals.h"
2121
#include "zend_hash.h"
22-
#include "zend_types.h" // for zend_rc_debug
22+
#include "zend_rc_debug.h"
2323

2424
#ifdef HAVE_VALGRIND
2525
# include "valgrind/callgrind.h"

Zend/zend_types.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "zend_char.h"
2626
#include "zend_portability.h"
2727
#include "zend_long.h"
28+
#include "zend_rc_debug.h"
2829
#include "zend_result.h"
2930
#include "zend_type_info.h"
3031

@@ -1160,29 +1161,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
11601161
#define Z_TRY_ADDREF(z) Z_TRY_ADDREF_P(&(z))
11611162
#define Z_TRY_DELREF(z) Z_TRY_DELREF_P(&(z))
11621163

1163-
#ifndef ZEND_RC_DEBUG
1164-
# define ZEND_RC_DEBUG 0
1165-
#endif
1166-
11671164
#if ZEND_RC_DEBUG
1168-
extern ZEND_API bool zend_rc_debug;
1169-
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
1170-
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
1171-
# define ZEND_RC_MOD_CHECK(p) do { \
1172-
if (zend_rc_debug) { \
1173-
zend_uchar type = zval_gc_type((p)->u.type_info); \
1174-
if (type != IS_OBJECT && type != IS_NULL) { \
1175-
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
1176-
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
1177-
} \
1178-
} \
1179-
} while (0)
11801165
# define GC_MAKE_PERSISTENT_LOCAL(p) do { \
11811166
GC_ADD_FLAGS(p, GC_PERSISTENT_LOCAL); \
11821167
} while (0)
11831168
#else
1184-
# define ZEND_RC_MOD_CHECK(p) \
1185-
do { } while (0)
11861169
# define GC_MAKE_PERSISTENT_LOCAL(p) \
11871170
do { } while (0)
11881171
#endif

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,7 @@ PHP_ADD_SOURCES(Zend, \
17221722
zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \
17231723
zend_default_classes.c zend_inheritance.c zend_smart_str.c zend_cpuinfo.c zend_gdb.c \
17241724
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_atomic.c \
1725+
zend_rc_debug.c \
17251726
Optimizer/zend_optimizer.c \
17261727
Optimizer/pass1.c \
17271728
Optimizer/pass3.c \

main/php.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "php_version.h"
3131
#include "zend.h"
32+
#include "zend_rc_debug.h"
3233
#include "zend_sort.h"
3334
#include "php_compat.h"
3435

0 commit comments

Comments
 (0)