mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 19:14:58 -06:00
util/interval-tree: Introduce pc_parent
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
4c8baa02d3
commit
d37a259fa4
1 changed files with 9 additions and 4 deletions
|
@ -68,9 +68,14 @@ typedef struct RBAugmentCallbacks {
|
||||||
void (*rotate)(RBNode *old, RBNode *new);
|
void (*rotate)(RBNode *old, RBNode *new);
|
||||||
} RBAugmentCallbacks;
|
} RBAugmentCallbacks;
|
||||||
|
|
||||||
|
static inline RBNode *pc_parent(uintptr_t pc)
|
||||||
|
{
|
||||||
|
return (RBNode *)(pc & ~1);
|
||||||
|
}
|
||||||
|
|
||||||
static inline RBNode *rb_parent(const RBNode *n)
|
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)
|
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.
|
* so as to bypass rb_erase_color() later on.
|
||||||
*/
|
*/
|
||||||
pc = node->rb_parent_color;
|
pc = node->rb_parent_color;
|
||||||
parent = rb_parent(node);
|
parent = pc_parent(pc);
|
||||||
rb_change_child(node, child, parent, root);
|
rb_change_child(node, child, parent, root);
|
||||||
if (child) {
|
if (child) {
|
||||||
child->rb_parent_color = pc;
|
child->rb_parent_color = pc;
|
||||||
|
@ -544,7 +549,7 @@ static void rb_erase_augmented(RBNode *node, RBRoot *root,
|
||||||
} else if (!child) {
|
} else if (!child) {
|
||||||
/* Still case 1, but this time the child is node->rb_left */
|
/* Still case 1, but this time the child is node->rb_left */
|
||||||
pc = node->rb_parent_color;
|
pc = node->rb_parent_color;
|
||||||
parent = rb_parent(node);
|
parent = pc_parent(pc);
|
||||||
tmp->rb_parent_color = pc;
|
tmp->rb_parent_color = pc;
|
||||||
rb_change_child(node, tmp, parent, root);
|
rb_change_child(node, tmp, parent, root);
|
||||||
rebalance = NULL;
|
rebalance = NULL;
|
||||||
|
@ -600,7 +605,7 @@ static void rb_erase_augmented(RBNode *node, RBRoot *root,
|
||||||
rb_set_parent(tmp, successor);
|
rb_set_parent(tmp, successor);
|
||||||
|
|
||||||
pc = node->rb_parent_color;
|
pc = node->rb_parent_color;
|
||||||
tmp = rb_parent(node);
|
tmp = pc_parent(pc);
|
||||||
rb_change_child(node, successor, tmp, root);
|
rb_change_child(node, successor, tmp, root);
|
||||||
|
|
||||||
if (child2) {
|
if (child2) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue