51,7 → 51,7 |
|
#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) |
|
/* 'empty' nodes are nodes that are known not to be inserted in an rbree */ |
/* 'empty' nodes are nodes that are known not to be inserted in an rbtree */ |
#define RB_EMPTY_NODE(node) \ |
((node)->__rb_parent_color == (unsigned long)(node)) |
#define RB_CLEAR_NODE(node) \ |
85,6 → 85,15 |
*rb_link = node; |
} |
|
static inline void rb_link_node_rcu(struct rb_node *node, struct rb_node *parent, |
struct rb_node **rb_link) |
{ |
node->__rb_parent_color = (unsigned long)parent; |
node->rb_left = node->rb_right = NULL; |
|
rcu_assign_pointer(*rb_link, node); |
} |
|
#define rb_entry_safe(ptr, type, member) \ |
({ typeof(ptr) ____ptr = (ptr); \ |
____ptr ? rb_entry(____ptr, type, member) : NULL; \ |
91,13 → 100,21 |
}) |
|
/** |
* rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of |
* given type safe against removal of rb_node entry |
* rbtree_postorder_for_each_entry_safe - iterate in post-order over rb_root of |
* given type allowing the backing memory of @pos to be invalidated |
* |
* @pos: the 'type *' to use as a loop cursor. |
* @n: another 'type *' to use as temporary storage |
* @root: 'rb_root *' of the rbtree. |
* @field: the name of the rb_node field within 'type'. |
* |
* rbtree_postorder_for_each_entry_safe() provides a similar guarantee as |
* list_for_each_entry_safe() and allows the iteration to continue independent |
* of changes to @pos by the body of the loop. |
* |
* Note, however, that it cannot handle other modifications that re-order the |
* rbtree it is iterating over. This includes calling rb_erase() on @pos, as |
* rb_erase() may rebalance the tree, causing us to miss some nodes. |
*/ |
#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \ |
for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), field); \ |