Skip to content

Commit 7fe1e13

Browse files
committed
[RBTREE] Add accessor macros for colour and parent fields of rb_node
This is in preparation for merging those fields into a single 'unsigned long', because using a whole machine-word for a single bit of colour information is wasteful. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
1 parent f4ffaa4 commit 7fe1e13

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎include/linux/rbtree.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ struct rb_node
107107
struct rb_node *rb_left;
108108
};
109109

110+
#define rb_parent(r) ((r)->rb_parent)
111+
#define rb_set_parent(r,p) do { (r)->rb_parent = p; } while (0)
112+
#define rb_colour(r) ((r)->rb_colour)
113+
#define rb_is_red(r) ((r)->colour == RB_RED)
114+
#define rb_is_black(r) ((r)->colour == RB_BLACK)
115+
#define rb_set_red(r) do { (r)->colour = RB_RED; } while (0)
116+
#define rb_set_black(r) do { (r)->colour = RB_BLACK; } while (0)
117+
#define rb_set_colour(r,c) do { (r)->colour = (c); } while (0)
118+
110119
struct rb_root
111120
{
112121
struct rb_node *rb_node;

0 commit comments

Comments
 (0)