summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2009-07-11 17:28:42 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2009-07-20 17:59:00 +0400
commit2a7582945217354eff08e6ca6d4b54e590eb516c (patch)
treeb2d1377d123c77b242c8f3ecf21650c1ba3b5188 /nasmlib.h
parent594c9646aea5a18b83d271c2925701c86f2d7eec (diff)
downloadnasm-2a7582945217354eff08e6ca6d4b54e590eb516c.tar.gz
nasm-2a7582945217354eff08e6ca6d4b54e590eb516c.tar.bz2
nasm-2a7582945217354eff08e6ca6d4b54e590eb516c.zip
nasmlib.h - introduce list iterator helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'nasmlib.h')
-rw-r--r--nasmlib.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/nasmlib.h b/nasmlib.h
index 21e976e..3cb15ba 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -234,6 +234,18 @@ void standard_extension(char *inname, char *outname, char *extension);
#define elements(x) ( sizeof(x) / sizeof(*(x)) )
/*
+ * List handling
+ *
+ * list_for_each - regular iterator over list
+ * list_for_each_safe - the same but safe against list items removal
+ */
+#define list_for_each(pos, head) \
+ for (pos = head; pos; pos = pos->next)
+#define list_for_each_safe(pos, n, head) \
+ for (pos = head, n = (pos ? pos->next : NULL); pos; \
+ pos = n, n = (n ? n->next : NULL))
+
+/*
* some handy macros that will probably be of use in more than one
* output format: convert integers into little-endian byte packed
* format in memory