9 #ifdef JEMALLOC_H_TYPES
11 typedef struct rtree_s rtree_t;
17 #define RTREE_NODESIZE (1U << 16)
19 typedef void *(rtree_alloc_t)(
size_t);
20 typedef void (rtree_dalloc_t)(
void *);
24 #ifdef JEMALLOC_H_STRUCTS
28 rtree_dalloc_t *dalloc;
32 unsigned level2bits[1];
37 #ifdef JEMALLOC_H_EXTERNS
39 rtree_t *
rtree_new(
unsigned bits, rtree_alloc_t *alloc, rtree_dalloc_t *dalloc);
47 #ifdef JEMALLOC_H_INLINES
49 #ifndef JEMALLOC_ENABLE_INLINE
57 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_RTREE_C_))
58 #define RTREE_GET_GENERATE(f) \
60 JEMALLOC_INLINE uint8_t \
61 f(rtree_t *rtree, uintptr_t key) \
65 unsigned i, lshift, height, bits; \
66 void **node, **child; \
68 RTREE_LOCK(&rtree->mutex); \
69 for (i = lshift = 0, height = rtree->height, node = rtree->root;\
71 i++, lshift += bits, node = child) { \
72 bits = rtree->level2bits[i]; \
73 subkey = (key << lshift) >> ((ZU(1) << (LG_SIZEOF_PTR + \
75 child = (void**)node[subkey]; \
76 if (child == NULL) { \
77 RTREE_UNLOCK(&rtree->mutex); \
86 bits = rtree->level2bits[i]; \
87 subkey = (key << lshift) >> ((ZU(1) << (LG_SIZEOF_PTR+3)) - \
90 uint8_t *leaf = (uint8_t *)node; \
93 RTREE_UNLOCK(&rtree->mutex); \
100 # define RTREE_LOCK(l) malloc_mutex_lock(l)
101 # define RTREE_UNLOCK(l) malloc_mutex_unlock(l)
102 # define RTREE_GET_VALIDATE
106 # undef RTREE_GET_VALIDATE
109 #define RTREE_LOCK(l)
110 #define RTREE_UNLOCK(l)
111 #ifdef JEMALLOC_DEBUG
120 # define RTREE_GET_VALIDATE \
121 assert(rtree_get_locked(rtree, key) == ret);
123 # define RTREE_GET_VALIDATE
128 #undef RTREE_GET_VALIDATE
134 unsigned i, lshift, height,
bits;
135 void **node, **child;
138 for (i = lshift = 0, height = rtree->height, node = rtree->root;
140 i++, lshift += bits, node = child) {
141 bits = rtree->level2bits[i];
142 subkey = (key << lshift) >> ((
ZU(1) << (LG_SIZEOF_PTR+3)) -
144 child = (
void**)node[subkey];
146 size_t size = ((i + 1 < height - 1) ?
sizeof(
void *)
147 : (
sizeof(
uint8_t))) << rtree->level2bits[i+1];
148 child = (
void**)rtree->alloc(size);
153 memset(child, 0, size);
154 node[subkey] = child;
159 bits = rtree->level2bits[i];
160 subkey = (key << lshift) >> ((
ZU(1) << (LG_SIZEOF_PTR+3)) -
bits);
#define malloc_mutex_lock
Definition: private_namespace.h:237
#define rtree_get_locked
Definition: private_namespace.h:340
#define JEMALLOC_INLINE
Definition: jemalloc_internal.h:259
#define rtree_postfork_parent
Definition: private_namespace.h:343
#define rtree_delete
Definition: private_namespace.h:338
#define rtree_set
Definition: private_namespace.h:345
arena_t NULL
Definition: jemalloc_internal.h:624
#define rtree_get
Definition: private_namespace.h:339
#define rtree_prefork
Definition: private_namespace.h:344
#define ZU(z)
Definition: jemalloc_internal.h:234
_W64 unsigned int uintptr_t
Definition: stdint.h:119
uint16 bits() const
Returns the underlying bits in this representation. Equivalent to:
Definition: unorm16.h:89
#define malloc_mutex_unlock
Definition: private_namespace.h:241
unsigned char uint8_t
Definition: stdint.h:78
#define rtree_new
Definition: private_namespace.h:341
#define rtree_postfork_child
Definition: private_namespace.h:342