diff options
Diffstat (limited to 'cpukit/libfs/src/jffs2/include/linux/rbtree.h')
-rw-r--r-- | cpukit/libfs/src/jffs2/include/linux/rbtree.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/cpukit/libfs/src/jffs2/include/linux/rbtree.h b/cpukit/libfs/src/jffs2/include/linux/rbtree.h index fef5f718d6..73cf937044 100644 --- a/cpukit/libfs/src/jffs2/include/linux/rbtree.h +++ b/cpukit/libfs/src/jffs2/include/linux/rbtree.h @@ -1,21 +1,21 @@ #ifndef _LINUX_RBTREE_H #define _LINUX_RBTREE_H +#include <stddef.h> struct rb_node { - struct rb_node *rb_left; /* left element */ - struct rb_node *rb_right; /* right element */ - struct rb_node *rb_parent; /* parent element */ - int rb_color; /* node color */ + struct rb_node *rb_left; + struct rb_node *rb_right; + struct rb_node *rb_parent; + int rb_color; }; struct rb_root { - struct rb_node *rb_node; /* root of the tree */ + struct rb_node *rb_node; }; -#define NULL ((void *)0) -#define RB_ROOT ((struct rb_root){NULL}) +#define RB_ROOT ((struct rb_root){0}) #define rb_entry(p, container, field) \ - ((container *) ((char *)p - ((char *)&(((container *)0)->field)))) + ((container *) ((char *)p - offsetof(container, field))) #define RB_BLACK 0 #define RB_RED 1 @@ -24,12 +24,11 @@ struct rb_root { extern void rb_insert_color(struct rb_node *, struct rb_root *); extern void rb_erase(struct rb_node *, struct rb_root *); -/* Find logical next and previous nodes in a tree */ extern struct rb_node *rb_next(struct rb_node *); extern struct rb_node *rb_prev(struct rb_node *); extern struct rb_node *rb_first(struct rb_root *); +extern struct rb_node *rb_last(struct rb_root *); -/* Fast replacement of a single node without remove/rebalance/add/rebalance */ extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root); @@ -43,4 +42,9 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent, *rb_link = node; } +static inline struct rb_node *rb_parent(struct rb_node * node) +{ + return node->rb_parent; +} + #endif /* _LINUX_RBTREE_H */ |