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) ...@@ -318,6 +318,12 @@ static inline unsigned long __ffs(unsigned long word)
return k; 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 * ffs: find first bit set. This is defined the same way as
* the libc and compiler builtin ffs routines, therefore * the libc and compiler builtin ffs routines, therefore
...@@ -332,15 +338,14 @@ static inline unsigned long __ffs(unsigned long word) ...@@ -332,15 +338,14 @@ static inline unsigned long __ffs(unsigned long word)
*/ */
static inline int sched_find_first_bit(unsigned long *b) static inline int sched_find_first_bit(unsigned long *b)
{ {
if (unlikely(b[0])) unsigned long v;
return __ffs(b[0]); unsigned int off;
if (unlikely(b[1]))
return __ffs(b[1]) + 32; for (off = 0; v = b[off], off < 4; off++) {
if (unlikely(b[2])) if (unlikely(v))
return __ffs(b[2]) + 64; break;
if (b[3]) }
return __ffs(b[3]) + 96; return __ffs(v) + off * 32;
return __ffs(b[4]) + 128;
} }
/* /*
......
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