1 #ifndef __ASM_SH_BITOPS_H
2 #define __ASM_SH_BITOPS_H
5 #include <asm/system.h>
7 #include <asm/byteorder.h>
9 static inline void set_bit(int nr
, volatile void * addr
)
12 volatile unsigned int *a
= addr
;
16 mask
= 1 << (nr
& 0x1f);
17 local_irq_save(flags
);
19 local_irq_restore(flags
);
23 * clear_bit() doesn't provide any barrier for the compiler.
25 #define smp_mb__before_clear_bit() barrier()
26 #define smp_mb__after_clear_bit() barrier()
27 static inline void clear_bit(int nr
, volatile void * addr
)
30 volatile unsigned int *a
= addr
;
34 mask
= 1 << (nr
& 0x1f);
35 local_irq_save(flags
);
37 local_irq_restore(flags
);
40 static inline void change_bit(int nr
, volatile void * addr
)
43 volatile unsigned int *a
= addr
;
47 mask
= 1 << (nr
& 0x1f);
48 local_irq_save(flags
);
50 local_irq_restore(flags
);
53 static inline int test_and_set_bit(int nr
, volatile void * addr
)
56 volatile unsigned int *a
= addr
;
60 mask
= 1 << (nr
& 0x1f);
61 local_irq_save(flags
);
62 retval
= (mask
& *a
) != 0;
64 local_irq_restore(flags
);
69 static inline int test_and_clear_bit(int nr
, volatile void * addr
)
72 volatile unsigned int *a
= addr
;
76 mask
= 1 << (nr
& 0x1f);
77 local_irq_save(flags
);
78 retval
= (mask
& *a
) != 0;
80 local_irq_restore(flags
);
85 static inline int test_and_change_bit(int nr
, volatile void * addr
)
88 volatile unsigned int *a
= addr
;
92 mask
= 1 << (nr
& 0x1f);
93 local_irq_save(flags
);
94 retval
= (mask
& *a
) != 0;
96 local_irq_restore(flags
);
101 #include <asm-generic/bitops/non-atomic.h>
103 static inline unsigned long ffz(unsigned long word
)
105 unsigned long result
;
111 : "=r" (result
), "=r" (word
)
112 : "0" (~0L), "1" (word
)
118 * __ffs - find first bit in word.
119 * @word: The word to search
121 * Undefined if no bit exists, so code should check against 0 first.
123 static inline unsigned long __ffs(unsigned long word
)
125 unsigned long result
;
131 : "=r" (result
), "=r" (word
)
132 : "0" (~0L), "1" (word
)
137 #include <asm-generic/bitops/find.h>
138 #include <asm-generic/bitops/ffs.h>
139 #include <asm-generic/bitops/hweight.h>
140 #include <asm-generic/bitops/sched.h>
141 #include <asm-generic/bitops/ext2-non-atomic.h>
142 #include <asm-generic/bitops/ext2-atomic.h>
143 #include <asm-generic/bitops/minix.h>
144 #include <asm-generic/bitops/fls.h>
145 #include <asm-generic/bitops/fls64.h>
147 #endif /* __KERNEL__ */
149 #endif /* __ASM_SH_BITOPS_H */