[Mesa-dev] [PATCH] util/list: add list_first/last_entry
Rob Clark
robdclark at gmail.com
Thu Apr 30 17:14:06 PDT 2015
From: Rob Clark <robclark at freedesktop.org>
I need an easier way to get at head/tail in ir3.
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
Applies on top of Jason's move-u_double_list-to-util patches
src/util/list.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/util/list.h b/src/util/list.h
index 50bad4a..7ec2622 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -137,6 +137,13 @@ static inline void list_validate(struct list_head *list)
- ((char *)&(sample)->member - (char *)(sample)))
#endif
+#define list_first_entry(ptr, type, member) \
+ LIST_ENTRY(type, (ptr)->next, member)
+
+#define list_last_entry(ptr, type, member) \
+ LIST_ENTRY(type, (ptr)->prev, member)
+
+
#define LIST_FOR_EACH_ENTRY(pos, head, member) \
for (pos = NULL, pos = container_of((head)->next, pos, member); \
&pos->member != (head); \
--
2.3.6
More information about the mesa-dev
mailing list