7 #ifdef JEMALLOC_H_TYPES
9 typedef struct rtree_node_elm_s rtree_node_elm_t;
10 typedef struct rtree_level_s rtree_level_t;
11 typedef struct rtree_s rtree_t;
17 #define LG_RTREE_BITS_PER_LEVEL 4
18 #define RTREE_BITS_PER_LEVEL (1U << LG_RTREE_BITS_PER_LEVEL)
20 #define RTREE_HEIGHT_MAX \
21 ((1U << (LG_SIZEOF_PTR+3)) / RTREE_BITS_PER_LEVEL)
24 #define RTREE_NODE_INITIALIZING ((rtree_node_elm_t *)0x1)
31 typedef rtree_node_elm_t *(rtree_node_alloc_t)(
size_t);
32 typedef void (rtree_node_dalloc_t)(rtree_node_elm_t *);
36 #ifdef JEMALLOC_H_STRUCTS
38 struct rtree_node_elm_s {
41 rtree_node_elm_t *child;
46 struct rtree_level_s {
71 rtree_node_elm_t *subtree;
79 unsigned cumulative_bits;
83 rtree_node_alloc_t *alloc;
84 rtree_node_dalloc_t *dalloc;
90 unsigned start_level[RTREE_HEIGHT_MAX];
91 rtree_level_t levels[RTREE_HEIGHT_MAX];
96 #ifdef JEMALLOC_H_EXTERNS
98 bool rtree_new(rtree_t *rtree,
unsigned bits, rtree_node_alloc_t *alloc,
99 rtree_node_dalloc_t *dalloc);
104 rtree_node_elm_t *elm,
unsigned level);
108 #ifdef JEMALLOC_H_INLINES
110 #ifndef JEMALLOC_ENABLE_INLINE
118 unsigned level,
bool dependent);
119 extent_node_t *
rtree_val_read(rtree_t *rtree, rtree_node_elm_t *elm,
122 const extent_node_t *
val);
132 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_RTREE_C_))
136 unsigned start_level;
139 return (rtree->height - 1);
142 LG_RTREE_BITS_PER_LEVEL];
144 return (start_level);
152 rtree->levels[
level].cumulative_bits)) & ((
ZU(1) <<
153 rtree->levels[
level].bits) - 1));
166 rtree_node_elm_t *child;
171 child = atomic_read_p(&elm->pun);
181 rtree_node_elm_t *child;
192 rtree_val_read(rtree_t *rtree, rtree_node_elm_t *elm,
bool dependent)
209 return (atomic_read_p(&elm->pun));
223 rtree_node_elm_t *subtree;
226 subtree = rtree->levels[
level].subtree;
228 subtree = atomic_read_p(&rtree->levels[
level].subtree_pun);
238 rtree_node_elm_t *subtree;
252 unsigned start_level;
253 rtree_node_elm_t *node;
258 #define RTREE_GET_BIAS (RTREE_HEIGHT_MAX - rtree->height)
259 switch (start_level + RTREE_GET_BIAS) {
260 #define RTREE_GET_SUBTREE(level) \
262 if (unlikely(level > (RTREE_HEIGHT_MAX-1)))\
264 if (!dependent && unlikely(!rtree_node_valid(node))) \
266 subkey = rtree_subkey(rtree, key, level - \
268 node = rtree_child_tryread(&node[subkey], dependent); \
270 #define RTREE_GET_LEAF(level) \
272 if (unlikely(level != (RTREE_HEIGHT_MAX-1))) \
274 if (!dependent && unlikely(!rtree_node_valid(node))) \
276 subkey = rtree_subkey(rtree, key, level - \
282 return (rtree_val_read(rtree, &node[subkey], \
284 #if RTREE_HEIGHT_MAX > 1
287 #if RTREE_HEIGHT_MAX > 2
290 #if RTREE_HEIGHT_MAX > 3
293 #if RTREE_HEIGHT_MAX > 4
296 #if RTREE_HEIGHT_MAX > 5
299 #if RTREE_HEIGHT_MAX > 6
302 #if RTREE_HEIGHT_MAX > 7
305 #if RTREE_HEIGHT_MAX > 8
308 #if RTREE_HEIGHT_MAX > 9
311 #if RTREE_HEIGHT_MAX > 10
314 #if RTREE_HEIGHT_MAX > 11
315 RTREE_GET_SUBTREE(10)
317 #if RTREE_HEIGHT_MAX > 12
318 RTREE_GET_SUBTREE(11)
320 #if RTREE_HEIGHT_MAX > 13
321 RTREE_GET_SUBTREE(12)
323 #if RTREE_HEIGHT_MAX > 14
324 RTREE_GET_SUBTREE(13)
326 #if RTREE_HEIGHT_MAX > 15
327 RTREE_GET_SUBTREE(14)
329 #if RTREE_HEIGHT_MAX > 16
330 # error Unsupported RTREE_HEIGHT_MAX
332 RTREE_GET_LEAF(RTREE_HEIGHT_MAX-1)
333 #undef RTREE_GET_SUBTREE
334 #undef RTREE_GET_LEAF
337 #undef RTREE_GET_BIAS
345 unsigned i, start_level;
346 rtree_node_elm_t *node, *child;
353 for (
i = start_level; ;
i++, node = child) {
355 if (
i == rtree->height - 1) {
int bits(struct state *s, int need)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
#define JEMALLOC_ALWAYS_INLINE
assert(limit<=UINT32_MAX/2)
#define rtree_subtree_read
#define rtree_start_level
#define rtree_subtree_read_hard
#define rtree_subtree_tryread
#define rtree_child_read_hard
#define rtree_child_tryread
_W64 unsigned int uintptr_t