[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/10] bitops: Write bitops_flsl in terms of clzl
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 06/10] bitops: Write bitops_flsl in terms of clzl |
Date: |
Wed, 13 Feb 2013 17:47:39 -0800 |
Signed-off-by: Richard Henderson <address@hidden>
---
include/qemu/bitops.h | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 8b88791..b50629b 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -57,34 +57,7 @@ static unsigned long bitops_ctzl(unsigned long word)
*/
static inline unsigned long bitops_flsl(unsigned long word)
{
- int num = BITS_PER_LONG - 1;
-
-#if LONG_MAX > 0x7FFFFFFF
- if (!(word & (~0ul << 32))) {
- num -= 32;
- word <<= 32;
- }
-#endif
- if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
- num -= 16;
- word <<= 16;
- }
- if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
- num -= 8;
- word <<= 8;
- }
- if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
- num -= 4;
- word <<= 4;
- }
- if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
- num -= 2;
-
- word <<= 2;
- }
- if (!(word & (~0ul << (BITS_PER_LONG-1))))
- num -= 1;
- return num;
+ return BITS_PER_LONG - 1 - clzl(word);
}
/**
--
1.8.1.2
- [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
- [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 <=
- [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
- Re: [Qemu-devel] [PATCH v2 00/10] Cleanup bitops vs host-utils, Blue Swirl, 2013/02/16