2 * linux/arch/unicore32/include/asm/bitops.h
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Copyright (C) 2001-2010 GUAN Xue-tao
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #ifndef __UNICORE_BITOPS_H__
14 #define __UNICORE_BITOPS_H__
16 #define find_next_bit __uc32_find_next_bit
17 #define find_next_zero_bit __uc32_find_next_zero_bit
19 #define find_first_bit __uc32_find_first_bit
20 #define find_first_zero_bit __uc32_find_first_zero_bit
22 #define _ASM_GENERIC_BITOPS_FLS_H_
23 #define _ASM_GENERIC_BITOPS___FLS_H_
24 #define _ASM_GENERIC_BITOPS_FFS_H_
25 #define _ASM_GENERIC_BITOPS___FFS_H_
27 * On UNICORE, those functions can be implemented around
28 * the cntlz instruction for much better code efficiency.
31 static inline int fls(int x
)
35 asm("cntlz\t%0, %1" : "=r" (ret
) : "r" (x
) : "cc");
41 #define __fls(x) (fls(x) - 1)
42 #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
43 #define __ffs(x) (ffs(x) - 1)
45 #include <asm-generic/bitops.h>
47 #endif /* __UNICORE_BITOPS_H__ */