[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/10] hbitmap: Use non-bitops ctzl
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 03/10] hbitmap: Use non-bitops ctzl |
Date: |
Thu, 14 Feb 2013 16:03:54 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
Il 14/02/2013 02:47, Richard Henderson ha scritto:
> 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 <address@hidden>
> ---
> include/qemu/hbitmap.h | 3 ++-
> util/hbitmap.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
> index 250de03..550d7ce 100644
> --- a/include/qemu/hbitmap.h
> +++ b/include/qemu/hbitmap.h
> @@ -16,6 +16,7 @@
> #include <stdint.h>
> #include <stdbool.h>
> #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 a0df5d3..d936831 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. */
>
Acked-by: Paolo Bonzini <address@hidden>
- [Qemu-devel] [PATCH v2 00/10] Cleanup bitops vs host-utils, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 01/10] host-utils: Add host long specific aliases for clz, ctz, ctpop, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 02/10] host-utils: Fix coding style and add comments, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 03/10] hbitmap: Use non-bitops ctzl, Richard Henderson, 2013/02/13
- Re: [Qemu-devel] [PATCH 03/10] hbitmap: Use non-bitops ctzl,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 04/10] bitops: Use non-bitops ctzl, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 05/10] memory: Use non-bitops ctzl, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 06/10] bitops: Write bitops_flsl in terms of clzl, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 07/10] target-i386: Inline bitops_flsl, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 08/10] bitops: Inline bitops_flsl, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 10/10] bitops: Remove routines redundant with host-utils, Richard Henderson, 2013/02/13
- [Qemu-devel] [PATCH 09/10] bitops: Replace bitops_ctol with ctzl, Richard Henderson, 2013/02/13
- Re: [Qemu-devel] [PATCH v2 00/10] Cleanup bitops vs host-utils, Peter Maydell, 2013/02/14
- Re: [Qemu-devel] [PATCH v2 00/10] Cleanup bitops vs host-utils, Eric Blake, 2013/02/14