diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2009-04-23 03:48:15 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2009-04-23 05:06:35 -0400 |
| commit | 952043ac12a117d8e94bddd9088338d7ad20ca7d (patch) | |
| tree | 3ad716873d90392fbf1888084af9be7e5e242e1f /include/linux | |
| parent | 091069740304c979f957ceacec39c461d0192158 (diff) | |
bitops: Add __ffs64 bitop
Finds the first set bit in a 64 bit word. This is required in order
to fix a bug in GFS2, but I think it should be a generic function
in case of future users.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Reviewed-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'include/linux')
| -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) | |||
| 112 | return fls64(l); | 112 | return fls64(l); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | /** | ||
| 116 | * __ffs64 - find first set bit in a 64 bit word | ||
| 117 | * @word: The 64 bit word | ||
| 118 | * | ||
| 119 | * On 64 bit arches this is a synomyn for __ffs | ||
| 120 | * The result is not defined if no bits are set, so check that @word | ||
| 121 | * is non-zero before calling this. | ||
| 122 | */ | ||
| 123 | static inline unsigned long __ffs64(u64 word) | ||
| 124 | { | ||
| 125 | #if BITS_PER_LONG == 32 | ||
| 126 | if (((u32)word) == 0UL) | ||
| 127 | return __ffs((u32)(word >> 32)) + 32; | ||
| 128 | #elif BITS_PER_LONG != 64 | ||
| 129 | #error BITS_PER_LONG not 32 or 64 | ||
| 130 | #endif | ||
| 131 | return __ffs((unsigned long)word); | ||
| 132 | } | ||
| 133 | |||
| 115 | #ifdef __KERNEL__ | 134 | #ifdef __KERNEL__ |
| 116 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT | 135 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT |
| 117 | 136 | ||
