0001
0002 #ifndef _ASM_GENERIC_BITOPS___FLS_H_
0003 #define _ASM_GENERIC_BITOPS___FLS_H_
0004
0005 #include <asm/types.h>
0006
0007
0008
0009
0010
0011
0012
0013 static __always_inline unsigned long __fls(unsigned long word)
0014 {
0015 int num = BITS_PER_LONG - 1;
0016
0017 #if BITS_PER_LONG == 64
0018 if (!(word & (~0ul << 32))) {
0019 num -= 32;
0020 word <<= 32;
0021 }
0022 #endif
0023 if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
0024 num -= 16;
0025 word <<= 16;
0026 }
0027 if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
0028 num -= 8;
0029 word <<= 8;
0030 }
0031 if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
0032 num -= 4;
0033 word <<= 4;
0034 }
0035 if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
0036 num -= 2;
0037 word <<= 2;
0038 }
0039 if (!(word & (~0ul << (BITS_PER_LONG-1))))
0040 num -= 1;
0041 return num;
0042 }
0043
0044 #endif