path: root/util/hbitmap.c
diff options
authorPaolo Bonzini <>2013-02-01 23:03:16 +0100
committerBlue Swirl <>2013-02-02 20:16:00 +0000
commitfbeadf50f2f965741def823036b086bbc2999b1f (patch)
tree859da9be446ae21d999274d1972730a69e1de9ee /util/hbitmap.c
parent7b2d9779818f4c0d4c31d3a0292bee1c4b633217 (diff)
bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl
We had two copies of a ffs function for longs with subtly different semantics and, for the one in bitops.h, a confusing name: the result was off-by-one compared to the library function ffsl. Unify the functions into one, and solve the name problem by calling the 0-based functions "bitops_ctzl" and "bitops_ctol" respectively. This also fixes the build on platforms with ffsl, including Mac OS X and Windows. Signed-off-by: Paolo Bonzini <> Reviewed-by: Eric Blake <> Tested-by: Andreas Färber <> Tested-by: Peter Maydell <> Signed-off-by: Blue Swirl <>
Diffstat (limited to 'util/hbitmap.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 2aa487d..a0df5d3 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -126,7 +126,7 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
* The index of this word's least significant set bit provides
* the low-order bits.
- pos = (pos << BITS_PER_LEVEL) + ffsl(cur) - 1;
+ pos = (pos << BITS_PER_LEVEL) + bitops_ctzl(cur);
hbi->cur[i] = cur & (cur - 1);
/* Set up next level for iteration. */
OpenPOWER on IntegriCloud