qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 16/21] hbitmap: add hbitmap_count_between() function


From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-devel] [PATCH 16/21] hbitmap: add hbitmap_count_between() function
Date: Fri, 23 Dec 2016 17:28:59 +0300

Add this function only for HBitmap's with greanularity = 0.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Pavel Butsykin <address@hidden>
---
 include/qemu/hbitmap.h | 2 ++
 util/hbitmap.c         | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index 2873a46..1967e13 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -314,4 +314,6 @@ static inline size_t hbitmap_iter_next_word(HBitmapIter 
*hbi, unsigned long *p_c
 }
 
 
+uint64_t hbitmap_count_between(HBitmap *hb, uint64_t start, uint64_t end);
+
 #endif
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 48d8b2d..d06bfa3 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -232,6 +232,15 @@ static uint64_t hb_count_between(HBitmap *hb, uint64_t 
start, uint64_t last)
     return count;
 }
 
+/* hbitmap_count_between() is only for HBitmap's with granularity = 0 */
+uint64_t hbitmap_count_between(HBitmap *hb, uint64_t start, uint64_t end)
+{
+    assert(hb->granularity == 0);
+    assert(start < end);
+
+    return hb_count_between(hb, start, end - 1);
+}
+
 /* Setting starts at the last layer and propagates up if an element
  * changes.
  */
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]