0001
0002 #ifndef _ASM_GENERIC_BITOPS_FLS_H_
0003 #define _ASM_GENERIC_BITOPS_FLS_H_
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 static __always_inline int fls(unsigned int x)
0014 {
0015 int r = 32;
0016
0017 if (!x)
0018 return 0;
0019 if (!(x & 0xffff0000u)) {
0020 x <<= 16;
0021 r -= 16;
0022 }
0023 if (!(x & 0xff000000u)) {
0024 x <<= 8;
0025 r -= 8;
0026 }
0027 if (!(x & 0xf0000000u)) {
0028 x <<= 4;
0029 r -= 4;
0030 }
0031 if (!(x & 0xc0000000u)) {
0032 x <<= 2;
0033 r -= 2;
0034 }
0035 if (!(x & 0x80000000u)) {
0036 x <<= 1;
0037 r -= 1;
0038 }
0039 return r;
0040 }
0041
0042 #endif