Whamcloud - gitweb
libext2fs: replace 'unsigned long' by 'uintptr_t'
[tools/e2fsprogs.git] / lib / ext2fs / rbtree.h
index 3b0b078..b767a90 100644 (file)
@@ -95,6 +95,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
 #define        _LINUX_RBTREE_H
 
 #include <stdlib.h>
+#include <stdint.h>
 
 #undef offsetof
 #ifdef __compiler_offsetof
@@ -109,7 +110,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
 
 struct rb_node
 {
-       unsigned long  rb_parent_color;
+       uintptr_t  rb_parent_color;
 #define        RB_RED          0
 #define        RB_BLACK        1
        struct rb_node *rb_right;
@@ -132,7 +133,7 @@ struct rb_root
 
 static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p)
 {
-       rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
+       rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p;
 }
 static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
 {
@@ -142,9 +143,20 @@ static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
 #define RB_ROOT        (struct rb_root) { NULL, }
 #define        ext2fs_rb_entry(ptr, type, member) container_of(ptr, type, member)
 
-#define EXT2FS_RB_EMPTY_ROOT(root)     ((root)->rb_node == NULL)
-#define EXT2FS_RB_EMPTY_NODE(node)     (ext2fs_rb_parent(node) == node)
-#define EXT2FS_RB_CLEAR_NODE(node)     (ext2fs_rb_set_parent(node, node))
+static inline int ext2fs_rb_empty_root(struct rb_root *root)
+{
+       return root->rb_node == NULL;
+}
+
+static inline int ext2fs_rb_empty_node(struct rb_node *node)
+{
+       return ext2fs_rb_parent(node) == node;
+}
+
+static inline void ext2fs_rb_clear_node(struct rb_node *node)
+{
+       ext2fs_rb_set_parent(node, node);
+}
 
 extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
 extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
@@ -171,7 +183,7 @@ static inline void ext2fs_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_parent_color = (uintptr_t)parent;
        node->rb_left = node->rb_right = NULL;
 
        *rb_link = node;