diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2023-07-22 21:20:05 +0100 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2023-07-31 12:19:13 -0700 |
commit | d37a259fa4f5164e300e8a20cdd83fe39c7fdadb (patch) | |
tree | b2519256dcb146d5b2f619264502e395d45d2d0e /util | |
parent | 4c8baa02d36379507afd17bdea87aabe0aa32ed3 (diff) |
util/interval-tree: Introduce pc_parent
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/interval-tree.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/util/interval-tree.c b/util/interval-tree.c index 759562db7d..d86c0752db 100644 --- a/util/interval-tree.c +++ b/util/interval-tree.c @@ -68,9 +68,14 @@ typedef struct RBAugmentCallbacks { void (*rotate)(RBNode *old, RBNode *new); } RBAugmentCallbacks; +static inline RBNode *pc_parent(uintptr_t pc) +{ + return (RBNode *)(pc & ~1); +} + static inline RBNode *rb_parent(const RBNode *n) { - return (RBNode *)(n->rb_parent_color & ~1); + return pc_parent(n->rb_parent_color); } static inline RBNode *rb_red_parent(const RBNode *n) @@ -532,7 +537,7 @@ static void rb_erase_augmented(RBNode *node, RBRoot *root, * so as to bypass rb_erase_color() later on. */ pc = node->rb_parent_color; - parent = rb_parent(node); + parent = pc_parent(pc); rb_change_child(node, child, parent, root); if (child) { child->rb_parent_color = pc; @@ -544,7 +549,7 @@ static void rb_erase_augmented(RBNode *node, RBRoot *root, } else if (!child) { /* Still case 1, but this time the child is node->rb_left */ pc = node->rb_parent_color; - parent = rb_parent(node); + parent = pc_parent(pc); tmp->rb_parent_color = pc; rb_change_child(node, tmp, parent, root); rebalance = NULL; @@ -600,7 +605,7 @@ static void rb_erase_augmented(RBNode *node, RBRoot *root, rb_set_parent(tmp, successor); pc = node->rb_parent_color; - tmp = rb_parent(node); + tmp = pc_parent(pc); rb_change_child(node, successor, tmp, root); if (child2) { |