OSDN Git Service

glsl: Add a foreach_in_list_reverse_safe macro.
authorMatt Turner <mattst88@gmail.com>
Wed, 31 Dec 2014 00:14:25 +0000 (16:14 -0800)
committerMatt Turner <mattst88@gmail.com>
Sat, 24 Jan 2015 01:57:39 +0000 (17:57 -0800)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/list.h

index 330c17e..85368a4 100644 (file)
@@ -636,6 +636,12 @@ inline void exec_node::insert_before(exec_list *before)
         __next != NULL;                              \
         __node = __next, __next = (__type *)__next->next)
 
+#define foreach_in_list_reverse_safe(__type, __node, __list) \
+   for (__type *__node = (__type *)(__list)->tail_pred,      \
+               *__prev = (__type *)__node->prev;             \
+        __prev != NULL;                                      \
+        __node = __prev, __prev = (__type *)__prev->prev)
+
 #define foreach_in_list_use_after(__type, __inst, __list) \
    __type *(__inst);                                      \
    for ((__inst) = (__type *)(__list)->head;              \