Add thread_equal function to allow for platform defined function to
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>
Wed, 19 Sep 2001 12:46:39 +0000 (12:46 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Wed, 19 Sep 2001 12:46:39 +0000 (12:46 +0000)
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.

15 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/glib/tmpl/threads.sgml
glib/gthread.c
glib/gthread.h
gthread/ChangeLog
gthread/gthread-posix.c
gthread/gthread-solaris.c
gthread/gthread-win32.c

index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index ae3c29b610c74a15224f2a101c4d4cfdb4188206..7060a7a911d7fec0dd2c971c2b1d97213455699c 100644 (file)
@@ -1,3 +1,11 @@
+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 ==.
+       
 Wed Sep 19 10:44:25 2001  Tim Janik  <timj@gtk.org>
 
        * Released 1.3.8.
index 75bd494015c09c2f5f109f8f40774dd80fc3c0e8..1b9d6143df4032339f16cb294f408185ff3c51a3 100644 (file)
@@ -137,6 +137,7 @@ This struct should only be used, if you know, what you are doing.
 @thread_exit: 
 @thread_set_priority: 
 @thread_self: 
+@thread_equal: 
 
 <!-- ##### FUNCTION g_thread_init ##### -->
 
index 96cb3f4567498370fed408a024064aaf50e079ff..1cd16fc0503931efba8b4e56eb07c8eeea805b67 100644 (file)
 #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)
 {
index 215cc287a4d97525ab55c7098c752b0061f32636..d4573a1b83cea3508c3a082ccf82e0e37930ffff 100644 (file)
@@ -102,6 +102,8 @@ struct _GThreadFunctions
   void      (*thread_set_priority)(gpointer              thread,
                                    GThreadPriority       priority);
   void      (*thread_self)        (gpointer              thread);
+  gboolean  (*thread_equal)       (gpointer              thread1,
+                                  gpointer              thread2);
 };
 
 GLIB_VAR GThreadFunctions       g_thread_functions_for_glib_use;
index 77f953fb6ba46d6bb18bccc5fa023181a271e1cc..8159e123990eee69dbd7147892feb8bc9658420b 100644 (file)
@@ -1,3 +1,11 @@
+2001-09-19  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * gthread-posix.c: Add g_thread_equal_posix_impl and add to the
+       function vector g_thread_functions_for_glib_use_default.
+       
+       * gthread-solaris.c, gthread-win32.c: Add NULL as equal function,
+       as on those two platforms you don't need an equal function.
+
 2001-09-19  Tor Lillqvist  <tml@iki.fi>
 
        * gthread.rc.in: Correct InternalName and OriginalFilename to
index faeafbc8c96ff5308b1b91215fb3fec1ac3a8ab2..b65c9d57bb626aaca9b281b9789d7c7052af5d3c 100644 (file)
@@ -383,6 +383,12 @@ g_thread_self_posix_impl (gpointer thread)
   *(pthread_t*)thread = pthread_self();
 }
 
+static gboolean
+g_thread_equal_posix_impl (gpointer thread1, gpointer thread2)
+{
+  return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
+}
+
 static GThreadFunctions g_thread_functions_for_glib_use_default =
 {
   g_mutex_new_posix_impl,
@@ -404,5 +410,6 @@ static GThreadFunctions g_thread_functions_for_glib_use_default =
   g_thread_join_posix_impl,
   g_thread_exit_posix_impl,
   g_thread_set_priority_posix_impl,
-  g_thread_self_posix_impl
+  g_thread_self_posix_impl,
+  g_thread_equal_posix_impl
 };
index 7eb7b8a36611f41e0fddf47ccc27ac9de20b18f7..8469b72005bcae7d8b8826d048a6b27f47bac75b 100644 (file)
@@ -270,5 +270,6 @@ static GThreadFunctions g_thread_functions_for_glib_use_default =
   g_thread_join_solaris_impl,
   g_thread_exit_solaris_impl,
   g_thread_set_priority_solaris_impl,
-  g_thread_self_solaris_impl
+  g_thread_self_solaris_impl,
+  NULL /* no equal function necessary on Solaris */
 };
index aebe87d58ca521218d38d70f9f3b8cd0f01b54bc..44e12a901d5a8356a7ff012172115eba9f2fb358 100644 (file)
@@ -521,7 +521,8 @@ static GThreadFunctions g_thread_functions_for_glib_use_default =
   g_thread_join_win32_impl,
   g_thread_exit_win32_impl,
   g_thread_set_priority_win32_impl,
-  g_thread_self_win32_impl
+  g_thread_self_win32_impl,
+  NULL                              /* no equal function necessary */
 };
 
 #define HAVE_G_THREAD_IMPL_INIT