Move rbtree into lib/

And make ARRAY_SIZE() generally available, also outside gfio.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/Makefile b/Makefile
index 1d3cc85..063823d 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@
 
 SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
 		eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
-		rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
+		lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
 		lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
 		engines/mmap.c engines/sync.c engines/null.c engines/net.c \
 		memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
diff --git a/fio.h b/fio.h
index 28198b9..393f381 100644
--- a/fio.h
+++ b/fio.h
@@ -20,7 +20,7 @@
 #include "thread_options.h"
 #include "flist.h"
 #include "fifo.h"
-#include "rbtree.h"
+#include "lib/rbtree.h"
 #include "arch/arch.h"
 #include "os/os.h"
 #include "mutex.h"
@@ -551,4 +551,6 @@
 extern const char *fio_get_arch_string(int);
 extern const char *fio_get_os_string(int);
 
+#define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
+
 #endif
diff --git a/gclient.c b/gclient.c
index dfdd870..deb20f0 100644
--- a/gclient.c
+++ b/gclient.c
@@ -736,7 +736,7 @@
 	GType types[FIO_IO_U_MAP_NR + 1];
 	int i;
 	const char *labels[] = { "Depth", "0", "1", "2", "4", "8", "16", "32", "64", ">= 64" };
-	const int nr_labels = ARRAYSIZE(labels);
+	const int nr_labels = ARRAY_SIZE(labels);
 
 	frame = gtk_frame_new("IO depths");
 	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
diff --git a/gfio.c b/gfio.c
index e4d1f21..274dea8 100644
--- a/gfio.c
+++ b/gfio.c
@@ -1389,7 +1389,7 @@
 	gtk_container_add(GTK_CONTAINER(bottom_align), ge->buttonbox);
 	gtk_box_pack_start(GTK_BOX(main_vbox), bottom_align, FALSE, FALSE, 0);
 
-	add_buttons(ge, buttonspeclist, ARRAYSIZE(buttonspeclist));
+	add_buttons(ge, buttonspeclist, ARRAY_SIZE(buttonspeclist));
 
 	/*
 	 * Set up thread status progress bar
diff --git a/gfio.h b/gfio.h
index dd4ee3d..71b2db7 100644
--- a/gfio.h
+++ b/gfio.h
@@ -144,8 +144,6 @@
 	unsigned int nr_du;
 };
 
-#define ARRAYSIZE(x) (sizeof((x)) / (sizeof((x)[0])))
-
 #define GFIO_MIME	"text/fio"
 
 extern void gfio_view_log(struct gui *ui);
diff --git a/iolog.h b/iolog.h
index 18d3c6c..0d6b506 100644
--- a/iolog.h
+++ b/iolog.h
@@ -1,7 +1,7 @@
 #ifndef FIO_IOLOG_H
 #define FIO_IOLOG_H
 
-#include "rbtree.h"
+#include "lib/rbtree.h"
 #include "lib/ieee754.h"
 #include "ioengine.h"
 
diff --git a/rbtree.c b/lib/rbtree.c
similarity index 100%
rename from rbtree.c
rename to lib/rbtree.c
diff --git a/rbtree.h b/lib/rbtree.h
similarity index 100%
rename from rbtree.h
rename to lib/rbtree.h