summaryrefslogtreecommitdiff
path: root/kern/bitmap.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2013-03-08 20:16:44 +0100
committerRichard Braun <rbraun@sceen.net>2013-03-08 20:16:44 +0100
commitfd6d3fc0f5ea8fa68dbe265ff30cabe0a9aa2506 (patch)
treeb1c38f4829a4479997e019767c4b49812064d231 /kern/bitmap.h
parent5377570ed371072725f725137108c6e4fe60c2a2 (diff)
kern/bitmap: add the bitmap_for_each macro
Diffstat (limited to 'kern/bitmap.h')
-rw-r--r--kern/bitmap.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/kern/bitmap.h b/kern/bitmap.h
index 3663469d..fb22d69f 100644
--- a/kern/bitmap.h
+++ b/kern/bitmap.h
@@ -16,6 +16,9 @@
*
*
* Arbitrary-length bit arrays.
+ *
+ * Most functions do not check whether the given parameters are valid. This
+ * is the responsibility of the caller.
*/
#ifndef _KERN_BITMAP_H
@@ -156,4 +159,10 @@ bitmap_find_first(volatile unsigned long *bm, int nr_bits)
return bitmap_find_next(bm, nr_bits, 0);
}
+#define bitmap_for_each(bm, nr_bits, bit) \
+for ((bit) = 0; \
+ ((bit) < nr_bits) \
+ && (((bit) = bitmap_find_next(bm, nr_bits, bit)) != -1); \
+ (bit)++)
+
#endif /* _KERN_BITMAP_H */