[glib/wip/mutexes: 43/58] Don't use the thread_equal vfunc anymore
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/mutexes: 43/58] Don't use the thread_equal vfunc anymore
- Date: Mon, 19 Sep 2011 05:15:41 +0000 (UTC)
commit 9f3050d1867eb9fe1625fdcc99d3be68aa45b45e
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 18 23:10:25 2011 -0400
Don't use the thread_equal vfunc anymore
Just move the g_system_thread_equal implementation into
the posix and win32 implementations, and drop some micro macro
optimization.
glib/gthread-posix.c | 7 ++++---
glib/gthread-win32.c | 7 +++++++
glib/gthread.c | 11 +++++------
glib/gthreadprivate.h | 10 ++--------
4 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 52b8d3f..6a25eec 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -681,8 +681,9 @@ g_thread_self_posix_impl (gpointer thread)
*(pthread_t*)thread = pthread_self();
}
-static gboolean
-g_thread_equal_posix_impl (gpointer thread1, gpointer thread2)
+gboolean
+g_system_thread_equal (gpointer thread1,
+ gpointer thread2)
{
return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
}
@@ -710,7 +711,7 @@ GThreadFunctions g_thread_functions_for_glib_use =
g_thread_exit_posix_impl,
g_thread_set_priority_posix_impl,
g_thread_self_posix_impl,
- g_thread_equal_posix_impl
+ g_system_thread_equal,
};
/* vim:set foldmethod=marker: */
diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
index 23a8dfb..3c83d52 100644
--- a/glib/gthread-win32.c
+++ b/glib/gthread-win32.c
@@ -499,6 +499,13 @@ g_thread_join_win32_impl (gpointer thread)
g_free (target);
}
+gboolean
+g_system_thread_equal (gpointer thread1,
+ gpointer thread2)
+{
+ return ((GSystemThread*)thread1)->dummy_pointer == ((GSystemThread*)thread2)->dummy_pointer;
+}
+
/* {{{1 SRWLock and CONDITION_VARIABLE emulation (for Windows XP) */
static CRITICAL_SECTION g_thread_xp_lock;
diff --git a/glib/gthread.c b/glib/gthread.c
index e8e5950..978fbcf 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -1196,7 +1196,7 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex)
G_THREAD_UF (thread_self, (&self));
- if (g_system_thread_equal (self, mutex->owner))
+ if (g_system_thread_equal (&self, &mutex->owner))
{
mutex->depth++;
return;
@@ -1229,7 +1229,7 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex)
G_THREAD_UF (thread_self, (&self));
- if (g_system_thread_equal (self, mutex->owner))
+ if (g_system_thread_equal (&self, &mutex->owner))
{
mutex->depth++;
return TRUE;
@@ -1293,7 +1293,7 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
G_THREAD_UF (thread_self, (&self));
- if (g_system_thread_equal (self, mutex->owner))
+ if (g_system_thread_equal (&self, &mutex->owner))
{
mutex->depth += depth;
return;
@@ -1859,8 +1859,7 @@ g_thread_join (GThread* thread)
g_return_val_if_fail (thread, NULL);
g_return_val_if_fail (thread->joinable, NULL);
- g_return_val_if_fail (!g_system_thread_equal (real->system_thread,
- zero_thread), NULL);
+ g_return_val_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread), NULL);
G_THREAD_UF (thread_join, (&real->system_thread));
@@ -1913,7 +1912,7 @@ g_thread_set_priority (GThread* thread,
GRealThread* real = (GRealThread*) thread;
g_return_if_fail (thread);
- g_return_if_fail (!g_system_thread_equal (real->system_thread, zero_thread));
+ g_return_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread));
g_return_if_fail (priority >= G_THREAD_PRIORITY_LOW);
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index fa64468..3dde484 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -27,21 +27,15 @@ G_BEGIN_DECLS
/* System thread identifier comparison and assignment */
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
-# define g_system_thread_equal_simple(thread1, thread2) \
- ((thread1).dummy_pointer == (thread2).dummy_pointer)
# define g_system_thread_assign(dest, src) \
((dest).dummy_pointer = (src).dummy_pointer)
#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
-# define g_system_thread_equal_simple(thread1, thread2) \
- (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0)
# define g_system_thread_assign(dest, src) \
(memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
-#define g_system_thread_equal(thread1, thread2) \
- (g_thread_functions_for_glib_use.thread_equal ? \
- g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
- g_system_thread_equal_simple((thread1), (thread2)))
+G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1,
+ gpointer thread2);
/* Is called from gthread/gthread-impl.c */
void g_thread_init_glib (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]