This commit was generated by cvs2svn to compensate for changes in r632,
[linux-2.6.git] / include / linux / prio_tree.h
1 #ifndef _LINUX_PRIO_TREE_H
2 #define _LINUX_PRIO_TREE_H
3
4 struct prio_tree_node {
5         struct prio_tree_node   *left;
6         struct prio_tree_node   *right;
7         struct prio_tree_node   *parent;
8 };
9
10 struct prio_tree_root {
11         struct prio_tree_node   *prio_tree_node;
12         unsigned int            index_bits;
13 };
14
15 struct prio_tree_iter {
16         struct prio_tree_node   *cur;
17         unsigned long           mask;
18         unsigned long           value;
19         int                     size_level;
20 };
21
22 #define INIT_PRIO_TREE_ROOT(ptr)        \
23 do {                                    \
24         (ptr)->prio_tree_node = NULL;   \
25         (ptr)->index_bits = 1;          \
26 } while (0)
27
28 #define INIT_PRIO_TREE_NODE(ptr)                                \
29 do {                                                            \
30         (ptr)->left = (ptr)->right = (ptr)->parent = (ptr);     \
31 } while (0)
32
33 #define INIT_PRIO_TREE_ITER(ptr)        \
34 do {                                    \
35         (ptr)->cur = NULL;              \
36         (ptr)->mask = 0UL;              \
37         (ptr)->value = 0UL;             \
38         (ptr)->size_level = 0;          \
39 } while (0)
40
41 #define prio_tree_entry(ptr, type, member) \
42        ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
43
44 static inline int prio_tree_empty(const struct prio_tree_root *root)
45 {
46         return root->prio_tree_node == NULL;
47 }
48
49 static inline int prio_tree_root(const struct prio_tree_node *node)
50 {
51         return node->parent == node;
52 }
53
54 static inline int prio_tree_left_empty(const struct prio_tree_node *node)
55 {
56         return node->left == node;
57 }
58
59 static inline int prio_tree_right_empty(const struct prio_tree_node *node)
60 {
61         return node->right == node;
62 }
63
64 #endif /* _LINUX_PRIO_TREE_H */