From 84588b3ba898ff86c485a811cf4d381a08bc57c2 Mon Sep 17 00:00:00 2001 From: Jiewei Ke Date: Tue, 25 May 2021 05:51:13 -0400 Subject: [PATCH] util: rename RB_ROOT into _RB_ROOT In examples/bdev/fio_plugin/fio_plugin, it will include fio.h which defines the RB_ROOT macro. To workaround the RB_ROOT redefined error, rename RB_ROOT to _RB_ROOT. Signed-off-by: Jiewei Ke Change-Id: Ied4f835e4d1657ca5a0a80c13c72845c774618d8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8044 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- include/spdk/tree.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/include/spdk/tree.h b/include/spdk/tree.h index 958185ceef..6da45995ab 100644 --- a/include/spdk/tree.h +++ b/include/spdk/tree.h @@ -340,8 +340,13 @@ struct { \ #define RB_RED_RIGHT(elm, field) ((RB_BITS(elm, field) & RB_RED_R) != 0) #define RB_PARENT(elm, field) ((__typeof(RB_UP(elm, field))) \ (RB_BITS(elm, field) & ~RB_RED_MASK)) -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) +/* + * _RB_ROOT starts with an underscore. This is a workaround for the issue that + * RB_ROOT() had a name conflict with the SPDK FIO plugin. The SPDK FIO plugin + * includes FIO and FIO defines RB_ROOT() itself. + */ +#define _RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (_RB_ROOT(head) == NULL) #define RB_SET_PARENT(dst, src, field) do { \ RB_BITS(dst, field) &= RB_RED_MASK; \ @@ -368,7 +373,7 @@ struct { \ #define RB_SWAP_CHILD(head, out, in, field) do { \ if (RB_PARENT(out, field) == NULL) \ - RB_ROOT(head) = (in); \ + _RB_ROOT(head) = (in); \ else if ((out) == RB_LEFT(RB_PARENT(out, field), field)) \ RB_LEFT(RB_PARENT(out, field), field) = (in); \ else \ @@ -638,7 +643,7 @@ name##_RB_INSERT(struct name *head, struct type *elm) \ struct type *tmp; \ struct type *parent = NULL; \ int comp = 0; \ - tmp = RB_ROOT(head); \ + tmp = _RB_ROOT(head); \ while (tmp) { \ parent = tmp; \ comp = (cmp)(elm, parent); \ @@ -651,7 +656,7 @@ name##_RB_INSERT(struct name *head, struct type *elm) \ } \ RB_SET(elm, parent, field); \ if (parent == NULL) \ - RB_ROOT(head) = elm; \ + _RB_ROOT(head) = elm; \ else if (comp < 0) \ RB_LEFT(parent, field) = elm; \ else \ @@ -669,7 +674,7 @@ name##_RB_INSERT(struct name *head, struct type *elm) \ attr struct type * \ name##_RB_FIND(struct name *head, struct type *elm) \ { \ - struct type *tmp = RB_ROOT(head); \ + struct type *tmp = _RB_ROOT(head); \ int comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ @@ -688,7 +693,7 @@ name##_RB_FIND(struct name *head, struct type *elm) \ attr struct type * \ name##_RB_NFIND(struct name *head, struct type *elm) \ { \ - struct type *tmp = RB_ROOT(head); \ + struct type *tmp = _RB_ROOT(head); \ struct type *res = NULL; \ int comp; \ while (tmp) { \ @@ -755,7 +760,7 @@ name##_RB_PREV(struct type *elm) \ attr struct type * \ name##_RB_MINMAX(struct name *head, int val) \ { \ - struct type *tmp = RB_ROOT(head); \ + struct type *tmp = _RB_ROOT(head); \ struct type *parent = NULL; \ while (tmp) { \ parent = tmp; \