1 #ifndef _FFS_H_ 2 #define _FFS_H_ 3 4 /* 5 * A really hacky implementation copied from asm/bitops.h 6 * to make it compile 7 */ ffs(int x)8inline int ffs(int x) 9 { 10 int r = 1; 11 12 if (!x) 13 return 0; 14 if (!(x & 0xffff)) { 15 x >>= 16; 16 r += 16; 17 } 18 if (!(x & 0xff)) { 19 x >>= 8; 20 r += 8; 21 } 22 if (!(x & 0xf)) { 23 x >>= 4; 24 r += 4; 25 } 26 if (!(x & 3)) { 27 x >>= 2; 28 r += 2; 29 } 30 if (!(x & 1)) { 31 x >>= 1; 32 r += 1; 33 } 34 return r; 35 } 36 37 #endif 38