summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_double_list.h
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-07-02 15:27:17 +1000
committerDave Airlie <airlied@redhat.com>2010-07-02 15:27:17 +1000
commit8556b77c56f3f1f0e75ce46d6b5c0d84c7b4eabd (patch)
tree9157c30056afe4b8b341c06de16a1715218682f0 /src/gallium/auxiliary/util/u_double_list.h
parent44732103b2b7a8765299e586fb3b9bf91e32f6d4 (diff)
r600: use gallium list macros instead of making our own.
before this change, r600 glxinfo segfaulted in the list code, and I wasn't debugging another linked list implementation, its 2010 after all. So add the two missing list macros to the gallium header from X.org list header file (after fixing them), then port all r600 lists to the new header. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/gallium/auxiliary/util/u_double_list.h')
-rw-r--r--src/gallium/auxiliary/util/u_double_list.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_double_list.h b/src/gallium/auxiliary/util/u_double_list.h
index 53bb1342dd..42adb1f069 100644
--- a/src/gallium/auxiliary/util/u_double_list.h
+++ b/src/gallium/auxiliary/util/u_double_list.h
@@ -98,5 +98,20 @@ struct list_head
#define LIST_IS_EMPTY(__list) \
((__list)->next == (__list))
-
+#ifndef container_of
+#define container_of(ptr, sample, member) \
+ (void *)((char *)(ptr) \
+ - ((char *)&(sample)->member - (char *)(sample)))
+#endif
+
+#define LIST_FOR_EACH_ENTRY(pos, head, member) \
+ for (pos = container_of((head)->next, pos, member); \
+ &pos->member != (head); \
+ pos = container_of(pos->member.next, pos, member))
+
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \
+ for (pos = container_of((head)->next, pos, member), \
+ storage = container_of(pos->member.next, pos, member); \
+ &pos->member != (head); \
+ pos = storage, storage = container_of(storage->member.next, storage, member))
#endif /*_U_DOUBLE_LIST_H_*/