2002-04-30 Jeffrey Stedfast <fejj@ximian.com>
authorJeffrey Stedfast <fejj@novell.com>
Tue, 30 Apr 2002 18:32:21 +0000 (18:32 -0000)
committerJeffrey Stedfast <fejj@novell.com>
Tue, 30 Apr 2002 18:32:21 +0000 (18:32 -0000)
* atomic.c: Changed to use a normal mutex rather than a spinlock
since a lot of platforms seem to not have them :\

svn path=/trunk/mono/; revision=4170

mono/io-layer/ChangeLog
mono/io-layer/atomic.c

index 1526eea44f30ecb34a19fb73a616317201b04b26..ae1b4e6a84c8f996dd5374fa8c42e0b0a0296d13 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-30  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * atomic.c: Changed to use a normal mutex rather than a spinlock
+       since a lot of platforms seem to not have them :\
+
 2002-04-30  Dick Porter  <dick@ximian.com>
 
        * Completely rewrote the handle waiting code: removed the helper
index 88212deec3daf40efa9de7dbdbd689ffc0ad88b8..49ce216d6898bb26f33cd6bc73c70cb28b1cbb78 100644 (file)
@@ -7,12 +7,12 @@
 #ifndef WAPI_ATOMIC_ASM
 #warning "Atomic functions are not atomic!"
 
-static pthread_spinlock_t spin;
+static pthread_mutex_t spin;
 static pthread_once_t spin_once=PTHREAD_ONCE_INIT;
 
 static void spin_init(void)
 {
-       pthread_spin_init(&spin, 0);
+       pthread_mutex_init(&spin, 0);
        g_warning("Using non-atomic functions!");
 }
 
@@ -22,14 +22,14 @@ gint32 InterlockedCompareExchange(volatile gint32 *dest, gint32 exch,
        gint32 old;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
        
        old= *dest;
        if(old==comp) {
                *dest=exch;
        }
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
 
        return(old);
 }
@@ -40,14 +40,14 @@ gpointer InterlockedCompareExchangePointer(volatile gpointer *dest,
        gpointer old;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
        
        old= *dest;
        if(old==comp) {
                *dest=exch;
        }
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
 
        return(old);
 }
@@ -57,12 +57,12 @@ gint32 InterlockedIncrement(volatile gint32 *dest)
        gint32 ret;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
        
        *dest++;
        ret= *dest;
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
        
        return(ret);
 }
@@ -72,12 +72,12 @@ gint32 InterlockedDecrement(volatile gint32 *dest)
        gint32 ret;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
        
        *dest--;
        ret= *dest;
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
        
        return(ret);
 }
@@ -87,12 +87,12 @@ gint32 InterlockedExchange(volatile gint32 *dest, gint32 exch)
        gint32 ret;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
 
        ret=*dest;
        *dest=exch;
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
        
        return(ret);
 }
@@ -102,12 +102,12 @@ gpointer InterlockedExchangePointer(volatile gpointer *dest, gpointer exch)
        gpointer ret;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
        
        ret=*dest;
        *dest=exch;
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
        
        return(ret);
 }
@@ -117,12 +117,12 @@ gint32 InterlockedExchangeAdd(volatile gint32 *dest, gint32 add)
        gint32 ret;
        
        pthread_once(&spin_once, spin_init);
-       pthread_spin_lock(&spin);
+       pthread_mutex_lock(&spin);
 
        ret= *dest;
        *dest+=add;
        
-       pthread_spin_unlock(&spin);
+       pthread_mutex_unlock(&spin);
        
        return(ret);
 }