Path: blob/master/tools/include/asm-generic/bitops/fls64.h
26295 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_GENERIC_BITOPS_FLS64_H_2#define _ASM_GENERIC_BITOPS_FLS64_H_34#include <asm/types.h>56/**7* fls64 - find last set bit in a 64-bit word8* @x: the word to search9*10* This is defined in a similar way as the libc and compiler builtin11* ffsll, but returns the position of the most significant set bit.12*13* fls64(value) returns 0 if value is 0 or the position of the last14* set bit if value is nonzero. The last (most significant) bit is15* at position 64.16*/17#if BITS_PER_LONG == 3218static __always_inline int fls64(__u64 x)19{20__u32 h = x >> 32;21if (h)22return fls(h) + 32;23return fls(x);24}25#elif BITS_PER_LONG == 6426static __always_inline int fls64(__u64 x)27{28if (x == 0)29return 0;30return __fls(x) + 1;31}32#else33#error BITS_PER_LONG not 32 or 6434#endif3536#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */373839