Skip to content

Commit 116fa65

Browse files
committed
Fixed ZEND_MAP_PTR_KIND_PTR (it is not used)
1 parent 476c333 commit 116fa65

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ ZEND_API void zend_alloc_ce_cache(zend_string *type_name)
18811881
/* We use the refcount to keep map_ptr of corresponding type */
18821882
uint32_t ret;
18831883
do {
1884-
ret = (uint32_t)(uintptr_t)zend_map_ptr_new();
1884+
ret = ZEND_MAP_PTR_NEW_OFFSET();
18851885
} while (ret <= 2);
18861886
GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR);
18871887
GC_SET_REFCOUNT(type_name, ret);

Zend/zend_map_ptr.h

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@
3030
//# define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR
3131
//#endif
3232

33-
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
34-
# define ZEND_MAP_PTR(ptr) \
33+
#define ZEND_MAP_PTR(ptr) \
3534
ptr ## __ptr
36-
# define ZEND_MAP_PTR_DEF(type, name) \
35+
#define ZEND_MAP_PTR_DEF(type, name) \
3736
type * ZEND_MAP_PTR(name)
37+
#define ZEND_MAP_PTR_OFFSET2PTR(offset) \
38+
((void**)((char*)CG(map_ptr_base) + offset))
39+
#define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
40+
((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
41+
#define ZEND_MAP_PTR_INIT(ptr, val) do { \
42+
ZEND_MAP_PTR(ptr) = (val); \
43+
} while (0)
44+
#define ZEND_MAP_PTR_NEW(ptr) do { \
45+
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
46+
} while (0)
47+
48+
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
49+
# define ZEND_MAP_PTR_NEW_OFFSET() \
50+
((uint32_t)(uintptr_t)ZEND_MAP_PTR_PTR2OFFSET(zend_map_ptr_new()))
3851
# define ZEND_MAP_PTR_GET(ptr) \
3952
(*(ZEND_MAP_PTR(ptr)))
4053
# define ZEND_MAP_PTR_GET_IMM(ptr) \
@@ -44,30 +57,16 @@
4457
} while (0)
4558
# define ZEND_MAP_PTR_SET_IMM(ptr, val) \
4659
ZEND_MAP_PTR_SET(ptr, val)
47-
# define ZEND_MAP_PTR_INIT(ptr, val) do { \
48-
ZEND_MAP_PTR(ptr) = (val); \
49-
} while (0)
50-
# define ZEND_MAP_PTR_NEW(ptr) do { \
51-
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
52-
} while (0)
5360
# define ZEND_MAP_PTR_REAL_BASE(base) \
5461
(base)
5562
# define ZEND_MAP_PTR_SET_REAL_BASE(base, ptr) do { \
5663
base = (ptr); \
5764
} while (0)
58-
# define ZEND_MAP_PTR_OFFSET2PTR(offset) \
59-
((void**)((char*)CG(map_ptr_base) + offset))
6065
#elif ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
61-
# define ZEND_MAP_PTR(ptr) \
62-
ptr ## __ptr
63-
# define ZEND_MAP_PTR_DEF(type, name) \
64-
type * ZEND_MAP_PTR(name)
66+
# define ZEND_MAP_PTR_NEW_OFFSET() \
67+
((uint32_t)(uintptr_t)zend_map_ptr_new())
6568
# define ZEND_MAP_PTR_IS_OFFSET(ptr) \
6669
(((uintptr_t)ZEND_MAP_PTR(ptr)) & 1L)
67-
# define ZEND_MAP_PTR_OFFSET2PTR(offset) \
68-
((void**)((char*)CG(map_ptr_base) + offset))
69-
# define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
70-
((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
7170
# define ZEND_MAP_PTR_GET(ptr) \
7271
(*(ZEND_MAP_PTR_IS_OFFSET(ptr) ? \
7372
ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)) : \
@@ -85,12 +84,6 @@
8584
void **__p = ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)); \
8685
*__p = (val); \
8786
} while (0)
88-
# define ZEND_MAP_PTR_INIT(ptr, val) do { \
89-
ZEND_MAP_PTR(ptr) = (val); \
90-
} while (0)
91-
# define ZEND_MAP_PTR_NEW(ptr) do { \
92-
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
93-
} while (0)
9487
# define ZEND_MAP_PTR_REAL_BASE(base) \
9588
((void*)(((uintptr_t)(base)) + 1))
9689
# define ZEND_MAP_PTR_SET_REAL_BASE(base, ptr) do { \

ext/opcache/zend_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name)
315315
if ((GC_FLAGS(type_name) & GC_IMMUTABLE)
316316
&& (GC_FLAGS(type_name) & IS_STR_PERMANENT)) {
317317
do {
318-
ret = (uint32_t)(uintptr_t)zend_map_ptr_new();
318+
ret = ZEND_MAP_PTR_NEW_OFFSET();
319319
} while (ret <= 2);
320320
GC_SET_REFCOUNT(type_name, ret);
321321
GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR);

0 commit comments

Comments
 (0)