util/list: add list_first/last_entry
authorRob Clark <robclark@freedesktop.org>
Wed, 29 Apr 2015 12:38:45 +0000 (08:38 -0400)
committerRob Clark <robclark@freedesktop.org>
Sun, 21 Jun 2015 11:52:36 +0000 (07:52 -0400)
I need an easier way to get at head/tail in ir3.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/util/list.h

index 946034710efd6e11b70b9645458ff3d8f39b6a75..b98ce59ff77d6c6344f6147fe13214b022c7a863 100644 (file)
@@ -140,6 +140,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);                                         \