[glib] gthread-posix: always use atomic pointer ops



commit 311e18abdded1f525725ea6e2c346fb402b2af02
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Oct 29 10:13:40 2012 +0100

    gthread-posix: always use atomic pointer ops
    
    On platforms where dependent loads can be reordered (alpha) and we have
    exotic implementation of pthread_mutex_lock() it could be possible that
    our implementation of g_mutex_lock() is unsafe.
    
    Always use atomic operations to avoid this possibility.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686191

 glib/gthread-posix.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index cb06b14..f42e32c 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -116,7 +116,7 @@ g_mutex_impl_free (pthread_mutex_t *mutex)
 static pthread_mutex_t *
 g_mutex_get_impl (GMutex *mutex)
 {
-  pthread_mutex_t *impl = mutex->p;
+  pthread_mutex_t *impl = g_atomic_pointer_get (&mutex->p);
 
   if G_UNLIKELY (impl == NULL)
     {
@@ -285,7 +285,7 @@ g_rec_mutex_impl_free (pthread_mutex_t *mutex)
 static pthread_mutex_t *
 g_rec_mutex_get_impl (GRecMutex *rec_mutex)
 {
-  pthread_mutex_t *impl = rec_mutex->p;
+  pthread_mutex_t *impl = g_atomic_pointer_get (&rec_mutex->p);
 
   if G_UNLIKELY (impl == NULL)
     {
@@ -445,7 +445,7 @@ g_rw_lock_impl_free (pthread_rwlock_t *rwlock)
 static pthread_rwlock_t *
 g_rw_lock_get_impl (GRWLock *lock)
 {
-  pthread_rwlock_t *impl = lock->p;
+  pthread_rwlock_t *impl = g_atomic_pointer_get (&lock->p);
 
   if G_UNLIKELY (impl == NULL)
     {
@@ -662,7 +662,7 @@ g_cond_impl_free (pthread_cond_t *cond)
 static pthread_cond_t *
 g_cond_get_impl (GCond *cond)
 {
-  pthread_cond_t *impl = cond->p;
+  pthread_cond_t *impl = g_atomic_pointer_get (&cond->p);
 
   if G_UNLIKELY (impl == NULL)
     {
@@ -969,7 +969,7 @@ g_private_impl_free (pthread_key_t *key)
 static pthread_key_t *
 g_private_get_impl (GPrivate *key)
 {
-  pthread_key_t *impl = key->p;
+  pthread_key_t *impl = g_atomic_pointer_get (&key->p);
 
   if G_UNLIKELY (impl == NULL)
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]