Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
0003 #define _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
0004 
0005 /**
0006  * fls - find last (most-significant) bit set
0007  * @x: the word to search
0008  *
0009  * This is defined the same way as ffs.
0010  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
0011  */
0012 static __always_inline int fls(unsigned int x)
0013 {
0014     return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
0015 }
0016 
0017 #endif