From: Richard Henderson Date: Thu, 14 Feb 2013 01:47:36 +0000 (-0800) Subject: hbitmap: Use non-bitops ctzl X-Git-Tag: v1.5.0-rc0~685 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18331e7c189507513008a2936f5fe79c3d8b8a08;p=thirdparty%2Fqemu.git hbitmap: Use non-bitops ctzl Both uses of ctz have already eliminated zero, and thus the difference in edge conditions between the two routines is irrelevant. Signed-off-by: Richard Henderson Acked-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Blue Swirl --- diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 250de03b03d..550d7ce2c39 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -16,6 +16,7 @@ #include #include #include "bitops.h" +#include "host-utils.h" typedef struct HBitmap HBitmap; typedef struct HBitmapIter HBitmapIter; @@ -170,7 +171,7 @@ static inline int64_t hbitmap_iter_next(HBitmapIter *hbi) /* The next call will resume work from the next bit. */ hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1); - item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + bitops_ctzl(cur); + item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur); return item << hbi->granularity; } diff --git a/util/hbitmap.c b/util/hbitmap.c index a0df5d35915..d93683128bd 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -126,7 +126,8 @@ 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) + bitops_ctzl(cur); + assert(cur); + pos = (pos << BITS_PER_LEVEL) + ctzl(cur); hbi->cur[i] = cur & (cur - 1); /* Set up next level for iteration. */