From 8823036a8b3c2a8e6662855902f23bea1f0fb2e6 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 25 Sep 2006 23:32:09 -0700 Subject: [PATCH] --- yaml --- r: 35648 b: refs/heads/master c: cf134483b2cd657039b305777215c531a1009947 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/asm-frv/bitops.h | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 6e27bd7e66b6..360d9bcf52fb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a8ad27d03f17e6154c61e81d4a7028c56ca6390d +refs/heads/master: cf134483b2cd657039b305777215c531a1009947 diff --git a/trunk/include/asm-frv/bitops.h b/trunk/include/asm-frv/bitops.h index 591eecc1f8cd..1f70d47148bd 100644 --- a/trunk/include/asm-frv/bitops.h +++ b/trunk/include/asm-frv/bitops.h @@ -157,8 +157,6 @@ static inline int __test_bit(int nr, const volatile void * addr) __constant_test_bit((nr),(addr)) : \ __test_bit((nr),(addr))) -#include -#include #include /** @@ -227,6 +225,37 @@ int fls64(u64 n) } +/** + * ffs - find first bit set + * @x: the word to search + * + * - return 32..1 to indicate bit 31..0 most least significant bit set + * - return 0 to indicate no bits set + */ +static inline __attribute__((const)) +int ffs(int x) +{ + /* Note: (x & -x) gives us a mask that is the least significant + * (rightmost) 1-bit of the value in x. + */ + return fls(x & -x); +} + +/** + * __ffs - find first bit set + * @x: the word to search + * + * - return 31..0 to indicate bit 31..0 most least significant bit set + * - if no bits are set in x, the result is undefined + */ +static inline __attribute__((const)) +int __ffs(unsigned long x) +{ + int bit; + asm("scan %1,gr0,%0" : "=r"(bit) : "r"(x & -x)); + return 31 - bit; +} + #include #include