mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-16 12:45:13 +01:00
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.
This commit is contained in:
parent
e00bcfcdec
commit
cc7631cd19
@ -681,8 +681,9 @@ g_thread_self_posix_impl (gpointer thread)
|
|||||||
*(pthread_t*)thread = pthread_self();
|
*(pthread_t*)thread = pthread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gboolean
|
||||||
g_thread_equal_posix_impl (gpointer thread1, gpointer thread2)
|
g_system_thread_equal (gpointer thread1,
|
||||||
|
gpointer thread2)
|
||||||
{
|
{
|
||||||
return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
|
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_exit_posix_impl,
|
||||||
g_thread_set_priority_posix_impl,
|
g_thread_set_priority_posix_impl,
|
||||||
g_thread_self_posix_impl,
|
g_thread_self_posix_impl,
|
||||||
g_thread_equal_posix_impl
|
g_system_thread_equal,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* vim:set foldmethod=marker: */
|
/* vim:set foldmethod=marker: */
|
||||||
|
@ -499,6 +499,13 @@ g_thread_join_win32_impl (gpointer thread)
|
|||||||
g_free (target);
|
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) */
|
/* {{{1 SRWLock and CONDITION_VARIABLE emulation (for Windows XP) */
|
||||||
|
|
||||||
static CRITICAL_SECTION g_thread_xp_lock;
|
static CRITICAL_SECTION g_thread_xp_lock;
|
||||||
|
@ -1196,7 +1196,7 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex)
|
|||||||
|
|
||||||
G_THREAD_UF (thread_self, (&self));
|
G_THREAD_UF (thread_self, (&self));
|
||||||
|
|
||||||
if (g_system_thread_equal (self, mutex->owner))
|
if (g_system_thread_equal (&self, &mutex->owner))
|
||||||
{
|
{
|
||||||
mutex->depth++;
|
mutex->depth++;
|
||||||
return;
|
return;
|
||||||
@ -1229,7 +1229,7 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex)
|
|||||||
|
|
||||||
G_THREAD_UF (thread_self, (&self));
|
G_THREAD_UF (thread_self, (&self));
|
||||||
|
|
||||||
if (g_system_thread_equal (self, mutex->owner))
|
if (g_system_thread_equal (&self, &mutex->owner))
|
||||||
{
|
{
|
||||||
mutex->depth++;
|
mutex->depth++;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1293,7 +1293,7 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
|
|||||||
|
|
||||||
G_THREAD_UF (thread_self, (&self));
|
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;
|
mutex->depth += depth;
|
||||||
return;
|
return;
|
||||||
@ -1859,8 +1859,7 @@ g_thread_join (GThread* thread)
|
|||||||
|
|
||||||
g_return_val_if_fail (thread, NULL);
|
g_return_val_if_fail (thread, NULL);
|
||||||
g_return_val_if_fail (thread->joinable, NULL);
|
g_return_val_if_fail (thread->joinable, NULL);
|
||||||
g_return_val_if_fail (!g_system_thread_equal (real->system_thread,
|
g_return_val_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread), NULL);
|
||||||
zero_thread), NULL);
|
|
||||||
|
|
||||||
G_THREAD_UF (thread_join, (&real->system_thread));
|
G_THREAD_UF (thread_join, (&real->system_thread));
|
||||||
|
|
||||||
@ -1913,7 +1912,7 @@ g_thread_set_priority (GThread* thread,
|
|||||||
GRealThread* real = (GRealThread*) thread;
|
GRealThread* real = (GRealThread*) thread;
|
||||||
|
|
||||||
g_return_if_fail (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_LOW);
|
||||||
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
||||||
|
|
||||||
|
@ -27,21 +27,15 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
/* System thread identifier comparison and assignment */
|
/* System thread identifier comparison and assignment */
|
||||||
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
|
#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) \
|
# define g_system_thread_assign(dest, src) \
|
||||||
((dest).dummy_pointer = (src).dummy_pointer)
|
((dest).dummy_pointer = (src).dummy_pointer)
|
||||||
#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
|
#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) \
|
# define g_system_thread_assign(dest, src) \
|
||||||
(memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
|
(memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
|
||||||
#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
|
#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
|
||||||
|
|
||||||
#define g_system_thread_equal(thread1, thread2) \
|
G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1,
|
||||||
(g_thread_functions_for_glib_use.thread_equal ? \
|
gpointer thread2);
|
||||||
g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
|
|
||||||
g_system_thread_equal_simple((thread1), (thread2)))
|
|
||||||
|
|
||||||
/* Is called from gthread/gthread-impl.c */
|
/* Is called from gthread/gthread-impl.c */
|
||||||
void g_thread_init_glib (void);
|
void g_thread_init_glib (void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user