]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/unicore32/include/asm/bitops.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
[mirror_ubuntu-jammy-kernel.git] / arch / unicore32 / include / asm / bitops.h
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
96cf5185
G
2/*
3 * linux/arch/unicore32/include/asm/bitops.h
4 *
5 * Code specific to PKUnity SoC and UniCore ISA
6 *
7 * Copyright (C) 2001-2010 GUAN Xue-tao
96cf5185
G
8 */
9
10#ifndef __UNICORE_BITOPS_H__
11#define __UNICORE_BITOPS_H__
12
96cf5185
G
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_
17/*
18 * On UNICORE, those functions can be implemented around
19 * the cntlz instruction for much better code efficiency.
20 */
21
3fc2579e 22static inline int fls(unsigned int x)
96cf5185
G
23{
24 int ret;
25
26 asm("cntlz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
27 ret = 32 - ret;
28
29 return ret;
30}
31
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)
35
36#include <asm-generic/bitops.h>
37
e13b91c1
GX
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
43
0ade34c3
CC
44#include <asm-generic/bitops/find.h>
45
96cf5185 46#endif /* __UNICORE_BITOPS_H__ */