[ofa-general] [PATCH] opensm/complib: cl_item_obj macro
Sasha Khapyorsky
sashak at voltaire.com
Tue Jun 24 13:43:40 PDT 2008
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 <sashak at voltaire.com>
---
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
More information about the general
mailing list