1 #ifndef __ASM_SH64_BITOPS_H
2 #define __ASM_SH64_BITOPS_H
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 * include/asm-sh64/bitops.h
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
16 #include <linux/compiler.h>
17 #include <asm/system.h>
19 #include <asm/byteorder.h>
21 static __inline__
void set_bit(int nr
, volatile void * addr
)
24 volatile unsigned int *a
= addr
;
28 mask
= 1 << (nr
& 0x1f);
29 local_irq_save(flags
);
31 local_irq_restore(flags
);
35 * clear_bit() doesn't provide any barrier for the compiler.
37 #define smp_mb__before_clear_bit() barrier()
38 #define smp_mb__after_clear_bit() barrier()
39 static inline void clear_bit(int nr
, volatile unsigned long *a
)
45 mask
= 1 << (nr
& 0x1f);
46 local_irq_save(flags
);
48 local_irq_restore(flags
);
51 static __inline__
void change_bit(int nr
, volatile void * addr
)
54 volatile unsigned int *a
= addr
;
58 mask
= 1 << (nr
& 0x1f);
59 local_irq_save(flags
);
61 local_irq_restore(flags
);
64 static __inline__
int test_and_set_bit(int nr
, volatile void * addr
)
67 volatile unsigned int *a
= addr
;
71 mask
= 1 << (nr
& 0x1f);
72 local_irq_save(flags
);
73 retval
= (mask
& *a
) != 0;
75 local_irq_restore(flags
);
80 static __inline__
int test_and_clear_bit(int nr
, volatile void * addr
)
83 volatile unsigned int *a
= addr
;
87 mask
= 1 << (nr
& 0x1f);
88 local_irq_save(flags
);
89 retval
= (mask
& *a
) != 0;
91 local_irq_restore(flags
);
96 static __inline__
int test_and_change_bit(int nr
, volatile void * addr
)
99 volatile unsigned int *a
= addr
;
103 mask
= 1 << (nr
& 0x1f);
104 local_irq_save(flags
);
105 retval
= (mask
& *a
) != 0;
107 local_irq_restore(flags
);
112 #include <asm-generic/bitops/non-atomic.h>
114 static __inline__
unsigned long ffz(unsigned long word
)
116 unsigned long result
, __d2
, __d3
;
118 __asm__("gettr tr0, %2\n\t"
121 "beq %3, r63, tr0\n\t"
124 "shlri.l %1, 1, %1\n\t"
130 : "=r" (result
), "=r" (word
), "=r" (__d2
), "=r" (__d3
)
131 : "0" (0L), "1" (word
));
136 #include <asm-generic/bitops/__ffs.h>
137 #include <asm-generic/bitops/find.h>
138 #include <asm-generic/bitops/hweight.h>
139 #include <asm-generic/bitops/sched.h>
140 #include <asm-generic/bitops/ffs.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_SH64_BITOPS_H */