Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib: Export interval_tree

lib/interval_tree.c provides a simple interface for an interval-tree
(an augmented red-black tree) but is only built when testing the generic
macros for building interval-trees. For drivers with modest needs,
export the simple interval-tree library as is.

v2: Lots of help from Michel Lespinasse to only compile the code
as required:
- make INTERVAL_TREE a config option
- make INTERVAL_TREE_TEST select the library functions
and sanitize the filenames & Makefile
- prepare interval_tree for being built as a module if required

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Michel Lespinasse <walken@google.com>
[Acked for inclusion via drm/i915 by Andrew Morton.]
[danvet: switch to _GPL as per the mailing list discussion.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

authored by

Chris Wilson and committed by
Daniel Vetter
a88cc108 8d4eee9c

+22 -2
+14
lib/Kconfig
··· 331 331 config BTREE 332 332 boolean 333 333 334 + config INTERVAL_TREE 335 + boolean 336 + help 337 + Simple, embeddable, interval-tree. Can find the start of an 338 + overlapping range in log(n) time and then iterate over all 339 + overlapping nodes. The algorithm is implemented as an 340 + augmented rbtree. 341 + 342 + See: 343 + 344 + Documentation/rbtree.txt 345 + 346 + for more information. 347 + 334 348 config ASSOCIATIVE_ARRAY 335 349 bool 336 350 help
+1
lib/Kconfig.debug
··· 1496 1496 config INTERVAL_TREE_TEST 1497 1497 tristate "Interval tree test" 1498 1498 depends on m && DEBUG_KERNEL 1499 + select INTERVAL_TREE 1499 1500 help 1500 1501 A benchmark measuring the performance of the interval tree library 1501 1502
+1 -2
lib/Makefile
··· 50 50 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 51 51 52 52 obj-$(CONFIG_BTREE) += btree.o 53 + obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o 53 54 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o 54 55 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 55 56 obj-$(CONFIG_DEBUG_LIST) += list_debug.o ··· 156 155 157 156 obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o 158 157 obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o 159 - 160 - interval_tree_test-objs := interval_tree_test_main.o interval_tree.o 161 158 162 159 obj-$(CONFIG_PERCPU_TEST) += percpu_test.o 163 160
+6
lib/interval_tree.c
··· 1 1 #include <linux/init.h> 2 2 #include <linux/interval_tree.h> 3 3 #include <linux/interval_tree_generic.h> 4 + #include <linux/module.h> 4 5 5 6 #define START(node) ((node)->start) 6 7 #define LAST(node) ((node)->last) ··· 9 8 INTERVAL_TREE_DEFINE(struct interval_tree_node, rb, 10 9 unsigned long, __subtree_last, 11 10 START, LAST,, interval_tree) 11 + 12 + EXPORT_SYMBOL_GPL(interval_tree_insert); 13 + EXPORT_SYMBOL_GPL(interval_tree_remove); 14 + EXPORT_SYMBOL_GPL(interval_tree_iter_first); 15 + EXPORT_SYMBOL_GPL(interval_tree_iter_next);
lib/interval_tree_test_main.c lib/interval_tree_test.c