CBL-Mariner/SPECS/libiscsi/0004-iser-Use-local-contain...

43 lines
1.2 KiB
Diff

From: Cole Robinson <crobinso@redhat.com>
Date: Mon, 30 Apr 2018 18:11:05 -0400
Subject: [PATCH] iser: Use local container_of definition
The code was implicitly dependent on container_of from
inifiniband/verbs.h, however that's been removed in rdma-core
latest release:
https://github.com/linux-rdma/rdma-core/commit/ce0274acffc78ed2861a56bdc34cdd3d60c20e1f
Define container_of locally if it's not already defined
(cherry picked from commit f1feb218e2823d236569f0ca3cfad07334f2a304)
---
lib/iser.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/iser.c b/lib/iser.c
index 17832c3..aa7244c 100644
--- a/lib/iser.c
+++ b/lib/iser.c
@@ -32,6 +32,20 @@
#include <semaphore.h>
#include <poll.h>
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) \
+ ((type *) ((uint8_t *)(ptr) - offsetof(type, member)))
+#endif
+
+
#ifdef __linux
static int cq_handle(struct iser_conn *iser_conn);