Skip to content

Commit

Permalink
[RBTREE] Add accessor macros for colour and parent fields of rb_node
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Woodhouse committed Apr 21, 2006
1 parent f4ffaa4 commit 7fe1e13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/linux/rbtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ struct rb_node
struct rb_node *rb_left;
};

#define rb_parent(r) ((r)->rb_parent)
#define rb_set_parent(r,p) do { (r)->rb_parent = p; } while (0)
#define rb_colour(r) ((r)->rb_colour)
#define rb_is_red(r) ((r)->colour == RB_RED)
#define rb_is_black(r) ((r)->colour == RB_BLACK)
#define rb_set_red(r) do { (r)->colour = RB_RED; } while (0)
#define rb_set_black(r) do { (r)->colour = RB_BLACK; } while (0)
#define rb_set_colour(r,c) do { (r)->colour = (c); } while (0)

struct rb_root
{
struct rb_node *rb_node;
Expand Down

0 comments on commit 7fe1e13

Please sign in to comment.