diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-01-06 04:25:13 +0100 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-01-06 04:25:13 +0100 |
commit | fed8bf19ec20efc0641740b2d10aa589dbd6d1ab (patch) | |
tree | c104a13c7b8cb7f4152b15729dc5aede7c063e91 /include/asm-x86_64/bitops.h | |
parent | Input: wistron - convert to the new platform device interface (diff) | |
parent | [NET]: Change 1500 to ETH_DATA_LEN in some files (diff) | |
download | linux-fed8bf19ec20efc0641740b2d10aa589dbd6d1ab.tar.xz linux-fed8bf19ec20efc0641740b2d10aa589dbd6d1ab.zip |
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/asm-x86_64/bitops.h')
-rw-r--r-- | include/asm-x86_64/bitops.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index 05a0d374404b..a4d5d0909453 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h @@ -340,6 +340,20 @@ static __inline__ unsigned long __ffs(unsigned long word) return word; } +/* + * __fls: find last bit set. + * @word: The word to search + * + * Undefined if no zero exists, so code should check against ~0UL first. + */ +static __inline__ unsigned long __fls(unsigned long word) +{ + __asm__("bsrq %1,%0" + :"=r" (word) + :"rm" (word)); + return word; +} + #ifdef __KERNEL__ static inline int sched_find_first_bit(const unsigned long *b) @@ -370,6 +384,19 @@ static __inline__ int ffs(int x) } /** + * fls64 - find last bit set in 64 bit word + * @x: the word to search + * + * This is defined the same way as fls. + */ +static __inline__ int fls64(__u64 x) +{ + if (x == 0) + return 0; + return __fls(x) + 1; +} + +/** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh * |