diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-09-18 23:58:12 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-09-21 16:06:55 -0400 |
commit | 7a69d46dc562188a8673c6057919b4d65798491d (patch) | |
tree | 16f355516e6ee9f090d7bf1d8c159f818d182f1a | |
parent | 51d92adeee67d1df30d13fe41e97af9e563f62ec (diff) |
GSystemThread: port 'self' 'join' and 'create'
Switch 'self' 'join' and 'create' from using the vtable to being called
via normal g_system_thread_* internal API (implemented in each of
gthread-{posix,win32}.c).
Again, we can put NULL in the vtable since these were never used from
gthread.h.
-rw-r--r-- | glib/gthread-posix.c | 32 | ||||
-rw-r--r-- | glib/gthread-win32.c | 32 | ||||
-rw-r--r-- | glib/gthread.c | 18 | ||||
-rw-r--r-- | glib/gthreadprivate.h | 10 |
4 files changed, 51 insertions, 41 deletions
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c index 950e5719c..3e7349f81 100644 --- a/glib/gthread-posix.c +++ b/glib/gthread-posix.c @@ -492,15 +492,15 @@ _g_thread_impl_init(void) #endif /* _SC_THREAD_STACK_MIN */ } -static void -g_thread_create_posix_impl (GThreadFunc thread_func, - gpointer arg, - gulong stack_size, - gboolean joinable, - gboolean bound, - GThreadPriority priority, - gpointer thread, - GError **error) +void +g_system_thread_create (GThreadFunc thread_func, + gpointer arg, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + gpointer thread, + GError **error) { pthread_attr_t attr; gint ret; @@ -558,8 +558,8 @@ g_thread_yield (void) sched_yield (); } -static void -g_thread_join_posix_impl (gpointer thread) +void +g_system_thread_join (gpointer thread) { gpointer ignore; posix_check_cmd (pthread_join (*(pthread_t*)thread, &ignore)); @@ -571,8 +571,8 @@ g_system_thread_exit (void) pthread_exit (NULL); } -static void -g_thread_self_posix_impl (gpointer thread) +void +g_system_thread_self (gpointer thread) { *(pthread_t*)thread = pthread_self(); } @@ -601,12 +601,12 @@ GThreadFunctions g_thread_functions_for_glib_use = g_private_new, g_private_get, g_private_set, - g_thread_create_posix_impl, + NULL, g_thread_yield, - g_thread_join_posix_impl, + NULL, g_system_thread_exit, NULL, - g_thread_self_posix_impl, + NULL, g_system_thread_equal, }; diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c index a71dae25e..97a10d26a 100644 --- a/glib/gthread-win32.c +++ b/glib/gthread-win32.c @@ -316,8 +316,8 @@ struct _GThreadData gboolean joinable; }; -static void -g_thread_self_win32_impl (gpointer thread) +void +g_system_thread_self (gpointer thread) { GThreadData *self = TlsGetValue (g_thread_self_tls); @@ -406,15 +406,15 @@ g_thread_proxy (gpointer data) return 0; } -static void -g_thread_create_win32_impl (GThreadFunc func, - gpointer data, - gulong stack_size, - gboolean joinable, - gboolean bound, - GThreadPriority priority, - gpointer thread, - GError **error) +void +g_system_thread_create (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + gpointer thread, + GError **error) { guint ignore; GThreadData *retval; @@ -449,8 +449,8 @@ g_thread_yield (void) Sleep(0); } -static void -g_thread_join_win32_impl (gpointer thread) +void +g_system_thread_join (gpointer thread) { GThreadData *target = *(GThreadData **)thread; @@ -768,12 +768,12 @@ GThreadFunctions g_thread_functions_for_glib_use = g_private_new, /* private thread data */ g_private_get, g_private_set, - g_thread_create_win32_impl, /* thread */ + NULL, /* thread */ g_thread_yield, - g_thread_join_win32_impl, + NULL, g_system_thread_exit, NULL, - g_thread_self_win32_impl, + NULL, g_system_thread_equal }; diff --git a/glib/gthread.c b/glib/gthread.c index 82aee33b9..9b50dfdf9 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -708,7 +708,7 @@ g_thread_init_glib (void) g_threads_got_initialized = TRUE; g_private_init (&g_thread_specific_private, g_thread_cleanup); g_private_set (&g_thread_specific_private, main_thread); - G_THREAD_UF (thread_self, (&main_thread->system_thread)); + g_system_thread_self (&main_thread->system_thread); /* accomplish log system initialization to enable messaging */ _g_messages_thread_init_nomessage (); @@ -1188,7 +1188,7 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex) if (!g_thread_supported ()) return; - G_THREAD_UF (thread_self, (&self)); + g_system_thread_self (&self); if (g_system_thread_equal (&self, &mutex->owner)) { @@ -1221,7 +1221,7 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex) if (!g_thread_supported ()) return TRUE; - G_THREAD_UF (thread_self, (&self)); + g_system_thread_self (&self); if (g_system_thread_equal (&self, &mutex->owner)) { @@ -1285,7 +1285,7 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, if (depth == 0) return; - G_THREAD_UF (thread_self, (&self)); + g_system_thread_self (&self); if (g_system_thread_equal (&self, &mutex->owner)) { @@ -1771,9 +1771,9 @@ g_thread_create_full (GThreadFunc func, result->thread.data = data; result->private_data = NULL; G_LOCK (g_thread); - G_THREAD_UF (thread_create, (g_thread_create_proxy, result, - stack_size, joinable, bound, 0, - &result->system_thread, &local_error)); + g_system_thread_create (g_thread_create_proxy, result, + stack_size, joinable, bound, 0, + &result->system_thread, &local_error); if (!local_error) { result->next = g_thread_all_threads; @@ -1844,7 +1844,7 @@ g_thread_join (GThread* thread) g_return_val_if_fail (thread->joinable, NULL); g_return_val_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread), NULL); - G_THREAD_UF (thread_join, (&real->system_thread)); + g_system_thread_join (&real->system_thread); retval = real->retval; @@ -1913,7 +1913,7 @@ g_thread_self (void) thread->thread.data = NULL; thread->private_data = NULL; - G_THREAD_UF (thread_self, (&thread->system_thread)); + g_system_thread_self (&thread->system_thread); g_private_set (&g_thread_specific_private, thread); diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h index 15f2452dd..f4d7288a3 100644 --- a/glib/gthreadprivate.h +++ b/glib/gthreadprivate.h @@ -34,6 +34,16 @@ G_BEGIN_DECLS (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD)) #endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */ +G_GNUC_INTERNAL void g_system_thread_self (gpointer thread); +G_GNUC_INTERNAL void g_system_thread_join (gpointer thread); +G_GNUC_INTERNAL void g_system_thread_create (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + gpointer thread, + GError **error); G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1, gpointer thread2); |