1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Port on Texas Instruments TMS320C6x architecture
5 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
6 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
8 #ifndef _ASM_C6X_BITOPS_H
9 #define _ASM_C6X_BITOPS_H
13 #include <linux/bitops.h>
14 #include <asm/byteorder.h>
15 #include <asm/barrier.h>
18 * We are lucky, DSP is perfect for bitops: do it in 3 cycles
22 * __ffs - find first bit in word.
23 * @word: The word to search
25 * Undefined if no bit exists, so code should check against 0 first.
26 * Note __ffs(0) = undef, __ffs(1) = 0, __ffs(0x80000000) = 31.
29 static inline unsigned long __ffs(unsigned long x
)
31 asm (" bitr .M1 %0,%0\n"
40 * ffz - find first zero in word.
41 * @word: The word to search
43 * Undefined if no zero exists, so code should check against ~0UL first.
45 #define ffz(x) __ffs(~(x))
48 * fls - find last (most-significant) bit set
49 * @x: the word to search
51 * This is defined the same way as ffs.
52 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
54 static inline int fls(unsigned int x
)
59 asm (" lmbd .L1 1,%0,%0\n" : "+a"(x
));
65 * ffs - find first bit set
66 * @x: the word to search
68 * This is defined the same way as
69 * the libc and compiler builtin ffs routines, therefore
70 * differs in spirit from the above ffz (man ffs).
71 * Note ffs(0) = 0, ffs(1) = 1, ffs(0x80000000) = 32.
73 static inline int ffs(int x
)
81 #include <asm-generic/bitops/__fls.h>
82 #include <asm-generic/bitops/fls64.h>
83 #include <asm-generic/bitops/find.h>
85 #include <asm-generic/bitops/sched.h>
86 #include <asm-generic/bitops/hweight.h>
87 #include <asm-generic/bitops/lock.h>
89 #include <asm-generic/bitops/atomic.h>
90 #include <asm-generic/bitops/non-atomic.h>
91 #include <asm-generic/bitops/le.h>
92 #include <asm-generic/bitops/ext2-atomic.h>
94 #endif /* __KERNEL__ */
95 #endif /* _ASM_C6X_BITOPS_H */