sched.h 721 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef _ASM_GENERIC_BITOPS_SCHED_H_
  2. #define _ASM_GENERIC_BITOPS_SCHED_H_
  3. #include <linux/compiler.h> /* unlikely() */
  4. #include <asm/types.h>
  5. /*
  6. * Every architecture must define this function. It's the fastest
  7. * way of searching a 100-bit bitmap. It's guaranteed that at least
  8. * one of the 100 bits is cleared.
  9. */
  10. static inline int sched_find_first_bit(const unsigned long *b)
  11. {
  12. #if BITS_PER_LONG == 64
  13. if (b[0])
  14. return __ffs(b[0]);
  15. return __ffs(b[1]) + 64;
  16. #elif BITS_PER_LONG == 32
  17. if (b[0])
  18. return __ffs(b[0]);
  19. if (b[1])
  20. return __ffs(b[1]) + 32;
  21. if (b[2])
  22. return __ffs(b[2]) + 64;
  23. return __ffs(b[3]) + 96;
  24. #else
  25. #error BITS_PER_LONG not defined
  26. #endif
  27. }
  28. #endif /* _ASM_GENERIC_BITOPS_SCHED_H_ */