From fd6d3fc0f5ea8fa68dbe265ff30cabe0a9aa2506 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 8 Mar 2013 20:16:44 +0100 Subject: kern/bitmap: add the bitmap_for_each macro --- kern/bitmap.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'kern/bitmap.h') 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 */ -- cgit v1.2.3