diff options
author | Alexander van Heukelum <heukelum@mailshack.com> | 2008-03-15 13:31:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-26 13:21:16 -0400 |
commit | 56a6b1eb7bfb5ace0b5cb9c149f502fbd101b8ab (patch) | |
tree | 46d3781050938b0649fc89cd8e7f612cacb66984 /include/asm-ia64 | |
parent | 7d9dff22e8ad06ad330968c9e3d3a2fb55a5f9c3 (diff) |
generic: implement __fls on all 64-bit archs
Implement __fls on all 64-bit archs:
alpha has an implementation of fls64.
Added __fls(x) = fls64(x) - 1.
ia64 has fls, but not __fls.
Added __fls based on code of fls.
mips and powerpc have __ilog2, which is the same as __fls.
Added __fls = __ilog2.
parisc, s390, sh and sparc64:
Include generic __fls.
x86_64 already has __fls.
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-ia64')
-rw-r--r-- | include/asm-ia64/bitops.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h index 953d3df9dd22..e2ca80037335 100644 --- a/include/asm-ia64/bitops.h +++ b/include/asm-ia64/bitops.h | |||
@@ -407,6 +407,22 @@ fls (int t) | |||
407 | return ia64_popcnt(x); | 407 | return ia64_popcnt(x); |
408 | } | 408 | } |
409 | 409 | ||
410 | /* | ||
411 | * Find the last (most significant) bit set. Undefined for x==0. | ||
412 | * Bits are numbered from 0..63 (e.g., __fls(9) == 3). | ||
413 | */ | ||
414 | static inline unsigned long | ||
415 | __fls (unsigned long x) | ||
416 | { | ||
417 | x |= x >> 1; | ||
418 | x |= x >> 2; | ||
419 | x |= x >> 4; | ||
420 | x |= x >> 8; | ||
421 | x |= x >> 16; | ||
422 | x |= x >> 32; | ||
423 | return ia64_popcnt(x) - 1; | ||
424 | } | ||
425 | |||
410 | #include <asm-generic/bitops/fls64.h> | 426 | #include <asm-generic/bitops/fls64.h> |
411 | 427 | ||
412 | /* | 428 | /* |