glsl: Add typed foreach_in_list/_reverse macros.
authorMatt Turner <mattst88@gmail.com>
Tue, 24 Jun 2014 23:36:04 +0000 (16:36 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 1 Jul 2014 15:55:51 +0000 (08:55 -0700)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/list.h

index 576bc14e44e860748b1109f3aefa7acd362d26cf..914ce9625278d1d171ffc213ad42a962470e2c35 100644 (file)
@@ -573,6 +573,16 @@ inline void exec_node::insert_before(exec_list *before)
        ; (__node)->next != NULL                        \
        ; (__node) = (__node)->next)
 
+#define foreach_in_list(__type, __inst, __list)      \
+   for (__type *(__inst) = (__type *)(__list)->head; \
+        !(__inst)->is_tail_sentinel();               \
+        (__inst) = (__type *)(__inst)->next)
+
+#define foreach_in_list_reverse(__type, __inst, __list) \
+   for (__type *(__inst) = (__type *)(__list)->head;    \
+        !(__inst)->is_head_sentinel();                  \
+        (__inst) = (__type *)(__inst)->prev)
+
 /**
  * Iterate through two lists at once.  Stops at the end of the shorter list.
  *