diff options
author | David S. Miller <davem@davemloft.net> | 2009-05-17 11:55:57 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-17 11:55:57 -0700 |
commit | 74392592bbf7e93ef383588e21aea0c1450d6f12 (patch) | |
tree | 086981f9ef51d57a34fbc5fde8095652877cf739 /include/linux/bitops.h | |
parent | Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6 (diff) | |
parent | Fix caller information for warn_slowpath_null (diff) | |
download | linux-dev-74392592bbf7e93ef383588e21aea0c1450d6f12.tar.xz linux-dev-74392592bbf7e93ef383588e21aea0c1450d6f12.zip |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 61829139795a..c05a29cb9bb2 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -112,6 +112,25 @@ static inline unsigned fls_long(unsigned long l) return fls64(l); } +/** + * __ffs64 - find first set bit in a 64 bit word + * @word: The 64 bit word + * + * On 64 bit arches this is a synomyn for __ffs + * The result is not defined if no bits are set, so check that @word + * is non-zero before calling this. + */ +static inline unsigned long __ffs64(u64 word) +{ +#if BITS_PER_LONG == 32 + if (((u32)word) == 0UL) + return __ffs((u32)(word >> 32)) + 32; +#elif BITS_PER_LONG != 64 +#error BITS_PER_LONG not 32 or 64 +#endif + return __ffs((unsigned long)word); +} + #ifdef __KERNEL__ #ifdef CONFIG_GENERIC_FIND_FIRST_BIT |