1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_CRIS_ARCH_BITOPS_H
3 #define _ASM_CRIS_ARCH_BITOPS_H
6 * Helper functions for the core of the ff[sz] functions. They compute the
7 * number of leading zeroes of a bits-in-byte, byte-in-word and
8 * word-in-dword-swapped number. They differ in that the first function also
9 * inverts all bits in the input.
12 static inline unsigned long
13 cris_swapnwbrlz(unsigned long w)
17 __asm__ __volatile__ ("swapnwbr %0\n\t"
19 : "=r" (res) : "0" (w));
24 static inline unsigned long
25 cris_swapwbrlz(unsigned long w)
29 __asm__ __volatile__ ("swapwbr %0\n\t"
31 : "=r" (res) : "0" (w));
37 * Find First Zero in word. Undefined if no zero exist, so the caller should
38 * check against ~0 first.
40 static inline unsigned long
43 return cris_swapnwbrlz(w);
47 * Find First Set bit in word. Undefined if no 1 exist, so the caller
48 * should check against 0 first.
50 static inline unsigned long
51 __ffs(unsigned long w)
53 return cris_swapnwbrlz(~w);
57 * Find First Bit that is set.
59 static inline unsigned long
60 kernel_ffs(unsigned long w)
62 return w ? cris_swapwbrlz (w) + 1 : 0;
65 #endif /* _ASM_CRIS_ARCH_BITOPS_H */