Add cl_item_obj() macro which resolves the object reference by its
item field. This can be useful with lists and maps when list/map item
is not a first member of the object structure.
Signed-off-by: Sasha Khapyorsky <[EMAIL PROTECTED]>
---
opensm/include/complib/cl_qlist.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/opensm/include/complib/cl_qlist.h
b/opensm/include/complib/cl_qlist.h
index a02da99..c515f7e 100644
--- a/opensm/include/complib/cl_qlist.h
+++ b/opensm/include/complib/cl_qlist.h
@@ -132,6 +132,10 @@ typedef struct _cl_list_item {
* Quick List
*********/
+#define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \
+ ((void *)item_ptr - (unsigned long)&((typeof(obj_ptr))0)->item_field)
+
+
/****s* Component Library: Quick List/cl_list_obj_t
* NAME
* cl_list_obj_t
--
1.5.5.1.178.g1f811
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general