aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2008-02-07 03:16:25 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:33 -0500
commit80af4eeb726f038eddc32826e4238feba5b1dfb4 (patch)
tree004867c90a5294a8902fc01f1181beacab587300 /include
parent405321d3ab2b41960e2874f2f74609daffbc7a4c (diff)
Add cmpxchg_local to sparc64
Use cmpxchg_u32 and cmpxchg_u64 for cmpxchg_local and cmpxchg64_local. For other type sizes, use the new generic cmpxchg_local (disables interrupt). Change: Since the header depends on local_irqsave/local_irqrestore, it must be included after their declaration. Actually, being below the #include <linux/irqflags.h> should be enough, and on sparc64 it is included at the beginning of system.h. So it makes sense to move it up for sparc64. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-sparc64/system.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index 99a669c190c7..1faefa6d3708 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -8,6 +8,7 @@
8#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
9 9
10#include <linux/irqflags.h> 10#include <linux/irqflags.h>
11#include <asm-generic/cmpxchg-local.h>
11 12
12/* 13/*
13 * Sparc (general) CPU types 14 * Sparc (general) CPU types
@@ -315,6 +316,34 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
315 (unsigned long)_n_, sizeof(*(ptr))); \ 316 (unsigned long)_n_, sizeof(*(ptr))); \
316 }) 317 })
317 318
319/*
320 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
321 * them available.
322 */
323
324static inline unsigned long __cmpxchg_local(volatile void *ptr,
325 unsigned long old,
326 unsigned long new, int size)
327{
328 switch (size) {
329 case 4:
330 case 8: return __cmpxchg(ptr, old, new, size);
331 default:
332 return __cmpxchg_local_generic(ptr, old, new, size);
333 }
334
335 return old;
336}
337
338#define cmpxchg_local(ptr, o, n) \
339 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
340 (unsigned long)(n), sizeof(*(ptr))))
341#define cmpxchg64_local(ptr, o, n) \
342 ({ \
343 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
344 cmpxchg_local((ptr), (o), (n)); \
345 })
346
318#endif /* !(__ASSEMBLY__) */ 347#endif /* !(__ASSEMBLY__) */
319 348
320#define arch_align_stack(x) (x) 349#define arch_align_stack(x) (x)