summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2013-02-13 17:47:39 -0800
committerBlue Swirl <blauwirbel@gmail.com>2013-02-16 11:12:21 +0000
commit0cfa6adc7fd1eba4694515bde6bbfb9ecd892f2f (patch)
tree16016d943c5821c74febe81c0487480247514f23
parent5bbf90be97203c472f47da070c0040b464c0460f (diff)
downloadfocaccia-qemu-0cfa6adc7fd1eba4694515bde6bbfb9ecd892f2f.tar.gz
focaccia-qemu-0cfa6adc7fd1eba4694515bde6bbfb9ecd892f2f.zip
bitops: Write bitops_flsl in terms of clzl
Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--include/qemu/bitops.h29
1 files changed, 1 insertions, 28 deletions
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 8b88791862..b50629bb58 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);
 }
 
 /**