#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,
(void *)&spin);
thr_ret = pthread_mutex_lock(&spin);
g_assert (thr_ret == 0);
-
- *dest++;
+
+ (*dest)++;
ret= *dest;
thr_ret = pthread_mutex_unlock(&spin);
thr_ret = pthread_mutex_lock(&spin);
g_assert (thr_ret == 0);
- *dest--;
+ (*dest)--;
ret= *dest;
thr_ret = pthread_mutex_unlock(&spin);
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);