1 #ifndef _LINUX_PRIO_TREE_H
2 #define _LINUX_PRIO_TREE_H
4 struct prio_tree_node {
5 struct prio_tree_node *left;
6 struct prio_tree_node *right;
7 struct prio_tree_node *parent;
10 struct prio_tree_root {
11 struct prio_tree_node *prio_tree_node;
12 unsigned int index_bits;
15 struct prio_tree_iter {
16 struct prio_tree_node *cur;
22 #define INIT_PRIO_TREE_ROOT(ptr) \
24 (ptr)->prio_tree_node = NULL; \
25 (ptr)->index_bits = 1; \
28 #define INIT_PRIO_TREE_NODE(ptr) \
30 (ptr)->left = (ptr)->right = (ptr)->parent = (ptr); \
33 #define INIT_PRIO_TREE_ITER(ptr) \
38 (ptr)->size_level = 0; \
41 #define prio_tree_entry(ptr, type, member) \
42 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
44 static inline int prio_tree_empty(const struct prio_tree_root *root)
46 return root->prio_tree_node == NULL;
49 static inline int prio_tree_root(const struct prio_tree_node *node)
51 return node->parent == node;
54 static inline int prio_tree_left_empty(const struct prio_tree_node *node)
56 return node->left == node;
59 static inline int prio_tree_right_empty(const struct prio_tree_node *node)
61 return node->right == node;
64 #endif /* _LINUX_PRIO_TREE_H */