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
;
21 struct prio_tree_root
*root
;
26 static inline void prio_tree_iter_init(struct prio_tree_iter
*iter
,
27 struct prio_tree_root
*root
, pgoff_t r_index
, pgoff_t h_index
)
30 iter
->r_index
= r_index
;
31 iter
->h_index
= h_index
;
34 #define INIT_PRIO_TREE_ROOT(ptr) \
36 (ptr)->prio_tree_node = NULL; \
37 (ptr)->index_bits = 1; \
40 #define INIT_PRIO_TREE_NODE(ptr) \
42 (ptr)->left = (ptr)->right = (ptr)->parent = (ptr); \
45 #define INIT_PRIO_TREE_ITER(ptr) \
50 (ptr)->size_level = 0; \
53 #define prio_tree_entry(ptr, type, member) \
54 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
56 static inline int prio_tree_empty(const struct prio_tree_root
*root
)
58 return root
->prio_tree_node
== NULL
;
61 static inline int prio_tree_root(const struct prio_tree_node
*node
)
63 return node
->parent
== node
;
66 static inline int prio_tree_left_empty(const struct prio_tree_node
*node
)
68 return node
->left
== node
;
71 static inline int prio_tree_right_empty(const struct prio_tree_node
*node
)
73 return node
->right
== node
;
76 #endif /* _LINUX_PRIO_TREE_H */