1 #ifndef KVM__INTERVAL_RBTREE_H
2 #define KVM__INTERVAL_RBTREE_H
3
4 #include <linux/rbtree.h>
5 #include <linux/types.h>
6
7 #define RB_INT_INIT(l, h) \
8 (struct rb_int_node){.low = l, .high = h}
9 #define rb_int(n) rb_entry(n, struct rb_int_node, node)
10 #define rb_int_start(n) ((n)->low)
11 #define rb_int_end(n) ((n)->low + (n)->high - 1)
12
13 struct rb_int_node {
14 struct rb_node node;
15 u64 low;
16 u64 high;
17 };
18
19 /* Return the rb_int_node interval in which 'point' is located. */
20 struct rb_int_node *rb_int_search_single(struct rb_root *root, u64 point);
21
22 /* Return the rb_int_node in which start:len is located. */
23 struct rb_int_node *rb_int_search_range(struct rb_root *root, u64 low, u64 high);
24
25 int rb_int_insert(struct rb_root *root, struct rb_int_node *data);
26
rb_int_erase(struct rb_root * root,struct rb_int_node * node)27 static inline void rb_int_erase(struct rb_root *root, struct rb_int_node *node)
28 {
29 rb_erase(&node->node, root);
30 }
31
32 #endif
33