1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/include/asm/bitops.h
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
10 #ifndef __UNICORE_BITOPS_H__
11 #define __UNICORE_BITOPS_H__
13 #define _ASM_GENERIC_BITOPS_FLS_H_
14 #define _ASM_GENERIC_BITOPS___FLS_H_
15 #define _ASM_GENERIC_BITOPS_FFS_H_
16 #define _ASM_GENERIC_BITOPS___FFS_H_
18 * On UNICORE, those functions can be implemented around
19 * the cntlz instruction for much better code efficiency.
22 static inline int fls(unsigned int x
)
26 asm("cntlz\t%0, %1" : "=r" (ret
) : "r" (x
) : "cc");
32 #define __fls(x) (fls(x) - 1)
33 #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
34 #define __ffs(x) (ffs(x) - 1)
36 #include <asm-generic/bitops.h>
38 /* following definitions: to avoid using codes in lib/find_*.c */
39 #define find_next_bit find_next_bit
40 #define find_next_zero_bit find_next_zero_bit
41 #define find_first_bit find_first_bit
42 #define find_first_zero_bit find_first_zero_bit
44 #include <asm-generic/bitops/find.h>
46 #endif /* __UNICORE_BITOPS_H__ */