summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2016-06-21 11:33:30 -0400
committerRob Clark <robclark@freedesktop.org>2016-07-20 19:42:21 -0400
commit1d1e01b2350e40711fcf19e200e46e2edfd887b2 (patch)
tree43da328971e543feb35f4a02a2fe3aa43b71da92
parentdd1f372001d4e6de648fa33b6b74d89aaa24cf75 (diff)
downloaddrm-1d1e01b2350e40711fcf19e200e46e2edfd887b2.tar.gz
list: add first/last entry macros
Signed-off-by: Rob Clark <robclark@freedesktop.org>
-rw-r--r--util_double_list.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/util_double_list.h b/util_double_list.h
index 27e0761b..5d01f52d 100644
--- a/util_double_list.h
+++ b/util_double_list.h
@@ -98,6 +98,12 @@ static inline void list_delinit(struct list_head *item)
#define LIST_ENTRY(__type, __item, __field) \
((__type *)(((char *)(__item)) - offsetof(__type, __field)))
+#define LIST_FIRST_ENTRY(__ptr, __type, __field) \
+ LIST_ENTRY(__type, (__ptr)->next, __field)
+
+#define LIST_LAST_ENTRY(__ptr, __type, __field) \
+ LIST_ENTRY(__type, (__ptr)->prev, __field)
+
#define LIST_IS_EMPTY(__list) \
((__list)->next == (__list))