32#if defined(RBT_IMPLICIT_LOCKING)
36#ifndef HAVE_POSIX_MEMALIGN
38int posix_memalign(
void **memptr,
size_t alignment,
size_t size);
50 RBT_WALK_PREORDER = 0x01,
51 RBT_WALK_INORDER = 0x02,
52 RBT_WALK_POSTORDER = 0x03,
53 RBT_WALK_LEVELORDER = 0x04,
54 RBT_WALK_RAWNODE = 0x10
57#define RBT_WALK_TYPEMASK 0x0f
58#define RBT_WALK_FLAGMASK 0xf0
74__attribute__((pure))
static inline struct rbt_node *rbt_node_ptr(
const struct rbt_node *nodep)
76 register uintptr_t nodep_uint = (uintptr_t)(nodep);
77 nodep_uint &= UINTPTR_MAX << 1;
78 return (
struct rbt_node *)(nodep_uint);
81#define rbt_node_setptr(dst,src) (dst) = (struct rbt_node *)((uintptr_t)rbt_node_ptr(src)|((uintptr_t)(dst)&1))
83#define rbt_node_setcolor(np, cb) \
85 register struct rbt_node *__n = rbt_node_ptr(np); \
86 register uint8_t __c = (cb) & 1; \
89 if (__c) __n->_chld[0] = (struct rbt_node *)((uintptr_t)(__n->_chld[0]) | 1); \
90 else __n->_chld[0] = rbt_node_ptr(__n->_chld[0]); \
93#define rbt_node_getcolor_raw(cp) ((uintptr_t)(cp) & 1)
94#define rbt_node_getcolor(np) (rbt_node_ptr(np) == NULL ? RBT_NODE_CB : rbt_node_getcolor_raw(rbt_node_ptr(np)->_chld[0]))
95#define rbt_node_cpycolor(dn, sn) rbt_node_setcolor((dn), rbt_node_getcolor(sn))
97#define rbt_hpush4(__a, __p) \
105#define rbt_hpush3(__a, __p) \
112#define rbt_redfix(__h, __d, v) \
114 if (((__d) & 3) < 2) { \
115 if (((__d) & 3) == 0) { \
116 rbt_node_setptr(v, rbt_node_rotate_R(__h[2])); \
118 rbt_node_setptr(v, rbt_node_rotate_RL(__h[2])); \
121 if (((__d) & 3) == 2) { \
122 rbt_node_setptr(v, rbt_node_rotate_LR(__h[2])); \
124 rbt_node_setptr(v, rbt_node_rotate_L(__h[2])); \
133#if defined(RBT_IMPLICIT_LOCKING)
134 pthread_rwlock_t lock;
144rbt_t *rbt_new(rbt_type_t type);
152void rbt_free(
rbt_t *
rbt,
void (*callback)(
void *));
153void rbt_free2(
rbt_t *
rbt,
void (*callback)(
void *,
void *),
void *user);
186#define rbt_walk_push(n) stack[depth++] = (n)
187#define rbt_walk_pop() stack[--depth]
188#define rbt_walk_top() stack[depth-1]
190int rbt_walk_preorder(
rbt_t *
rbt,
int (*callback)(
void *), rbt_walk_t flags);
191int rbt_walk_inorder(
rbt_t *
rbt,
int (*callback)(
void *), rbt_walk_t flags);
192int rbt_walk_inorder2(
rbt_t *
rbt,
int (*callback)(
void *,
void *),
void *user, rbt_walk_t flags);
193int rbt_walk_postorder(
rbt_t *
rbt,
int (*callback)(
void *), rbt_walk_t flags);
Generic node structure Lowest bit of _chld[0] holds the color bit.
Definition rbt_common.h:64
Definition rbt_common.h:129