summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/bitmap.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-12-13 23:26:56 +0100
committerDave Barach <openvpp@barachs.net>2020-12-14 12:14:21 +0000
commitf0ca1e8d92114582ec9142bd15a40f1eb0102793 (patch)
treeaba56d88d909387605ba7fdaf7fc0fd5d3ff565c /src/vppinfra/bitmap.h
parentb2c31b685fd2cf28436ca32bc93e23eb24c74878 (diff)
misc: refactor clib_bitmap_foreach macro
Type: refactor Change-Id: I077110e1a422722e20aa546a6f3224c06ab0cde5 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/bitmap.h')
-rw-r--r--src/vppinfra/bitmap.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h
index 44411163975..5c56068da77 100644
--- a/src/vppinfra/bitmap.h
+++ b/src/vppinfra/bitmap.h
@@ -358,7 +358,13 @@ clib_bitmap_set_region (uword * bitmap, uword i, uword value, uword n_bits)
@param ai - the bitmap
@param body - the expression to evaluate for each set bit
*/
-#define clib_bitmap_foreach(i,ai,body) \
+#define clib_bitmap_foreach(i,ai) \
+ if (ai) \
+ for (i = clib_bitmap_first_set (ai); \
+ i != ~0; \
+ i = clib_bitmap_next_set (ai, i + 1))
+
+#define clib_bitmap_foreach_old(i,ai,body) \
do { \
uword __bitmap_i, __bitmap_ai, __bitmap_len, __bitmap_first_set; \
__bitmap_len = vec_len ((ai)); \