summaryrefslogtreecommitdiffstats
path: root/include/asm-cris
diff options
context:
space:
mode:
authorNick Piggin <nickpiggin@yahoo.com.au>2005-11-13 16:07:24 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-13 18:14:16 -0800
commit4a6dae6d382e9edf3ff440b819e554ed706359bc (patch)
tree2945a5095973e2ecf05b503d6deb859083045b8e /include/asm-cris
parent53e86b91b7ae66d4c2757195cbd42e00d9199cf2 (diff)
downloadop-kernel-dev-4a6dae6d382e9edf3ff440b819e554ed706359bc.zip
op-kernel-dev-4a6dae6d382e9edf3ff440b819e554ed706359bc.tar.gz
[PATCH] atomic: cmpxchg
Introduce an atomic_cmpxchg operation. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: "Paul E. McKenney" <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-cris')
-rw-r--r--include/asm-cris/atomic.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asm-cris/atomic.h b/include/asm-cris/atomic.h
index 8c2e783..45891f7d 100644
--- a/include/asm-cris/atomic.h
+++ b/include/asm-cris/atomic.h
@@ -123,6 +123,19 @@ static inline int atomic_inc_and_test(volatile atomic_t *v)
return retval;
}
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+ int ret;
+ unsigned long flags;
+
+ cris_atomic_save(v, flags);
+ ret = v->counter;
+ if (likely(ret == old))
+ v->counter = new;
+ cris_atomic_restore(v, flags);
+ return ret;
+}
+
/* Atomic operations are already serializing */
#define smp_mb__before_atomic_dec() barrier()
#define smp_mb__after_atomic_dec() barrier()
OpenPOWER on IntegriCloud