Make lib/prio_tree.c a stand-alone library
authorTomohiro Kusumi <tkusumi@tuxera.com>
Tue, 4 Apr 2017 20:22:14 +0000 (23:22 +0300)
committerJens Axboe <axboe@fb.com>
Sat, 8 Apr 2017 17:04:21 +0000 (11:04 -0600)
lib/prio_tree.c not having dependency on fio.h enables it to be
a stand-alone library, which is useful for debugging purpose.
In fact, most of the files under lib/ directory do things this way.

--
 # cat ./test2.c
 #include <stdio.h>
 #include "lib/prio_tree.h"
 int main(void) {
         struct prio_tree_root tree;
         struct prio_tree_node node;
         INIT_PRIO_TREE_ROOT(&tree);
         INIT_PRIO_TREE_NODE(&node);
         prio_tree_insert(&tree, &node);
         prio_tree_remove(&tree, &node);
         printf("%d\n", prio_tree_empty(&tree));
         return 0;
 }
 # gcc -Wall -g -DBITS_PER_LONG=64 ./test2.c ./lib/prio_tree.c
 # ./a.out
 1

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
lib/prio_tree.c

index e18ae324bac4200ee85b5ddda738f6fca006938a..de3fe1c025276bea0f34a5ee10ce8896ec662507 100644 (file)
 
 #include <stdlib.h>
 #include <limits.h>
-#include "../fio.h"
+
+#include "../compiler/compiler.h"
 #include "prio_tree.h"
 
+#define ARRAY_SIZE(x)    (sizeof((x)) / (sizeof((x)[0])))
+
 /*
  * A clever mix of heap and radix trees forms a radix priority search tree (PST)
  * which is useful for storing intervals, e.g, we can consider a vma as a closed