2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

bitops: use a gcc builtin function instead of our __ffs

Our __ffs implementation is straightforward and non-optimal,
__builtin_ffsl should be faster.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Andrei Vagin 2018-06-17 06:32:53 +03:00
parent 625fbb3f97
commit b2ec837f72

View File

@ -57,17 +57,7 @@ static inline void clear_bit(int nr, volatile unsigned long *addr)
*/
static inline unsigned long __ffs(unsigned long word)
{
int p = 0;
for (; p < 8*sizeof(word); ++p) {
if (word & 1) {
break;
}
word >>= 1;
}
return p;
return __builtin_ffsl(word) - 1;
}
#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)