aboutsummaryrefslogtreecommitdiff
path: root/include/asm-arm/bitops.h
diff options
context:
space:
mode:
authorAkinobu Mita <mita@miraclelinux.com>2006-03-26 01:38:59 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 08:57:09 -0800
commit93635133663ea3155e74a0e3645b64754a046007 (patch)
tree6eb48fde8cc6a54d6b63ba160158f1b4688b337d /include/asm-arm/bitops.h
parentf214ef3e193dea10a7b527d4f4b0c15d2d98c984 (diff)
[PATCH] arm: fix undefined reference to generic_fls
This patch defines constant_fls() instead of removed generic_fls(). Signed-off-by: Akinobu Mita <mita@miraclelinux.com> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-arm/bitops.h')
-rw-r--r--include/asm-arm/bitops.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index d02de721ecc..eaecd553e85 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -344,13 +344,42 @@ static inline unsigned long __ffs(unsigned long word)
#else
+static inline int constant_fls(int x)
+{
+ int r = 32;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff0000u)) {
+ x <<= 16;
+ r -= 16;
+ }
+ if (!(x & 0xff000000u)) {
+ x <<= 8;
+ r -= 8;
+ }
+ if (!(x & 0xf0000000u)) {
+ x <<= 4;
+ r -= 4;
+ }
+ if (!(x & 0xc0000000u)) {
+ x <<= 2;
+ r -= 2;
+ }
+ if (!(x & 0x80000000u)) {
+ x <<= 1;
+ r -= 1;
+ }
+ return r;
+}
+
/*
* On ARMv5 and above those functions can be implemented around
* the clz instruction for much better code efficiency.
*/
#define fls(x) \
- ( __builtin_constant_p(x) ? generic_fls(x) : \
+ ( __builtin_constant_p(x) ? constant_fls(x) : \
({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
#define fls64(x) generic_fls64(x)
#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })