perf stat: Fix duplicate PMU name for interval print
[linux/fpc-iii.git] / tools / include / asm-generic / bitops / __ffs.h
blob9d131051949709e65ae87f1ac156ce52d58ccbbd
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS___FFS_H_
3 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS___FFS_H_
5 #include <asm/types.h>
6 #include <asm/bitsperlong.h>
8 /**
9 * __ffs - find first bit in word.
10 * @word: The word to search
12 * Undefined if no bit exists, so code should check against 0 first.
14 static __always_inline unsigned long __ffs(unsigned long word)
16 int num = 0;
18 #if __BITS_PER_LONG == 64
19 if ((word & 0xffffffff) == 0) {
20 num += 32;
21 word >>= 32;
23 #endif
24 if ((word & 0xffff) == 0) {
25 num += 16;
26 word >>= 16;
28 if ((word & 0xff) == 0) {
29 num += 8;
30 word >>= 8;
32 if ((word & 0xf) == 0) {
33 num += 4;
34 word >>= 4;
36 if ((word & 0x3) == 0) {
37 num += 2;
38 word >>= 2;
40 if ((word & 0x1) == 0)
41 num += 1;
42 return num;
45 #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS___FFS_H_ */