V4:
Add bitmap_count1 function to count all 1 bits.
---
lib/bitmap.c | 15 +++++++++++++++
lib/bitmap.h | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index ac568e9..7dd5a0f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -92,3 +92,18 @@ bitmap_scan(const unsigned long int *bitmap, size_t start,
size_t end)
}
return i;
}
+
+size_t
+bitmap_count1(const unsigned long int *bitmap, size_t end)
+{
+ size_t i;
+ size_t count = 0;
+
+ for (i = 0; i < end; i++) {
+ if (bitmap_is_set(bitmap, i)) {
+ ++count;
+ }
+ }
+
+ return count;
+}
diff --git a/lib/bitmap.h b/lib/bitmap.h
index 645f15f..5e6f8ed 100644
--- a/lib/bitmap.h
+++ b/lib/bitmap.h
@@ -101,6 +101,7 @@ void bitmap_set_multiple(unsigned long *, size_t start,
size_t count,
bool value);
bool bitmap_equal(const unsigned long *, const unsigned long *, size_t n);
size_t bitmap_scan(const unsigned long int *, size_t start, size_t end);
+size_t bitmap_count1(const unsigned long *, size_t n);
#define BITMAP_FOR_EACH_1(IDX, SIZE, BITMAP) \
for ((IDX) = bitmap_scan(BITMAP, 0, SIZE); (IDX) < (SIZE); \
--
1.7.3.1.msysgit.0
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev