aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-05-25 12:32:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-01 15:13:00 +0800
commit6115b7a54b2a3f0b6fc783715f606d3760962dc9 (patch)
treeca535872e161ffc6ad71c85a6af714c78a4c59d6 /arch/tile
parent0d7755e450865b76b98e3fea2e166b0a2266972d (diff)
downloadkernel_samsung_aries-6115b7a54b2a3f0b6fc783715f606d3760962dc9.zip
kernel_samsung_aries-6115b7a54b2a3f0b6fc783715f606d3760962dc9.tar.gz
kernel_samsung_aries-6115b7a54b2a3f0b6fc783715f606d3760962dc9.tar.bz2
tile: fix bug where fls(0) was not returning 0
commit 9f1d62bed7f015d11b9164078b7fea433b474114 upstream. This is because __builtin_clz(0) returns 64 for the "undefined" case of 0, since the builtin just does a right-shift 32 and "clz" instruction. So, use the alpha approach of casting to u32 and using __builtin_clzll(). Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/tile')
-rw-r--r--arch/tile/include/asm/bitops.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
index 16f1fa5..bd186c4 100644
--- a/arch/tile/include/asm/bitops.h
+++ b/arch/tile/include/asm/bitops.h
@@ -77,6 +77,11 @@ static inline int ffs(int x)
return __builtin_ffs(x);
}
+static inline int fls64(__u64 w)
+{
+ return (sizeof(__u64) * 8) - __builtin_clzll(w);
+}
+
/**
* fls - find last set bit in word
* @x: the word to search
@@ -90,12 +95,7 @@ static inline int ffs(int x)
*/
static inline int fls(int x)
{
- return (sizeof(int) * 8) - __builtin_clz(x);
-}
-
-static inline int fls64(__u64 w)
-{
- return (sizeof(__u64) * 8) - __builtin_clzll(w);
+ return fls64((unsigned int) x);
}
static inline unsigned int __arch_hweight32(unsigned int w)