2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #ifndef _ASM_C6X_BITOPS_H
12 #define _ASM_C6X_BITOPS_H
16 #include <linux/bitops.h>
18 #include <asm/system.h>
19 #include <asm/byteorder.h>
22 * clear_bit() doesn't provide any barrier for the compiler.
24 #define smp_mb__before_clear_bit() barrier()
25 #define smp_mb__after_clear_bit() barrier()
28 * We are lucky, DSP is perfect for bitops: do it in 3 cycles
32 * __ffs - find first bit in word.
33 * @word: The word to search
35 * Undefined if no bit exists, so code should check against 0 first.
36 * Note __ffs(0) = undef, __ffs(1) = 0, __ffs(0x80000000) = 31.
39 static inline unsigned long __ffs(unsigned long x
)
41 asm (" bitr .M1 %0,%0\n"
50 * ffz - find first zero in word.
51 * @word: The word to search
53 * Undefined if no zero exists, so code should check against ~0UL first.
55 #define ffz(x) __ffs(~(x))
58 * fls - find last (most-significant) bit set
59 * @x: the word to search
61 * This is defined the same way as ffs.
62 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
64 static inline int fls(int x
)
69 asm (" lmbd .L1 1,%0,%0\n" : "+a"(x
));
75 * ffs - find first bit set
76 * @x: the word to search
78 * This is defined the same way as
79 * the libc and compiler builtin ffs routines, therefore
80 * differs in spirit from the above ffz (man ffs).
81 * Note ffs(0) = 0, ffs(1) = 1, ffs(0x80000000) = 32.
83 static inline int ffs(int x
)
91 #include <asm-generic/bitops/__fls.h>
92 #include <asm-generic/bitops/fls64.h>
93 #include <asm-generic/bitops/find.h>
95 #include <asm-generic/bitops/sched.h>
96 #include <asm-generic/bitops/hweight.h>
97 #include <asm-generic/bitops/lock.h>
99 #include <asm-generic/bitops/atomic.h>
100 #include <asm-generic/bitops/non-atomic.h>
101 #include <asm-generic/bitops/le.h>
102 #include <asm-generic/bitops/ext2-atomic.h>
104 #endif /* __KERNEL__ */
105 #endif /* _ASM_C6X_BITOPS_H */