php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_map_ptr.h
Go to the documentation of this file.
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 | Authors: Dmitry Stogov <dmitry@php.net> |
16 +----------------------------------------------------------------------+
17*/
18
19#ifndef ZEND_MAP_PTR_H
20#define ZEND_MAP_PTR_H
21
22#include "zend_portability.h"
23
25
26#define ZEND_MAP_PTR_KIND_PTR 0
27#define ZEND_MAP_PTR_KIND_PTR_OR_OFFSET 1
28
29#define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
30
31#define ZEND_MAP_PTR(ptr) \
32 ptr ## __ptr
33#define ZEND_MAP_PTR_DEF(type, name) \
34 type ZEND_MAP_PTR(name)
35#define ZEND_MAP_PTR_OFFSET2PTR(offset) \
36 ((void**)((char*)CG(map_ptr_base) + offset))
37#define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
38 ((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
39#define ZEND_MAP_PTR_INIT(ptr, val) do { \
40 ZEND_MAP_PTR(ptr) = (val); \
41 } while (0)
42#define ZEND_MAP_PTR_NEW(ptr) do { \
43 ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
44 } while (0)
45#define ZEND_MAP_PTR_NEW_STATIC(ptr) do { \
46 ZEND_MAP_PTR(ptr) = zend_map_ptr_new_static(); \
47 } while (0)
48
49#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
50# define ZEND_MAP_PTR_NEW_OFFSET() \
51 ((uint32_t)(uintptr_t)zend_map_ptr_new())
52# define ZEND_MAP_PTR_IS_OFFSET(ptr) \
53 (((uintptr_t)ZEND_MAP_PTR(ptr)) & 1L)
54# define ZEND_MAP_PTR_GET(ptr) \
55 ((ZEND_MAP_PTR_IS_OFFSET(ptr) ? \
56 ZEND_MAP_PTR_GET_IMM(ptr) : \
57 ((void*)(ZEND_MAP_PTR(ptr)))))
58# define ZEND_MAP_PTR_GET_IMM(ptr) \
59 (*ZEND_MAP_PTR_OFFSET2PTR((intptr_t)ZEND_MAP_PTR(ptr)))
60# define ZEND_MAP_PTR_SET(ptr, val) do { \
61 if (ZEND_MAP_PTR_IS_OFFSET(ptr)) { \
62 ZEND_MAP_PTR_SET_IMM(ptr, val); \
63 } else { \
64 ZEND_MAP_PTR_INIT(ptr, val); \
65 } \
66 } while (0)
67# define ZEND_MAP_PTR_SET_IMM(ptr, val) do { \
68 void **__p = ZEND_MAP_PTR_OFFSET2PTR((intptr_t)ZEND_MAP_PTR(ptr)); \
69 *__p = (val); \
70 } while (0)
71# define ZEND_MAP_PTR_BIASED_BASE(real_base) \
72 ((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))
76#else
77# error "Unknown ZEND_MAP_PTR_KIND"
78#endif
79
81
83ZEND_API void *zend_map_ptr_new(void);
87
90
92
93#endif /* ZEND_MAP_PTR_H */
ZEND_API size_t zend_map_ptr_static_size
Definition zend.c:2008
ZEND_API void zend_alloc_ce_cache(zend_string *type_name)
Definition zend.c:2070
ZEND_API size_t zend_map_ptr_static_last
Definition zend.c:2009
ZEND_API void * zend_map_ptr_new_static(void)
Definition zend.c:2032
ZEND_API void zend_map_ptr_reset(void)
Definition zend.c:2011
ZEND_API void zend_map_ptr_extend(size_t last)
Definition zend.c:2053
ZEND_API void * zend_map_ptr_new(void)
Definition zend.c:2016
#define ZEND_API
struct _zend_string zend_string
int last
#define END_EXTERN_C()
#define BEGIN_EXTERN_C()