[ovs-dev] [PATCH v5 2/5] bitmap: add bitmap_count1 function
Ben Pfaff
blp at nicira.com
Mon Dec 23 20:58:51 UTC 2013
On Wed, Dec 18, 2013 at 05:48:40PM +0800, Alexander Wu wrote:
> v5:
> No change.
>
> v4.1:
> Update bitmap_count1 function: call count_1bits to improve
> performance.
>
> v4:
> Add bitmap_count1 function to count all 1 bits.
>
> Signed-off-by: Alexander Wu <alexander.wu at huawei.com>
> Acked-by: Ben Pfaff <blp at nicira.com>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
Thanks.
I folded in the following changes and will soon apply this to master.
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 655b0a2..51ad5bf 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -94,14 +94,15 @@ bitmap_scan(const unsigned long int *bitmap, size_t start, size_t end)
return i;
}
+/* Returns the number of 1-bits in the 'n'-bit bitmap at 'bitmap'. */
size_t
-bitmap_count1(const unsigned long int *bitmap, size_t end)
+bitmap_count1(const unsigned long int *bitmap, size_t n)
{
size_t i;
size_t count = 0;
BUILD_ASSERT(ULONG_MAX <= UINT64_MAX);
- for (i = 0; i < BITMAP_N_LONGS(end); i++) {
+ for (i = 0; i < BITMAP_N_LONGS(n); i++) {
count += count_1bits(bitmap[i]);
}
More information about the dev
mailing list