G_LOCK: port from GStaticMutex to GMutex
authorRyan Lortie <desrt@desrt.ca>
Sat, 17 Sep 2011 22:33:25 +0000 (18:33 -0400)
committerRyan Lortie <desrt@desrt.ca>
Wed, 21 Sep 2011 19:55:36 +0000 (15:55 -0400)
GCancellable made use of the undocumented G_LOCK_NAME macro in an
invalid way.  Fix that up while we're at it.

gio/gcancellable.c
glib/gthread.h

index 91ff249..7ebbdf4 100644 (file)
@@ -270,8 +270,7 @@ g_cancellable_reset (GCancellable *cancellable)
   while (priv->cancelled_running)
     {
       priv->cancelled_running_waiting = TRUE;
-      g_cond_wait (cancellable_cond,
-                   g_static_mutex_get_mutex (& G_LOCK_NAME (cancellable)));
+      g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
     }
 
   if (priv->cancelled)
@@ -619,8 +618,7 @@ g_cancellable_disconnect (GCancellable  *cancellable,
   while (priv->cancelled_running)
     {
       priv->cancelled_running_waiting = TRUE;
-      g_cond_wait (cancellable_cond,
-                   g_static_mutex_get_mutex (& G_LOCK_NAME (cancellable)));
+      g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
     }
 
   g_signal_handler_disconnect (cancellable, handler_id);
index 68d808d..6b7b7b6 100644 (file)
@@ -348,8 +348,8 @@ extern void glib_dummy_decl (void);
 #define G_LOCK_NAME(name)               g__ ## name ## _lock
 #define G_LOCK_DEFINE_STATIC(name)    static G_LOCK_DEFINE (name)
 #define G_LOCK_DEFINE(name)           \
-  GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT
-#define G_LOCK_EXTERN(name)           extern GStaticMutex G_LOCK_NAME (name)
+  GMutex G_LOCK_NAME (name) = G_MUTEX_INIT
+#define G_LOCK_EXTERN(name)           extern GMutex G_LOCK_NAME (name)
 
 #ifdef G_DEBUG_LOCKS
 #  define G_LOCK(name)                G_STMT_START{             \
@@ -357,24 +357,24 @@ extern void glib_dummy_decl (void);
              "file %s: line %d (%s): locking: %s ",             \
              __FILE__,        __LINE__, G_STRFUNC,              \
              #name);                                            \
-      g_static_mutex_lock (&G_LOCK_NAME (name));                \
+      g_mutex_lock (&G_LOCK_NAME (name));                       \
    }G_STMT_END
 #  define G_UNLOCK(name)              G_STMT_START{             \
       g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                   \
              "file %s: line %d (%s): unlocking: %s ",           \
              __FILE__,        __LINE__, G_STRFUNC,              \
              #name);                                            \
-     g_static_mutex_unlock (&G_LOCK_NAME (name));               \
+     g_mutex_unlock (&G_LOCK_NAME (name));                      \
    }G_STMT_END
 #  define G_TRYLOCK(name)                                       \
       (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                  \
              "file %s: line %d (%s): try locking: %s ",         \
              __FILE__,        __LINE__, G_STRFUNC,              \
-             #name), g_static_mutex_trylock (&G_LOCK_NAME (name)))
+             #name), g_mutex_trylock (&G_LOCK_NAME (name)))
 #else  /* !G_DEBUG_LOCKS */
-#  define G_LOCK(name) g_static_mutex_lock       (&G_LOCK_NAME (name))
-#  define G_UNLOCK(name) g_static_mutex_unlock   (&G_LOCK_NAME (name))
-#  define G_TRYLOCK(name) g_static_mutex_trylock (&G_LOCK_NAME (name))
+#  define G_LOCK(name) g_mutex_lock       (&G_LOCK_NAME (name))
+#  define G_UNLOCK(name) g_mutex_unlock   (&G_LOCK_NAME (name))
+#  define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name))
 #endif /* !G_DEBUG_LOCKS */