aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ia64
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2007-05-08 03:34:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:19 -0400
commit819791319becde19e32788a34cc2556aef9f9e6d (patch)
tree50c0b7cc25e4338b1e99002ac40f592da2536c75 /include/asm-ia64
parente656e245d5adf19f3c431e7f7792659c204e32f2 (diff)
atomic.h: add atomic64 cmpxchg, xchg and add_unless to ia64
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Cc: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-ia64')
-rw-r--r--include/asm-ia64/atomic.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/asm-ia64/atomic.h b/include/asm-ia64/atomic.h
index 569ec7574baf..b16ad235c7ee 100644
--- a/include/asm-ia64/atomic.h
+++ b/include/asm-ia64/atomic.h
@@ -88,12 +88,16 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
88 return new; 88 return new;
89} 89}
90 90
91#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) 91#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new))
92#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 92#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
93 93
94#define atomic64_cmpxchg(v, old, new) \
95 (cmpxchg(&((v)->counter), old, new))
96#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
97
94#define atomic_add_unless(v, a, u) \ 98#define atomic_add_unless(v, a, u) \
95({ \ 99({ \
96 int c, old; \ 100 __typeof__(v->counter) c, old; \
97 c = atomic_read(v); \ 101 c = atomic_read(v); \
98 for (;;) { \ 102 for (;;) { \
99 if (unlikely(c == (u))) \ 103 if (unlikely(c == (u))) \
@@ -107,6 +111,22 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
107}) 111})
108#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 112#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
109 113
114#define atomic64_add_unless(v, a, u) \
115({ \
116 __typeof__(v->counter) c, old; \
117 c = atomic64_read(v); \
118 for (;;) { \
119 if (unlikely(c == (u))) \
120 break; \
121 old = atomic64_cmpxchg((v), c, c + (a)); \
122 if (likely(old == c)) \
123 break; \
124 c = old; \
125 } \
126 c != (u); \
127})
128#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
129
110#define atomic_add_return(i,v) \ 130#define atomic_add_return(i,v) \
111({ \ 131({ \
112 int __ia64_aar_i = (i); \ 132 int __ia64_aar_i = (i); \