xref: /linux/kernel/bpf/range_tree.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
3 #ifndef _RANGE_TREE_H
4 #define _RANGE_TREE_H 1
5 
6 struct range_tree {
7 	/* root of interval tree */
8 	struct rb_root_cached it_root;
9 	/* root of rbtree of interval sizes */
10 	struct rb_root_cached range_size_root;
11 };
12 
13 void range_tree_init(struct range_tree *rt);
14 void range_tree_destroy(struct range_tree *rt);
15 
16 int range_tree_clear(struct range_tree *rt, u32 start, u32 len);
17 int range_tree_set(struct range_tree *rt, u32 start, u32 len);
18 int is_range_tree_set(struct range_tree *rt, u32 start, u32 len);
19 s64 range_tree_find(struct range_tree *rt, u32 len);
20 
21 #endif
22