Commit 44364724 authored by Russell King's avatar Russell King

[ARM] asm-arm/bitops.h - add fls() and stream-line sched_find_first_bit()

parent 75fb1f97
......@@ -318,6 +318,12 @@ static inline unsigned long __ffs(unsigned long word)
return k;
}
/*
* fls: find last bit set.
*/
#define fls(x) generic_fls(x)
/*
* ffs: find first bit set. This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
......@@ -332,15 +338,14 @@ static inline unsigned long __ffs(unsigned long word)
*/
static inline int sched_find_first_bit(unsigned long *b)
{
if (unlikely(b[0]))
return __ffs(b[0]);
if (unlikely(b[1]))
return __ffs(b[1]) + 32;
if (unlikely(b[2]))
return __ffs(b[2]) + 64;
if (b[3])
return __ffs(b[3]) + 96;
return __ffs(b[4]) + 128;
unsigned long v;
unsigned int off;
for (off = 0; v = b[off], off < 4; off++) {
if (unlikely(v))
break;
}
return __ffs(v) + off * 32;
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment