Path: blob/master/include/asm-generic/bitops/ffs.h
10818 views
#ifndef _ASM_GENERIC_BITOPS_FFS_H_1#define _ASM_GENERIC_BITOPS_FFS_H_23/**4* ffs - find first bit set5* @x: the word to search6*7* This is defined the same way as8* the libc and compiler builtin ffs routines, therefore9* differs in spirit from the above ffz (man ffs).10*/11static inline int ffs(int x)12{13int r = 1;1415if (!x)16return 0;17if (!(x & 0xffff)) {18x >>= 16;19r += 16;20}21if (!(x & 0xff)) {22x >>= 8;23r += 8;24}25if (!(x & 0xf)) {26x >>= 4;27r += 4;28}29if (!(x & 3)) {30x >>= 2;31r += 2;32}33if (!(x & 1)) {34x >>= 1;35r += 1;36}37return r;38}3940#endif /* _ASM_GENERIC_BITOPS_FFS_H_ */414243