1 #ifndef __ASM_SH_BITOPS_H
2 #define __ASM_SH_BITOPS_H
6 #ifndef _LINUX_BITOPS_H
7 #error only <linux/bitops.h> can be included directly
10 #include <asm/system.h>
12 #include <asm/byteorder.h>
14 static inline void set_bit(int nr, volatile void * addr)
17 volatile unsigned int *a = addr;
21 mask = 1 << (nr & 0x1f);
22 local_irq_save(flags);
24 local_irq_restore(flags);
28 * clear_bit() doesn't provide any barrier for the compiler.
30 #define smp_mb__before_clear_bit() barrier()
31 #define smp_mb__after_clear_bit() barrier()
32 static inline void clear_bit(int nr, volatile void * addr)
35 volatile unsigned int *a = addr;
39 mask = 1 << (nr & 0x1f);
40 local_irq_save(flags);
42 local_irq_restore(flags);
45 static inline void change_bit(int nr, volatile void * addr)
48 volatile unsigned int *a = addr;
52 mask = 1 << (nr & 0x1f);
53 local_irq_save(flags);
55 local_irq_restore(flags);
58 static inline int test_and_set_bit(int nr, volatile void * addr)
61 volatile unsigned int *a = addr;
65 mask = 1 << (nr & 0x1f);
66 local_irq_save(flags);
67 retval = (mask & *a) != 0;
69 local_irq_restore(flags);
74 static inline int test_and_clear_bit(int nr, volatile void * addr)
77 volatile unsigned int *a = addr;
81 mask = 1 << (nr & 0x1f);
82 local_irq_save(flags);
83 retval = (mask & *a) != 0;
85 local_irq_restore(flags);
90 static inline int test_and_change_bit(int nr, volatile void * addr)
93 volatile unsigned int *a = addr;
97 mask = 1 << (nr & 0x1f);
98 local_irq_save(flags);
99 retval = (mask & *a) != 0;
101 local_irq_restore(flags);
106 #include <asm-generic/bitops/non-atomic.h>
108 #ifdef CONFIG_SUPERH32
109 static inline unsigned long ffz(unsigned long word)
111 unsigned long result;
117 : "=r" (result), "=r" (word)
118 : "0" (~0L), "1" (word)
124 * __ffs - find first bit in word.
125 * @word: The word to search
127 * Undefined if no bit exists, so code should check against 0 first.
129 static inline unsigned long __ffs(unsigned long word)
131 unsigned long result;
137 : "=r" (result), "=r" (word)
138 : "0" (~0L), "1" (word)
143 static inline unsigned long ffz(unsigned long word)
145 unsigned long result, __d2, __d3;
147 __asm__("gettr tr0, %2\n\t"
150 "beq %3, r63, tr0\n\t"
153 "shlri.l %1, 1, %1\n\t"
159 : "=r" (result), "=r" (word), "=r" (__d2), "=r" (__d3)
160 : "0" (0L), "1" (word));
165 #include <asm-generic/bitops/__ffs.h>
168 #include <asm-generic/bitops/find.h>
169 #include <asm-generic/bitops/ffs.h>
170 #include <asm-generic/bitops/hweight.h>
171 #include <asm-generic/bitops/lock.h>
172 #include <asm-generic/bitops/sched.h>
173 #include <asm-generic/bitops/ext2-non-atomic.h>
174 #include <asm-generic/bitops/ext2-atomic.h>
175 #include <asm-generic/bitops/minix.h>
176 #include <asm-generic/bitops/fls.h>
177 #include <asm-generic/bitops/fls64.h>
179 #endif /* __KERNEL__ */
181 #endif /* __ASM_SH_BITOPS_H */