Skip to content

Commit a39cdef

Browse files
committed
Move static map ptr number to pointer computation into macro
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
1 parent 595471c commit a39cdef

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Zend/zend_map_ptr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ typedef struct _zend_string zend_string;
7070
} while (0)
7171
# define ZEND_MAP_PTR_BIASED_BASE(real_base) \
7272
((void*)(((uintptr_t)(real_base)) + zend_map_ptr_static_size * sizeof(void *) - 1))
73+
// Note: chunked like: [8192..12287][4096..8191][0..4095]
74+
#define ZEND_MAP_PTR_STATIC_NUM_TO_PTR(num) \
75+
((void **)CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX((num) + 1, 4096) + ((num) & 4095))
7376
#else
7477
# error "Unknown ZEND_MAP_PTR_KIND"
7578
#endif

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,9 +4394,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
43944394
ZCG(preloaded_internal_run_time_cache) = cache;
43954395

43964396
for (size_t cur_static_map_ptr = orig_map_ptr_static_last; cur_static_map_ptr < zend_map_ptr_static_last; ++cur_static_map_ptr) {
4397-
// Note: chunked like: [8192..12287][4096..8191][0..4095]
4398-
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX(cur_static_map_ptr + 1, 4096) + (cur_static_map_ptr & 4095);
4399-
*ptr = cache;
4397+
*ZEND_MAP_PTR_STATIC_NUM_TO_PTR(cur_static_map_ptr) = cache;
44004398
cache += runtime_cache_size;
44014399
}
44024400
}

0 commit comments

Comments
 (0)