bitops: remove ext2 non-atomic bitops from asm/bitops.h
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / blackfin / include / asm / bitops.h
blob6a69690bd4653d5bc8c74fd9edf71f319489bf61
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
5 */
7 #ifndef _BLACKFIN_BITOPS_H
8 #define _BLACKFIN_BITOPS_H
10 #include <linux/compiler.h>
12 #include <asm-generic/bitops/__ffs.h>
13 #include <asm-generic/bitops/ffz.h>
14 #include <asm-generic/bitops/fls.h>
15 #include <asm-generic/bitops/__fls.h>
16 #include <asm-generic/bitops/fls64.h>
17 #include <asm-generic/bitops/find.h>
19 #ifndef _LINUX_BITOPS_H
20 #error only <linux/bitops.h> can be included directly
21 #endif
23 #include <asm-generic/bitops/sched.h>
24 #include <asm-generic/bitops/ffs.h>
25 #include <asm-generic/bitops/const_hweight.h>
26 #include <asm-generic/bitops/lock.h>
28 #include <asm-generic/bitops/le.h>
29 #include <asm-generic/bitops/ext2-atomic.h>
30 #include <asm-generic/bitops/minix.h>
32 #ifndef CONFIG_SMP
33 #include <linux/irqflags.h>
36 * clear_bit may not imply a memory barrier
38 #ifndef smp_mb__before_clear_bit
39 #define smp_mb__before_clear_bit() smp_mb()
40 #define smp_mb__after_clear_bit() smp_mb()
41 #endif
42 #include <asm-generic/bitops/atomic.h>
43 #include <asm-generic/bitops/non-atomic.h>
44 #else
46 #include <asm/byteorder.h> /* swab32 */
47 #include <linux/linkage.h>
49 asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
51 asmlinkage int __raw_bit_clear_asm(volatile unsigned long *addr, int nr);
53 asmlinkage int __raw_bit_toggle_asm(volatile unsigned long *addr, int nr);
55 asmlinkage int __raw_bit_test_set_asm(volatile unsigned long *addr, int nr);
57 asmlinkage int __raw_bit_test_clear_asm(volatile unsigned long *addr, int nr);
59 asmlinkage int __raw_bit_test_toggle_asm(volatile unsigned long *addr, int nr);
61 asmlinkage int __raw_bit_test_asm(const volatile unsigned long *addr, int nr);
63 static inline void set_bit(int nr, volatile unsigned long *addr)
65 volatile unsigned long *a = addr + (nr >> 5);
66 __raw_bit_set_asm(a, nr & 0x1f);
69 static inline void clear_bit(int nr, volatile unsigned long *addr)
71 volatile unsigned long *a = addr + (nr >> 5);
72 __raw_bit_clear_asm(a, nr & 0x1f);
75 static inline void change_bit(int nr, volatile unsigned long *addr)
77 volatile unsigned long *a = addr + (nr >> 5);
78 __raw_bit_toggle_asm(a, nr & 0x1f);
81 static inline int test_bit(int nr, const volatile unsigned long *addr)
83 volatile const unsigned long *a = addr + (nr >> 5);
84 return __raw_bit_test_asm(a, nr & 0x1f) != 0;
87 static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
89 volatile unsigned long *a = addr + (nr >> 5);
90 return __raw_bit_test_set_asm(a, nr & 0x1f);
93 static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
95 volatile unsigned long *a = addr + (nr >> 5);
96 return __raw_bit_test_clear_asm(a, nr & 0x1f);
99 static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
101 volatile unsigned long *a = addr + (nr >> 5);
102 return __raw_bit_test_toggle_asm(a, nr & 0x1f);
106 * clear_bit() doesn't provide any barrier for the compiler.
108 #define smp_mb__before_clear_bit() barrier()
109 #define smp_mb__after_clear_bit() barrier()
111 #define test_bit __skip_test_bit
112 #include <asm-generic/bitops/non-atomic.h>
113 #undef test_bit
115 #endif /* CONFIG_SMP */
118 * hweightN: returns the hamming weight (i.e. the number
119 * of bits set) of a N-bit word
122 static inline unsigned int __arch_hweight32(unsigned int w)
124 unsigned int res;
126 __asm__ ("%0.l = ONES %1;"
127 "%0 = %0.l (Z);"
128 : "=d" (res) : "d" (w));
129 return res;
132 static inline unsigned int __arch_hweight64(__u64 w)
134 return __arch_hweight32((unsigned int)(w >> 32)) +
135 __arch_hweight32((unsigned int)w);
138 static inline unsigned int __arch_hweight16(unsigned int w)
140 return __arch_hweight32(w & 0xffff);
143 static inline unsigned int __arch_hweight8(unsigned int w)
145 return __arch_hweight32(w & 0xff);
148 #endif /* _BLACKFIN_BITOPS_H */