summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2007-12-10 13:20:24 +0100
committerVolker Lendecke <vl@samba.org>2007-12-10 16:06:32 +0100
commit8a8b146ead07149de57069ed803051ce460fa94b (patch)
treeec400eab65c7fe4cbe6aabadd2690b901034bc6e /source3
parent26a2e818face1c2a627e392b4190bed7f2b02656 (diff)
downloadsamba-8a8b146ead07149de57069ed803051ce460fa94b.tar.gz
samba-8a8b146ead07149de57069ed803051ce460fa94b.tar.bz2
samba-8a8b146ead07149de57069ed803051ce460fa94b.zip
Make the Linux rbtrees compile within Samba
(This used to be commit c871fd802f3c0c5ef1f63b2d01a636c885f22b23)
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/rbtree.h55
-rw-r--r--source3/lib/rbtree.c57
3 files changed, 55 insertions, 59 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index f686ac0cbf..01aa236130 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -282,7 +282,7 @@ TALLOC_OBJ = lib/talloc/talloc.o
LIB_WITHOUT_PROTO_OBJ = $(LIBREPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) $(NSS_WRAPPER_OBJ) $(TALLOC_OBJ) \
lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \
- lib/interfaces.o
+ lib/interfaces.o lib/rbtree.o
LIB_WITH_PROTO_OBJ = $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \
lib/interface.o lib/md4.o \
diff --git a/source3/include/rbtree.h b/source3/include/rbtree.h
index 344bc3495d..1cfd3463a0 100644
--- a/source3/include/rbtree.h
+++ b/source3/include/rbtree.h
@@ -94,18 +94,12 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
#ifndef _LINUX_RBTREE_H
#define _LINUX_RBTREE_H
-#include <linux/kernel.h>
-#include <linux/stddef.h>
-
struct rb_node
{
unsigned long rb_parent_color;
-#define RB_RED 0
-#define RB_BLACK 1
struct rb_node *rb_right;
struct rb_node *rb_left;
-} __attribute__((aligned(sizeof(long))));
- /* The alignment might seem pointless, but allegedly CRIS needs it */
+};
struct rb_root
{
@@ -113,49 +107,26 @@ struct rb_root
};
-#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
-#define rb_color(r) ((r)->rb_parent_color & 1)
-#define rb_is_red(r) (!rb_color(r))
-#define rb_is_black(r) rb_color(r)
-#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
-#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
-
-static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
-{
- rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
-}
-static inline void rb_set_color(struct rb_node *rb, int color)
-{
- rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
-}
-
#define RB_ROOT (struct rb_root) { NULL, }
-#define rb_entry(ptr, type, member) container_of(ptr, type, member)
-#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
-#define RB_EMPTY_NODE(node) (rb_parent(node) == node)
-#define RB_CLEAR_NODE(node) (rb_set_parent(node, node))
+#if 0
+#define rb_entry(ptr, type, member) container_of(ptr, type, member)
+#endif
-extern void rb_insert_color(struct rb_node *, struct rb_root *);
-extern void rb_erase(struct rb_node *, struct rb_root *);
+void rb_insert_color(struct rb_node *, struct rb_root *);
+void rb_erase(struct rb_node *, struct rb_root *);
/* Find logical next and previous nodes in a tree */
-extern struct rb_node *rb_next(struct rb_node *);
-extern struct rb_node *rb_prev(struct rb_node *);
-extern struct rb_node *rb_first(struct rb_root *);
-extern struct rb_node *rb_last(struct rb_root *);
+struct rb_node *rb_next(struct rb_node *);
+struct rb_node *rb_prev(struct rb_node *);
+struct rb_node *rb_first(struct rb_root *);
+struct rb_node *rb_last(struct rb_root *);
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
-extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
+extern void rb_replace_node(struct rb_node *victim, struct rb_node *new_node,
struct rb_root *root);
-static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
- struct rb_node ** rb_link)
-{
- node->rb_parent_color = (unsigned long )parent;
- node->rb_left = node->rb_right = NULL;
-
- *rb_link = node;
-}
+void rb_link_node(struct rb_node * node, struct rb_node * parent,
+ struct rb_node ** rb_link);
#endif /* _LINUX_RBTREE_H */
diff --git a/source3/lib/rbtree.c b/source3/lib/rbtree.c
index 48499c2d88..f6868cab5d 100644
--- a/source3/lib/rbtree.c
+++ b/source3/lib/rbtree.c
@@ -20,8 +20,31 @@
linux/lib/rbtree.c
*/
-#include <linux/rbtree.h>
-#include <linux/module.h>
+#include "includes.h"
+#include "rbtree.h"
+
+#define RB_RED 0
+#define RB_BLACK 1
+
+#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
+#define rb_color(r) ((r)->rb_parent_color & 1)
+#define rb_is_red(r) (!rb_color(r))
+#define rb_is_black(r) rb_color(r)
+#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
+#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
+
+static void rb_set_parent(struct rb_node *rb, struct rb_node *p)
+{
+ rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
+}
+static void rb_set_color(struct rb_node *rb, int color)
+{
+ rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
+}
+
+#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
+#define RB_EMPTY_NODE(node) (rb_parent(node) == node)
+#define RB_CLEAR_NODE(node) (rb_set_parent(node, node))
static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
{
@@ -133,7 +156,6 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
rb_set_black(root->rb_node);
}
-EXPORT_SYMBOL(rb_insert_color);
static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
struct rb_root *root)
@@ -287,7 +309,6 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
if (color == RB_BLACK)
__rb_erase_color(child, parent, root);
}
-EXPORT_SYMBOL(rb_erase);
/*
* This function returns the first node (in sort order) of the tree.
@@ -303,7 +324,6 @@ struct rb_node *rb_first(struct rb_root *root)
n = n->rb_left;
return n;
}
-EXPORT_SYMBOL(rb_first);
struct rb_node *rb_last(struct rb_root *root)
{
@@ -316,7 +336,6 @@ struct rb_node *rb_last(struct rb_root *root)
n = n->rb_right;
return n;
}
-EXPORT_SYMBOL(rb_last);
struct rb_node *rb_next(struct rb_node *node)
{
@@ -345,7 +364,6 @@ struct rb_node *rb_next(struct rb_node *node)
return parent;
}
-EXPORT_SYMBOL(rb_next);
struct rb_node *rb_prev(struct rb_node *node)
{
@@ -370,9 +388,8 @@ struct rb_node *rb_prev(struct rb_node *node)
return parent;
}
-EXPORT_SYMBOL(rb_prev);
-void rb_replace_node(struct rb_node *victim, struct rb_node *new,
+void rb_replace_node(struct rb_node *victim, struct rb_node *new_node,
struct rb_root *root)
{
struct rb_node *parent = rb_parent(victim);
@@ -380,18 +397,26 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
/* Set the surrounding nodes to point to the replacement */
if (parent) {
if (victim == parent->rb_left)
- parent->rb_left = new;
+ parent->rb_left = new_node;
else
- parent->rb_right = new;
+ parent->rb_right = new_node;
} else {
- root->rb_node = new;
+ root->rb_node = new_node;
}
if (victim->rb_left)
- rb_set_parent(victim->rb_left, new);
+ rb_set_parent(victim->rb_left, new_node);
if (victim->rb_right)
- rb_set_parent(victim->rb_right, new);
+ rb_set_parent(victim->rb_right, new_node);
/* Copy the pointers/colour from the victim to the replacement */
- *new = *victim;
+ *new_node = *victim;
+}
+
+void rb_link_node(struct rb_node * node, struct rb_node * parent,
+ struct rb_node ** rb_link)
+{
+ node->rb_parent_color = (unsigned long )parent;
+ node->rb_left = node->rb_right = NULL;
+
+ *rb_link = node;
}
-EXPORT_SYMBOL(rb_replace_node);