diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /arch/tile/include/asm/atomic.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'arch/tile/include/asm/atomic.h')
-rw-r--r-- | arch/tile/include/asm/atomic.h | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h index b8c49f98a44c..739cfe0499d1 100644 --- a/arch/tile/include/asm/atomic.h +++ b/arch/tile/include/asm/atomic.h | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | static inline int atomic_read(const atomic_t *v) | 33 | static inline int atomic_read(const atomic_t *v) |
34 | { | 34 | { |
35 | return v->counter; | 35 | return ACCESS_ONCE(v->counter); |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
@@ -130,17 +130,52 @@ static inline int atomic_read(const atomic_t *v) | |||
130 | */ | 130 | */ |
131 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | 131 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) |
132 | 132 | ||
133 | |||
134 | /* | ||
135 | * We define xchg() and cmpxchg() in the included headers. | ||
136 | * Note that we do not define __HAVE_ARCH_CMPXCHG, since that would imply | ||
137 | * that cmpxchg() is an efficient operation, which is not particularly true. | ||
138 | */ | ||
139 | |||
140 | /* Nonexistent functions intended to cause link errors. */ | 133 | /* Nonexistent functions intended to cause link errors. */ |
141 | extern unsigned long __xchg_called_with_bad_pointer(void); | 134 | extern unsigned long __xchg_called_with_bad_pointer(void); |
142 | extern unsigned long __cmpxchg_called_with_bad_pointer(void); | 135 | extern unsigned long __cmpxchg_called_with_bad_pointer(void); |
143 | 136 | ||
137 | #define xchg(ptr, x) \ | ||
138 | ({ \ | ||
139 | typeof(*(ptr)) __x; \ | ||
140 | switch (sizeof(*(ptr))) { \ | ||
141 | case 4: \ | ||
142 | __x = (typeof(__x))(typeof(__x-__x))atomic_xchg( \ | ||
143 | (atomic_t *)(ptr), \ | ||
144 | (u32)(typeof((x)-(x)))(x)); \ | ||
145 | break; \ | ||
146 | case 8: \ | ||
147 | __x = (typeof(__x))(typeof(__x-__x))atomic64_xchg( \ | ||
148 | (atomic64_t *)(ptr), \ | ||
149 | (u64)(typeof((x)-(x)))(x)); \ | ||
150 | break; \ | ||
151 | default: \ | ||
152 | __xchg_called_with_bad_pointer(); \ | ||
153 | } \ | ||
154 | __x; \ | ||
155 | }) | ||
156 | |||
157 | #define cmpxchg(ptr, o, n) \ | ||
158 | ({ \ | ||
159 | typeof(*(ptr)) __x; \ | ||
160 | switch (sizeof(*(ptr))) { \ | ||
161 | case 4: \ | ||
162 | __x = (typeof(__x))(typeof(__x-__x))atomic_cmpxchg( \ | ||
163 | (atomic_t *)(ptr), \ | ||
164 | (u32)(typeof((o)-(o)))(o), \ | ||
165 | (u32)(typeof((n)-(n)))(n)); \ | ||
166 | break; \ | ||
167 | case 8: \ | ||
168 | __x = (typeof(__x))(typeof(__x-__x))atomic64_cmpxchg( \ | ||
169 | (atomic64_t *)(ptr), \ | ||
170 | (u64)(typeof((o)-(o)))(o), \ | ||
171 | (u64)(typeof((n)-(n)))(n)); \ | ||
172 | break; \ | ||
173 | default: \ | ||
174 | __cmpxchg_called_with_bad_pointer(); \ | ||
175 | } \ | ||
176 | __x; \ | ||
177 | }) | ||
178 | |||
144 | #define tas(ptr) (xchg((ptr), 1)) | 179 | #define tas(ptr) (xchg((ptr), 1)) |
145 | 180 | ||
146 | #endif /* __ASSEMBLY__ */ | 181 | #endif /* __ASSEMBLY__ */ |