queue_extras: use SPDK_CONTAINEROF

A couple of the functions inside of the queue_extras file were relying
on an undefined __containerof function. Replace that with
SPDK_CONTAINEROF. Then add an extra check so that when someone includes
this file on FreeBSD, it doesn't throw compiler warnings for the
redefinitions (see our cpp headers test for example).

The argument order for both functions is the same, namely pointer, type,
member.

Change-Id: I1bd0497ee14df8b37f4de1046e271e5fe144ca82
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470191
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
Seth Howell 2019-10-02 10:22:27 -07:00 committed by Jim Harris
parent 584a630287
commit fcaabb48fa
2 changed files with 8 additions and 2 deletions

View File

@ -105,6 +105,8 @@
* *
*/ */
#include "spdk/util.h"
/* /*
* Singly-linked Tail queue declarations. * Singly-linked Tail queue declarations.
*/ */
@ -141,7 +143,7 @@ struct name { \
#define STAILQ_LAST(head, type, field) \ #define STAILQ_LAST(head, type, field) \
(STAILQ_EMPTY((head)) ? NULL : \ (STAILQ_EMPTY((head)) ? NULL : \
__containerof((head)->stqh_last, struct type, field.stqe_next)) SPDK_CONTAINEROF((head)->stqh_last, struct type, field.stqe_next))
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
@ -233,7 +235,7 @@ struct { \
#define LIST_PREV(elm, head, type, field) \ #define LIST_PREV(elm, head, type, field) \
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
__containerof((elm)->field.le_prev, struct type, field.le_next)) SPDK_CONTAINEROF((elm)->field.le_prev, struct type, field.le_next))
#define LIST_SWAP(head1, head2, type, field) do { \ #define LIST_SWAP(head1, head2, type, field) do { \
struct type *swap_tmp = LIST_FIRST((head1)); \ struct type *swap_tmp = LIST_FIRST((head1)); \

View File

@ -35,6 +35,10 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
HEADERS := $(wildcard $(SPDK_ROOT_DIR)/include/spdk/*.h) HEADERS := $(wildcard $(SPDK_ROOT_DIR)/include/spdk/*.h)
# On Linux, queue_extras.h is pulled in with queue.h,
# on FreeBSD, we want to ignore queue_extras.h entirely.
HEADERS := $(filter-out $(SPDK_ROOT_DIR)/include/spdk/queue_extras.h,$(HEADERS))
CXX_SRCS := $(patsubst %.h,%.cpp,$(notdir $(HEADERS))) CXX_SRCS := $(patsubst %.h,%.cpp,$(notdir $(HEADERS)))
install : all install : all