diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-02 15:38:46 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-02 15:38:46 +0200 |
commit | dd7a74db87297f74c9bb0f57d8ff3df51e89f37e (patch) | |
tree | 5fb0cd4ceda493810be2f34c4affd7872022aab6 | |
parent | 6b1c8e0f50f73552c9db2a7e04960deef5cd0e6a (diff) | |
download | barebox-dd7a74db87297f74c9bb0f57d8ff3df51e89f37e.tar.gz barebox-dd7a74db87297f74c9bb0f57d8ff3df51e89f37e.tar.xz |
ARM bitops: fix for arm arch < 5
The correct bitops implementation depends on __LINUX_ARM_ARCH__ being
set. We do not currently support this variable. Change the default case
to < armv5, so that we do not end up with clz instructions in v4 code.
This is actually a workaround, the correct solution is to set
__LINUX_ARM_ARCH__ correctly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | include/asm-arm/bitops.h | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index b1d34f8633..138ebe2d8c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -115,30 +115,7 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset); #endif /* __ARMEB__ */ -#if defined(__LINUX_ARM_ARCH__) && (__LINUX_ARM_ARCH__ < 5) - -/* - * ffz = Find First Zero in word. Undefined if no zero exists, - * so code should check against ~0UL first.. - */ -static inline unsigned long ffz(unsigned long word) -{ - int k; - - word = ~word; - k = 31; - if (word & 0x0000ffff) { k -= 16; word <<= 16; } - if (word & 0x00ff0000) { k -= 8; word <<= 8; } - if (word & 0x0f000000) { k -= 4; word <<= 4; } - if (word & 0x30000000) { k -= 2; word <<= 2; } - if (word & 0x40000000) { k -= 1; } - return k; -} -#include <asm-generic/bitops/__ffs.h> -#include <asm-generic/bitops/ffs.h> -#include <asm-generic/bitops/fls.h> -#else /* ! __ARM__USE_GENERIC_FF */ - +#if defined(__LINUX_ARM_ARCH__) && (__LINUX_ARM_ARCH__ >= 5) static inline int constant_fls(int x) { int r = 32; @@ -178,6 +155,27 @@ static inline int constant_fls(int x) #define ffs(x) ({ unsigned long __t = (x); fls(__t &-__t); }) #define __ffs(x) (ffs(x) - 1) #define ffz(x) __ffs(~(x)) +#else /* ! __ARM__USE_GENERIC_FF */ +/* + * ffz = Find First Zero in word. Undefined if no zero exists, + * so code should check against ~0UL first.. + */ +static inline unsigned long ffz(unsigned long word) +{ + int k; + + word = ~word; + k = 31; + if (word & 0x0000ffff) { k -= 16; word <<= 16; } + if (word & 0x00ff0000) { k -= 8; word <<= 8; } + if (word & 0x0f000000) { k -= 4; word <<= 4; } + if (word & 0x30000000) { k -= 2; word <<= 2; } + if (word & 0x40000000) { k -= 1; } + return k; +} +#include <asm-generic/bitops/__ffs.h> +#include <asm-generic/bitops/ffs.h> +#include <asm-generic/bitops/fls.h> #endif /* __ARM__USE_GENERIC_FF */ #include <asm-generic/bitops/fls64.h> |