Switch the runtime to use TARGET_IOS and TARGET_OSX instead of playing with TargetCon...
[mono.git] / mono / io-layer / atomic.c
index 67a4e63efa6a9a1b74a6c5ed36ce93fd96734c4d..07732fd8c1b22da790a69043dc368a7d571148c0 100644 (file)
 
 #include "mono/io-layer/wapi.h"
 
-#ifdef WAPI_ATOMIC_ASM
-#if defined(sparc) || defined (__sparc__)
-volatile unsigned char _wapi_sparc_lock;
-#endif
-#else
+#ifndef WAPI_ATOMIC_ASM
 
 static pthread_mutex_t spin = PTHREAD_MUTEX_INITIALIZER;
 static mono_once_t spin_once=MONO_ONCE_INIT;
 
 static void spin_init(void)
 {
-       g_warning("Using non-atomic functions!");
+       g_warning("Using non-atomic functions!  Expect race conditions when using process-shared handles!");
 }
 
 gint32 InterlockedCompareExchange(volatile gint32 *dest, gint32 exch,
@@ -91,8 +87,8 @@ gint32 InterlockedIncrement(volatile gint32 *dest)
                              (void *)&spin);
        thr_ret = pthread_mutex_lock(&spin);
        g_assert (thr_ret == 0);
-       
-       *dest++;
+
+       (*dest)++;
        ret= *dest;
        
        thr_ret = pthread_mutex_unlock(&spin);
@@ -115,7 +111,7 @@ gint32 InterlockedDecrement(volatile gint32 *dest)
        thr_ret = pthread_mutex_lock(&spin);
        g_assert (thr_ret == 0);
        
-       *dest--;
+       (*dest)--;
        ret= *dest;
        
        thr_ret = pthread_mutex_unlock(&spin);
@@ -134,7 +130,7 @@ gint32 InterlockedExchange(volatile gint32 *dest, gint32 exch)
        mono_once(&spin_once, spin_init);
        
        pthread_cleanup_push ((void(*)(void *))pthread_mutex_unlock,
-                             (void *)&req_mutex);
+                             (void *)&spin);
        thr_ret = pthread_mutex_lock(&spin);
        g_assert (thr_ret == 0);