From: Ryan Lortie Date: Sat, 17 Sep 2011 22:05:24 +0000 (-0400) Subject: libglib: stop using g_cond_new in some places X-Git-Tag: 2.31.0~450 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1d34d0187cd658a95fba64473942b55d27bfcea;p=platform%2Fupstream%2Fglib.git libglib: stop using g_cond_new in some places Port a couple of low-level users of g_cond_new to use G_COND_INIT or g_cond_init() as appropriate. --- diff --git a/glib/gbitlock.c b/glib/gbitlock.c index f68becd..1d241fb 100644 --- a/glib/gbitlock.c +++ b/glib/gbitlock.c @@ -31,9 +31,8 @@ #include "gthreadprivate.h" #include "config.h" - -#ifdef G_BIT_LOCK_FORCE_FUTEX_EMULATION #undef HAVE_FUTEX +#ifdef G_BIT_LOCK_FORCE_FUTEX_EMULATION #endif #ifndef HAVE_FUTEX @@ -102,7 +101,7 @@ typedef struct { const volatile gint *address; gint ref_count; - GCond *wait_queue; + GCond wait_queue; } WaitAddress; static WaitAddress * @@ -134,20 +133,20 @@ g_futex_wait (const volatile gint *address, { waiter = g_slice_new (WaitAddress); waiter->address = address; - waiter->wait_queue = g_cond_new (); + g_cond_init (&waiter->wait_queue); waiter->ref_count = 0; g_futex_address_list = g_slist_prepend (g_futex_address_list, waiter); } waiter->ref_count++; - g_cond_wait (waiter->wait_queue, &g_futex_mutex); + g_cond_wait (&waiter->wait_queue, &g_futex_mutex); if (!--waiter->ref_count) { g_futex_address_list = g_slist_remove (g_futex_address_list, waiter); - g_cond_free (waiter->wait_queue); + g_cond_clear (&waiter->wait_queue); g_slice_free (WaitAddress, waiter); } } @@ -167,7 +166,7 @@ g_futex_wake (const volatile gint *address) */ g_mutex_lock (&g_futex_mutex); if ((waiter = g_futex_find_address (address))) - g_cond_signal (waiter->wait_queue); + g_cond_signal (&waiter->wait_queue); g_mutex_unlock (&g_futex_mutex); } #endif diff --git a/glib/gthread.c b/glib/gthread.c index bcc29f8..62d6116 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -875,7 +875,7 @@ static GThreadFunctions g_thread_functions_for_glib_use_old = { /* Local Data {{{1 -------------------------------------------------------- */ static GMutex g_once_mutex = G_MUTEX_INIT; -static GCond *g_once_cond = NULL; +static GCond g_once_cond = G_COND_INIT; static GPrivate *g_thread_specific_private = NULL; static GRealThread *g_thread_all_threads = NULL; static GSList *g_thread_free_indices = NULL; @@ -940,9 +940,6 @@ g_thread_init_glib (void) */ GRealThread* main_thread = (GRealThread*) g_thread_self (); - /* mutex and cond creation works without g_threads_got_initialized */ - g_once_cond = g_cond_new (); - /* we may only create mutex and cond in here */ _g_mem_thread_init_noprivate_nomessage (); @@ -1049,7 +1046,7 @@ g_once_impl (GOnce *once, g_mutex_lock (&g_once_mutex); while (once->status == G_ONCE_STATUS_PROGRESS) - g_cond_wait (g_once_cond, &g_once_mutex); + g_cond_wait (&g_once_cond, &g_once_mutex); if (once->status != G_ONCE_STATUS_READY) { @@ -1060,7 +1057,7 @@ g_once_impl (GOnce *once, g_mutex_lock (&g_once_mutex); once->status = G_ONCE_STATUS_READY; - g_cond_broadcast (g_once_cond); + g_cond_broadcast (&g_once_cond); } g_mutex_unlock (&g_once_mutex); @@ -1116,7 +1113,7 @@ g_once_init_enter_impl (volatile gsize *value_location) } else do - g_cond_wait (g_once_cond, &g_once_mutex); + g_cond_wait (&g_once_cond, &g_once_mutex); while (g_slist_find (g_once_init_list, (void*) value_location)); } g_mutex_unlock (&g_once_mutex); @@ -1148,7 +1145,7 @@ g_once_init_leave (volatile gsize *value_location, g_atomic_pointer_set (value_location, initialization_value); g_mutex_lock (&g_once_mutex); g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location); - g_cond_broadcast (g_once_cond); + g_cond_broadcast (&g_once_cond); g_mutex_unlock (&g_once_mutex); }