1 #ifndef __ASM_SH_BITOPS_H
2 #define __ASM_SH_BITOPS_H
5 //#include <asm/system.h>
6 #include <asm/irqflags.h>
8 #include <asm/byteorder.h>
10 static inline void set_bit(int nr, volatile void * addr)
13 volatile unsigned int *a = addr;
17 mask = 1 << (nr & 0x1f);
18 local_irq_save(flags);
20 local_irq_restore(flags);
24 * clear_bit() doesn't provide any barrier for the compiler.
26 #define smp_mb__before_clear_bit() barrier()
27 #define smp_mb__after_clear_bit() barrier()
28 static inline void clear_bit(int nr, volatile void * addr)
31 volatile unsigned int *a = addr;
35 mask = 1 << (nr & 0x1f);
36 local_irq_save(flags);
38 local_irq_restore(flags);
41 static inline void change_bit(int nr, volatile void * addr)
44 volatile unsigned int *a = addr;
48 mask = 1 << (nr & 0x1f);
49 local_irq_save(flags);
51 local_irq_restore(flags);
54 static inline int test_and_set_bit(int nr, volatile void * addr)
57 volatile unsigned int *a = addr;
61 mask = 1 << (nr & 0x1f);
62 local_irq_save(flags);
63 retval = (mask & *a) != 0;
65 local_irq_restore(flags);
70 static inline int test_and_clear_bit(int nr, volatile void * addr)
73 volatile unsigned int *a = addr;
77 mask = 1 << (nr & 0x1f);
78 local_irq_save(flags);
79 retval = (mask & *a) != 0;
81 local_irq_restore(flags);
86 static inline int test_and_change_bit(int nr, volatile void * addr)
89 volatile unsigned int *a = addr;
93 mask = 1 << (nr & 0x1f);
94 local_irq_save(flags);
95 retval = (mask & *a) != 0;
97 local_irq_restore(flags);
102 //#include <asm-generic/bitops/non-atomic.h>
104 static inline unsigned long ffz(unsigned long word)
106 unsigned long result;
112 : "=r" (result), "=r" (word)
113 : "0" (~0L), "1" (word)
119 * ffs - find first bit in word.
120 * @word: The word to search
122 * Undefined if no bit exists, so code should check against 0 first.
124 static inline int ffs(int x)
154 #include <asm-generic/bitops/find.h>
155 #include <asm-generic/bitops/ffs.h>
156 #include <asm-generic/bitops/hweight.h>
157 #include <asm-generic/bitops/sched.h>
158 #include <asm-generic/bitops/ext2-non-atomic.h>
159 #include <asm-generic/bitops/ext2-atomic.h>
160 #include <asm-generic/bitops/minix.h>
161 #include <asm-generic/bitops/fls.h>
162 #include <asm-generic/bitops/fls64.h>
164 #endif /* __KERNEL__ */
166 #endif /* __ASM_SH_BITOPS_H */