1 #ifndef __ASM_SH_BITOPS_H
2 #define __ASM_SH_BITOPS_H
5 #include <asm/irqflags.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 static inline unsigned long ffz(unsigned long word)
103 unsigned long result;
109 : "=r" (result), "=r" (word)
110 : "0" (~0L), "1" (word)
116 * ffs - find first bit in word.
117 * @word: The word to search
119 * Undefined if no bit exists, so code should check against 0 first.
121 static inline int ffs (int x)
149 #endif /* __KERNEL__ */
151 #endif /* __ASM_SH_BITOPS_H */