bitops: remove minix bitops from asm/bitops.h
[linux-2.6/libata-dev.git] / arch / blackfin / include / asm / bitops.h
blob49762c6bb0d56f549f090fd98216ababccc75045
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>
31 #ifndef CONFIG_SMP
32 #include <linux/irqflags.h>
35 * clear_bit may not imply a memory barrier
37 #ifndef smp_mb__before_clear_bit
38 #define smp_mb__before_clear_bit() smp_mb()
39 #define smp_mb__after_clear_bit() smp_mb()
40 #endif
41 #include <asm-generic/bitops/atomic.h>
42 #include <asm-generic/bitops/non-atomic.h>
43 #else
45 #include <asm/byteorder.h> /* swab32 */
46 #include <linux/linkage.h>
48 asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
50 asmlinkage int __raw_bit_clear_asm(volatile unsigned long *addr, int nr);
52 asmlinkage int __raw_bit_toggle_asm(volatile unsigned long *addr, int nr);
54 asmlinkage int __raw_bit_test_set_asm(volatile unsigned long *addr, int nr);
56 asmlinkage int __raw_bit_test_clear_asm(volatile unsigned long *addr, int nr);
58 asmlinkage int __raw_bit_test_toggle_asm(volatile unsigned long *addr, int nr);
60 asmlinkage int __raw_bit_test_asm(const volatile unsigned long *addr, int nr);
62 static inline void set_bit(int nr, volatile unsigned long *addr)
64 volatile unsigned long *a = addr + (nr >> 5);
65 __raw_bit_set_asm(a, nr & 0x1f);
68 static inline void clear_bit(int nr, volatile unsigned long *addr)
70 volatile unsigned long *a = addr + (nr >> 5);
71 __raw_bit_clear_asm(a, nr & 0x1f);
74 static inline void change_bit(int nr, volatile unsigned long *addr)
76 volatile unsigned long *a = addr + (nr >> 5);
77 __raw_bit_toggle_asm(a, nr & 0x1f);
80 static inline int test_bit(int nr, const volatile unsigned long *addr)
82 volatile const unsigned long *a = addr + (nr >> 5);
83 return __raw_bit_test_asm(a, nr & 0x1f) != 0;
86 static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
88 volatile unsigned long *a = addr + (nr >> 5);
89 return __raw_bit_test_set_asm(a, nr & 0x1f);
92 static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
94 volatile unsigned long *a = addr + (nr >> 5);
95 return __raw_bit_test_clear_asm(a, nr & 0x1f);
98 static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
100 volatile unsigned long *a = addr + (nr >> 5);
101 return __raw_bit_test_toggle_asm(a, nr & 0x1f);
105 * clear_bit() doesn't provide any barrier for the compiler.
107 #define smp_mb__before_clear_bit() barrier()
108 #define smp_mb__after_clear_bit() barrier()
110 #define test_bit __skip_test_bit
111 #include <asm-generic/bitops/non-atomic.h>
112 #undef test_bit
114 #endif /* CONFIG_SMP */
117 * hweightN: returns the hamming weight (i.e. the number
118 * of bits set) of a N-bit word
121 static inline unsigned int __arch_hweight32(unsigned int w)
123 unsigned int res;
125 __asm__ ("%0.l = ONES %1;"
126 "%0 = %0.l (Z);"
127 : "=d" (res) : "d" (w));
128 return res;
131 static inline unsigned int __arch_hweight64(__u64 w)
133 return __arch_hweight32((unsigned int)(w >> 32)) +
134 __arch_hweight32((unsigned int)w);
137 static inline unsigned int __arch_hweight16(unsigned int w)
139 return __arch_hweight32(w & 0xffff);
142 static inline unsigned int __arch_hweight8(unsigned int w)
144 return __arch_hweight32(w & 0xff);
147 #endif /* _BLACKFIN_BITOPS_H */