From 0d721450eb9dca0cc5051c7ac9d2570685cce7e5 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 24 Jun 2010 14:01:05 +0200 Subject: added missing support for systems without atomic instructions --- runtime/atomic.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'runtime/atomic.h') diff --git a/runtime/atomic.h b/runtime/atomic.h index da0852fa..da544c4b 100644 --- a/runtime/atomic.h +++ b/runtime/atomic.h @@ -90,6 +90,21 @@ pthread_mutex_unlock(hlpmut); \ } + static inline int + ATOMIC_CAS(int *data, int oldVal, int newVal, pthread_mutex_t *phlpmut) { + int bSuccess; + pthread_mutex_lock(phlpmut); + if(*data == oldVal) { + *data = newVal; + bSuccess = 1; + } else { + bSuccess = 0; + } + pthread_mutex_unlock(phlpmut); + return(bSuccess); + } + + static inline int ATOMIC_CAS_VAL(int *data, int oldVal, int newVal, pthread_mutex_t *phlpmut) { int val; -- cgit