diff options
Diffstat (limited to 'arch/arm/include/asm/bitops.h')
-rw-r--r-- | arch/arm/include/asm/bitops.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h index 9a1db20e032a..63a481fbbed4 100644 --- a/arch/arm/include/asm/bitops.h +++ b/arch/arm/include/asm/bitops.h | |||
@@ -237,6 +237,7 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset); | |||
237 | #if __LINUX_ARM_ARCH__ < 5 | 237 | #if __LINUX_ARM_ARCH__ < 5 |
238 | 238 | ||
239 | #include <asm-generic/bitops/ffz.h> | 239 | #include <asm-generic/bitops/ffz.h> |
240 | #include <asm-generic/bitops/__fls.h> | ||
240 | #include <asm-generic/bitops/__ffs.h> | 241 | #include <asm-generic/bitops/__ffs.h> |
241 | #include <asm-generic/bitops/fls.h> | 242 | #include <asm-generic/bitops/fls.h> |
242 | #include <asm-generic/bitops/ffs.h> | 243 | #include <asm-generic/bitops/ffs.h> |
@@ -277,16 +278,19 @@ static inline int constant_fls(int x) | |||
277 | * the clz instruction for much better code efficiency. | 278 | * the clz instruction for much better code efficiency. |
278 | */ | 279 | */ |
279 | 280 | ||
280 | #define __fls(x) \ | ||
281 | ( __builtin_constant_p(x) ? constant_fls(x) : \ | ||
282 | ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) | ||
283 | |||
284 | /* Implement fls() in C so that 64-bit args are suitably truncated */ | ||
285 | static inline int fls(int x) | 281 | static inline int fls(int x) |
286 | { | 282 | { |
287 | return __fls(x); | 283 | int ret; |
284 | |||
285 | if (__builtin_constant_p(x)) | ||
286 | return constant_fls(x); | ||
287 | |||
288 | asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc"); | ||
289 | ret = 32 - ret; | ||
290 | return ret; | ||
288 | } | 291 | } |
289 | 292 | ||
293 | #define __fls(x) (fls(x) - 1) | ||
290 | #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) | 294 | #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) |
291 | #define __ffs(x) (ffs(x) - 1) | 295 | #define __ffs(x) (ffs(x) - 1) |
292 | #define ffz(x) __ffs( ~(x) ) | 296 | #define ffz(x) __ffs( ~(x) ) |