aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asm-generic/bitops/sched.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/include/asm-generic/bitops/sched.h b/include/asm-generic/bitops/sched.h
index 815bb0148060..604fab7031a6 100644
--- a/include/asm-generic/bitops/sched.h
+++ b/include/asm-generic/bitops/sched.h
@@ -6,28 +6,23 @@
6 6
7/* 7/*
8 * Every architecture must define this function. It's the fastest 8 * Every architecture must define this function. It's the fastest
9 * way of searching a 140-bit bitmap where the first 100 bits are 9 * way of searching a 100-bit bitmap. It's guaranteed that at least
10 * unlikely to be set. It's guaranteed that at least one of the 140 10 * one of the 100 bits is cleared.
11 * bits is cleared.
12 */ 11 */
13static inline int sched_find_first_bit(const unsigned long *b) 12static inline int sched_find_first_bit(const unsigned long *b)
14{ 13{
15#if BITS_PER_LONG == 64 14#if BITS_PER_LONG == 64
16 if (unlikely(b[0])) 15 if (b[0])
17 return __ffs(b[0]); 16 return __ffs(b[0]);
18 if (likely(b[1])) 17 return __ffs(b[1]) + 64;
19 return __ffs(b[1]) + 64;
20 return __ffs(b[2]) + 128;
21#elif BITS_PER_LONG == 32 18#elif BITS_PER_LONG == 32
22 if (unlikely(b[0])) 19 if (b[0])
23 return __ffs(b[0]); 20 return __ffs(b[0]);
24 if (unlikely(b[1])) 21 if (b[1])
25 return __ffs(b[1]) + 32; 22 return __ffs(b[1]) + 32;
26 if (unlikely(b[2])) 23 if (b[2])
27 return __ffs(b[2]) + 64; 24 return __ffs(b[2]) + 64;
28 if (b[3]) 25 return __ffs(b[3]) + 96;
29 return __ffs(b[3]) + 96;
30 return __ffs(b[4]) + 128;
31#else 26#else
32#error BITS_PER_LONG not defined 27#error BITS_PER_LONG not defined
33#endif 28#endif