Add thread_equal function to allow for platform defined function to

2001-09-19  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* glib/gthread.h (GThreadFunctions): Add thread_equal function to
	allow for platform defined function to compare two threads.

	* glib/gthread.c: Use g_thread_functions_for_glib_use.thread_equal
	when non-NULL instead of ==.

	* gthread/gthread-posix.c: Add g_thread_equal_posix_impl and
	add to the function vector g_thread_functions_for_glib_use_default.

	* gthread/gthread-solaris.c, gthread/gthread-win32.c: Add NULL
	as equal function, as on those two platforms you don't need an
	equal function.
This commit is contained in:
Sebastian Wilhelmi
2001-09-19 12:46:39 +00:00
committed by Sebastian Wilhelmi
parent 5ad6ec44c6
commit f8f4c3778a
15 changed files with 98 additions and 9 deletions

View File

@@ -49,17 +49,22 @@
#include <string.h>
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
# define g_system_thread_equal(thread1, thread2) \
(thread1.dummy_pointer == thread2.dummy_pointer)
# 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)
((dest).dummy_pointer = (src).dummy_pointer)
#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
# define g_system_thread_equal(thread1, thread2) \
(memcmp (&thread1, &thread2, GLIB_SIZEOF_SYSTEM_THREAD) == 0)
# 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))
(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)))
GQuark
g_thread_error_quark (void)
{