18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_GENERIC_BITOPS_SCHED_H_ 38c2ecf20Sopenharmony_ci#define _ASM_GENERIC_BITOPS_SCHED_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/compiler.h> /* unlikely() */ 68c2ecf20Sopenharmony_ci#include <asm/types.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 98c2ecf20Sopenharmony_ci * Every architecture must define this function. It's the fastest 108c2ecf20Sopenharmony_ci * way of searching a 100-bit bitmap. It's guaranteed that at least 118c2ecf20Sopenharmony_ci * one of the 100 bits is cleared. 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_cistatic inline int sched_find_first_bit(const unsigned long *b) 148c2ecf20Sopenharmony_ci{ 158c2ecf20Sopenharmony_ci#if BITS_PER_LONG == 64 168c2ecf20Sopenharmony_ci if (b[0]) 178c2ecf20Sopenharmony_ci return __ffs(b[0]); 188c2ecf20Sopenharmony_ci return __ffs(b[1]) + 64; 198c2ecf20Sopenharmony_ci#elif BITS_PER_LONG == 32 208c2ecf20Sopenharmony_ci if (b[0]) 218c2ecf20Sopenharmony_ci return __ffs(b[0]); 228c2ecf20Sopenharmony_ci if (b[1]) 238c2ecf20Sopenharmony_ci return __ffs(b[1]) + 32; 248c2ecf20Sopenharmony_ci if (b[2]) 258c2ecf20Sopenharmony_ci return __ffs(b[2]) + 64; 268c2ecf20Sopenharmony_ci return __ffs(b[3]) + 96; 278c2ecf20Sopenharmony_ci#else 288c2ecf20Sopenharmony_ci#error BITS_PER_LONG not defined 298c2ecf20Sopenharmony_ci#endif 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#endif /* _ASM_GENERIC_BITOPS_SCHED_H_ */ 33