Path: blob/master/include/asm-generic/bitops/fls64.h
10818 views
#ifndef _ASM_GENERIC_BITOPS_FLS64_H_1#define _ASM_GENERIC_BITOPS_FLS64_H_23#include <asm/types.h>45/**6* fls64 - find last set bit in a 64-bit word7* @x: the word to search8*9* This is defined in a similar way as the libc and compiler builtin10* ffsll, but returns the position of the most significant set bit.11*12* fls64(value) returns 0 if value is 0 or the position of the last13* set bit if value is nonzero. The last (most significant) bit is14* at position 64.15*/16#if BITS_PER_LONG == 3217static __always_inline int fls64(__u64 x)18{19__u32 h = x >> 32;20if (h)21return fls(h) + 32;22return fls(x);23}24#elif BITS_PER_LONG == 6425static __always_inline int fls64(__u64 x)26{27if (x == 0)28return 0;29return __fls(x) + 1;30}31#else32#error BITS_PER_LONG not 32 or 6433#endif3435#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */363738