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