exec_list: Add simpler exec_list for-each macros
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 10 May 2010 18:17:23 +0000 (11:17 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 10 May 2010 18:17:23 +0000 (11:17 -0700)
list.h

diff --git a/list.h b/list.h
index 26941746b45cfeedaaa92681758eedcbd8beec78..3bfdf55e2a2b9bb453d5674d00525794558fdd12 100644 (file)
--- a/list.h
+++ b/list.h
@@ -337,4 +337,14 @@ struct exec_list {
 #endif
 };
 
+#define foreach_list(__node, __list)                   \
+   for (exec_node * __node = (__list)->head            \
+       ; (__node)->next != NULL                        \
+       ; (__node) = (__node)->next)
+
+#define foreach_list_const(__node, __list)             \
+   for (const exec_node * __node = (__list)->head      \
+       ; (__node)->next != NULL                        \
+       ; (__node) = (__node)->next)
+
 #endif /* LIST_CONTAINER_H */