mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +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:
@@ -57,17 +57,7 @@ static inline void clear_bit(int nr, volatile unsigned long *addr)
|
|||||||
*/
|
*/
|
||||||
static inline unsigned long __ffs(unsigned long word)
|
static inline unsigned long __ffs(unsigned long word)
|
||||||
{
|
{
|
||||||
int p = 0;
|
return __builtin_ffsl(word) - 1;
|
||||||
|
|
||||||
for (; p < 8*sizeof(word); ++p) {
|
|
||||||
if (word & 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
word >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
|
#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||||
|
Reference in New Issue
Block a user