urcu rbtree: use redirections when comparing to parent right/left in prev/next
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 9 Mar 2010 14:52:37 +0000 (09:52 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 9 Mar 2010 14:52:37 +0000 (09:52 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu-rbtree.c

index 25ba43f0caceb949a0db271283ebeb28b0f7ac26..f834ef3e839b554190040946fd05b0cda64415b8 100644 (file)
@@ -98,7 +98,7 @@ struct rcu_rbtree_node *rcu_rbtree_max(struct rcu_rbtree_node *x,
 struct rcu_rbtree_node *rcu_rbtree_next(struct rcu_rbtree_node *x,
                                        rcu_rbtree_comp comp)
 {
-       struct rcu_rbtree_node *xr, *y, *yredir;
+       struct rcu_rbtree_node *xr, *y, *yredir, *yr, *yrredir;
 
        x = rcu_dereference(x);
 
@@ -107,7 +107,14 @@ struct rcu_rbtree_node *rcu_rbtree_next(struct rcu_rbtree_node *x,
        y = rcu_dereference(x->p);
        while ((yredir = rcu_dereference(y->redir)) != NULL)
                y = yredir;
-       while (y != &rcu_rbtree_nil && x == rcu_dereference(y->right)) {
+       for (;;) {
+               if (y == &rcu_rbtree_nil)
+                       break;
+               yr = rcu_dereference(y->right);
+               while ((yrredir = rcu_dereference(yr->redir)) != NULL)
+                       yr = yrredir;
+               if (x != yr)
+                       break;
                x = y;
                y = rcu_dereference(y->p);
                while ((yredir = rcu_dereference(y->redir)) != NULL)
@@ -119,7 +126,7 @@ struct rcu_rbtree_node *rcu_rbtree_next(struct rcu_rbtree_node *x,
 struct rcu_rbtree_node *rcu_rbtree_prev(struct rcu_rbtree_node *x,
                                        rcu_rbtree_comp comp)
 {
-       struct rcu_rbtree_node *xl, *y, *yredir;
+       struct rcu_rbtree_node *xl, *y, *yredir, *yl, *ylredir;;
 
        x = rcu_dereference(x);
 
@@ -128,7 +135,14 @@ struct rcu_rbtree_node *rcu_rbtree_prev(struct rcu_rbtree_node *x,
        y = rcu_dereference(x->p);
        while ((yredir = rcu_dereference(y->redir)) != NULL)
                y = yredir;
-       while (y != &rcu_rbtree_nil && x == rcu_dereference(y->left)) {
+       for (;;) {
+               if (y == &rcu_rbtree_nil)
+                       break;
+               yl = rcu_dereference(y->left);
+               while ((ylredir = rcu_dereference(yl->redir)) != NULL)
+                       yl = ylredir;
+               if (x != yl)
+                       break;
                x = y;
                y = rcu_dereference(y->p);
                while ((yredir = rcu_dereference(y->redir)) != NULL)
This page took 0.02636 seconds and 4 git commands to generate.