summaryrefslogtreecommitdiff
path: root/list.h
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-05-10 17:40:41 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-05-10 17:40:41 -0700
commit4cfbad9e4df4acb011676bde761af557ae58e96a (patch)
treee87aaf56daf343a7768322ec1393efa3809aaa9a /list.h
parent304ea90233baeac6801a98e981658cb7a2d2501c (diff)
exec_list: Add foreach_list_typed and foreach_list_typed_const
These variations are parameterized by the type of the nodes in the list. This enables skipping the explicit usage of exec_node_data in the loop body.
Diffstat (limited to 'list.h')
-rw-r--r--list.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/list.h b/list.h
index 3bfdf55e2a..615be05437 100644
--- a/list.h
+++ b/list.h
@@ -347,4 +347,16 @@ struct exec_list {
; (__node)->next != NULL \
; (__node) = (__node)->next)
+#define foreach_list_typed(__type, __node, __field, __list) \
+ for (__type * __node = \
+ exec_node_data(__type, (__list)->head, __field); \
+ (__node)->__field.next != NULL; \
+ (__node) = exec_node_data(__type, (__node)->__field.next, __field))
+
+#define foreach_list_typed_const(__type, __node, __field, __list) \
+ for (const __type * __node = \
+ exec_node_data(__type, (__list)->head, __field); \
+ (__node)->__field.next != NULL; \
+ (__node) = exec_node_data(__type, (__node)->__field.next, __field))
+
#endif /* LIST_CONTAINER_H */