]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
lib: Export interval_tree
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 17 Mar 2014 12:21:54 +0000 (12:21 +0000)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 25 Apr 2014 14:17:54 +0000 (16:17 +0200)
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>
lib/Kconfig
lib/Kconfig.debug
lib/Makefile
lib/interval_tree.c
lib/interval_tree_test.c [moved from lib/interval_tree_test_main.c with 100% similarity]

index 991c98bc4a3f51e9e7f377274084bec909483ea9..04270aae4b6008da9d5c6a15866d6228e05869b6 100644 (file)
@@ -322,6 +322,20 @@ config TEXTSEARCH_FSM
 config BTREE
        boolean
 
+config INTERVAL_TREE
+       boolean
+       help
+         Simple, embeddable, interval-tree. Can find the start of an
+         overlapping range in log(n) time and then iterate over all
+         overlapping nodes. The algorithm is implemented as an
+         augmented rbtree.
+
+         See:
+
+               Documentation/rbtree.txt
+
+         for more information.
+
 config ASSOCIATIVE_ARRAY
        bool
        help
index a48abeac753f39ef520fbe1bc5243cb494c47621..135a6a0588c9c4bc9826b6af04a0b54ad9eb7df7 100644 (file)
@@ -1487,6 +1487,7 @@ config RBTREE_TEST
 config INTERVAL_TREE_TEST
        tristate "Interval tree test"
        depends on m && DEBUG_KERNEL
+       select INTERVAL_TREE
        help
          A benchmark measuring the performance of the interval tree library
 
index 48140e3ba73f5864a734edb3032be01745b2c678..0969494f20d18a2af295828ff64c6eb9b98c1e2f 100644 (file)
@@ -50,6 +50,7 @@ CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
 
 obj-$(CONFIG_BTREE) += btree.o
+obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
 obj-$(CONFIG_DEBUG_LIST) += list_debug.o
@@ -155,8 +156,6 @@ lib-$(CONFIG_LIBFDT) += $(libfdt_files)
 obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
 obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
 
-interval_tree_test-objs := interval_tree_test_main.o interval_tree.o
-
 obj-$(CONFIG_PERCPU_TEST) += percpu_test.o
 
 obj-$(CONFIG_ASN1) += asn1_decoder.o
index e6eb406f2d65dd3c4e22520239ec10afdd42dc30..f367f9ad544c3901a0ee5bcdfe451ac8b9b2aea3 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/init.h>
 #include <linux/interval_tree.h>
 #include <linux/interval_tree_generic.h>
+#include <linux/module.h>
 
 #define START(node) ((node)->start)
 #define LAST(node)  ((node)->last)
@@ -8,3 +9,8 @@
 INTERVAL_TREE_DEFINE(struct interval_tree_node, rb,
                     unsigned long, __subtree_last,
                     START, LAST,, interval_tree)
+
+EXPORT_SYMBOL_GPL(interval_tree_insert);
+EXPORT_SYMBOL_GPL(interval_tree_remove);
+EXPORT_SYMBOL_GPL(interval_tree_iter_first);
+EXPORT_SYMBOL_GPL(interval_tree_iter_next);