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
17 #ifndef _LINUX_BITOPS_H
18 #error only <linux/bitops.h> can be included directly
21 #include <linux/compiler.h>
22 #include <asm/system.h>
24 #include <asm/byteorder.h>
26 static __inline__
void set_bit(int nr
, volatile void * addr
)
29 volatile unsigned int *a
= addr
;
33 mask
= 1 << (nr
& 0x1f);
34 local_irq_save(flags
);
36 local_irq_restore(flags
);
40 * clear_bit() doesn't provide any barrier for the compiler.
42 #define smp_mb__before_clear_bit() barrier()
43 #define smp_mb__after_clear_bit() barrier()
44 static inline void clear_bit(int nr
, volatile unsigned long *a
)
50 mask
= 1 << (nr
& 0x1f);
51 local_irq_save(flags
);
53 local_irq_restore(flags
);
56 static __inline__
void change_bit(int nr
, volatile void * addr
)
59 volatile unsigned int *a
= addr
;
63 mask
= 1 << (nr
& 0x1f);
64 local_irq_save(flags
);
66 local_irq_restore(flags
);
69 static __inline__
int test_and_set_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_clear_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__
int test_and_change_bit(int nr
, volatile void * addr
)
104 volatile unsigned int *a
= addr
;
108 mask
= 1 << (nr
& 0x1f);
109 local_irq_save(flags
);
110 retval
= (mask
& *a
) != 0;
112 local_irq_restore(flags
);
117 #include <asm-generic/bitops/non-atomic.h>
119 static __inline__
unsigned long ffz(unsigned long word
)
121 unsigned long result
, __d2
, __d3
;
123 __asm__("gettr tr0, %2\n\t"
126 "beq %3, r63, tr0\n\t"
129 "shlri.l %1, 1, %1\n\t"
135 : "=r" (result
), "=r" (word
), "=r" (__d2
), "=r" (__d3
)
136 : "0" (0L), "1" (word
));
141 #include <asm-generic/bitops/__ffs.h>
142 #include <asm-generic/bitops/find.h>
143 #include <asm-generic/bitops/hweight.h>
144 #include <asm-generic/bitops/lock.h>
145 #include <asm-generic/bitops/sched.h>
146 #include <asm-generic/bitops/ffs.h>
147 #include <asm-generic/bitops/ext2-non-atomic.h>
148 #include <asm-generic/bitops/ext2-atomic.h>
149 #include <asm-generic/bitops/minix.h>
150 #include <asm-generic/bitops/fls.h>
151 #include <asm-generic/bitops/fls64.h>
153 #endif /* __KERNEL__ */
155 #endif /* __ASM_SH64_BITOPS_H */