2006-03-26 13:39:12 +04:00
|
|
|
#ifndef _ASM_GENERIC_BITOPS_SCHED_H_
|
|
|
|
#define _ASM_GENERIC_BITOPS_SCHED_H_
|
|
|
|
|
|
|
|
#include <linux/compiler.h> /* unlikely() */
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Every architecture must define this function. It's the fastest
|
2007-07-09 20:52:00 +04:00
|
|
|
* way of searching a 100-bit bitmap. It's guaranteed that at least
|
|
|
|
* one of the 100 bits is cleared.
|
2006-03-26 13:39:12 +04:00
|
|
|
*/
|
|
|
|
static inline int sched_find_first_bit(const unsigned long *b)
|
|
|
|
{
|
|
|
|
#if BITS_PER_LONG == 64
|
2007-07-09 20:52:00 +04:00
|
|
|
if (b[0])
|
2006-03-26 13:39:12 +04:00
|
|
|
return __ffs(b[0]);
|
2007-07-09 20:52:00 +04:00
|
|
|
return __ffs(b[1]) + 64;
|
2006-03-26 13:39:12 +04:00
|
|
|
#elif BITS_PER_LONG == 32
|
2007-07-09 20:52:00 +04:00
|
|
|
if (b[0])
|
2006-03-26 13:39:12 +04:00
|
|
|
return __ffs(b[0]);
|
2007-07-09 20:52:00 +04:00
|
|
|
if (b[1])
|
2006-03-26 13:39:12 +04:00
|
|
|
return __ffs(b[1]) + 32;
|
2007-07-09 20:52:00 +04:00
|
|
|
if (b[2])
|
2006-03-26 13:39:12 +04:00
|
|
|
return __ffs(b[2]) + 64;
|
2007-07-09 20:52:00 +04:00
|
|
|
return __ffs(b[3]) + 96;
|
2006-03-26 13:39:12 +04:00
|
|
|
#else
|
|
|
|
#error BITS_PER_LONG not defined
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _ASM_GENERIC_BITOPS_SCHED_H_ */
|