Index: sys/compat/linuxkpi/common/include/linux/rbtree.h =================================================================== --- sys/compat/linuxkpi/common/include/linux/rbtree.h +++ sys/compat/linuxkpi/common/include/linux/rbtree.h @@ -74,11 +74,8 @@ #define RB_EMPTY_NODE(node) (RB_PARENT(node, __entry) == node) #define RB_CLEAR_NODE(node) RB_SET_PARENT(node, node, __entry) -#define rb_insert_color(node, root) do { \ - if (rb_parent(node)) \ - linux_root_RB_INSERT_COLOR((struct linux_root *)(root), \ - rb_parent(node), (node)); \ -} while (0) +#define rb_insert_color(node, root) \ + linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node)) #define rb_erase(node, root) \ linux_root_RB_REMOVE((struct linux_root *)(root), (node)) #define rb_next(node) RB_NEXT(linux_root, NULL, (node)) @@ -148,9 +145,7 @@ rb_insert_color_cached(struct rb_node *node, struct rb_root_cached *root, bool leftmost) { - if (rb_parent(node)) - linux_root_RB_INSERT_COLOR((struct linux_root *)&root->rb_root, - rb_parent(node), node); + linux_root_RB_INSERT_COLOR((struct linux_root *)&root->rb_root, node); if (leftmost) root->rb_leftmost = node; } Index: sys/sys/tree.h =================================================================== --- sys/sys/tree.h +++ sys/sys/tree.h @@ -412,6 +412,7 @@ RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ RB_PROTOTYPE_RANK(name, type, attr) \ + RB_PROTOTYPE_DO_INSERT_COLOR(name, type, attr); \ RB_PROTOTYPE_INSERT_COLOR(name, type, attr); \ RB_PROTOTYPE_REMOVE_COLOR(name, type, attr); \ RB_PROTOTYPE_INSERT_FINISH(name, type, attr); \ @@ -431,9 +432,11 @@ #else #define RB_PROTOTYPE_RANK(name, type, attr) #endif -#define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \ - attr struct type *name##_RB_INSERT_COLOR(struct name *, \ +#define RB_PROTOTYPE_DO_INSERT_COLOR(name, type, attr) \ + attr struct type *name##_RB_DO_INSERT_COLOR(struct name *, \ struct type *, struct type *) +#define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \ + attr struct type *name##_RB_INSERT_COLOR(struct name *, struct type *) #define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \ attr struct type *name##_RB_REMOVE_COLOR(struct name *, \ struct type *, struct type *) @@ -472,6 +475,7 @@ RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ RB_GENERATE_RANK(name, type, field, attr) \ + RB_GENERATE_DO_INSERT_COLOR(name, type, field, attr) \ RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \ RB_GENERATE_INSERT_FINISH(name, type, field, attr) \ @@ -522,9 +526,9 @@ #define RB_GENERATE_RANK(name, type, field, attr) #endif -#define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ +#define RB_GENERATE_DO_INSERT_COLOR(name, type, field, attr) \ attr struct type * \ -name##_RB_INSERT_COLOR(struct name *head, \ +name##_RB_DO_INSERT_COLOR(struct name *head, \ struct type *parent, struct type *elm) \ { \ /* \ @@ -625,6 +629,20 @@ return (NULL); \ } +#define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ +attr struct type * \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *tmp; \ + \ + parent = RB_PARENT(elm, field); \ + if (parent != NULL) \ + tmp = name##_RB_DO_INSERT_COLOR(head, parent, elm); \ + else \ + tmp = NULL; \ + return (tmp); \ +} + #ifndef RB_STRICT_HST /* * In REMOVE_COLOR, the HST paper, in figure 3, in the single-rotate case, has @@ -826,7 +844,7 @@ RB_SET(elm, parent, field); \ *pptr = elm; \ if (parent != NULL) \ - tmp = name##_RB_INSERT_COLOR(head, parent, elm); \ + tmp = name##_RB_DO_INSERT_COLOR(head, parent, elm); \ _RB_AUGMENT_WALK(elm, tmp, field); \ if (tmp != NULL) \ /* \