[glib] gthread: add thread name support on Solaris



commit 28f01600315cec9e44a8ed656fb9210bfebaf887
Author: Alan Coopersmith <alan coopersmith oracle com>
Date:   Sun Dec 6 11:17:39 2015 -0800

    gthread: add thread name support on Solaris
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747478

 configure.ac         |   10 ++++++++++
 glib/gthread-posix.c |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ca5f7e9..b2ef445 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2095,6 +2095,16 @@ AS_IF([ test x"$have_threads" = xposix], [
              AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
                 [Have function pthread_setname_np(const char*)])],
             [AC_MSG_RESULT(no)])
+        dnl Sets thread names on Solaris 11.3 & higher
+        AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
+        AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM(
+                [#include <pthread.h>],
+                [pthread_setname_np(pthread_self(), "example")])],
+            [AC_MSG_RESULT(yes)
+             AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
+                [Have function pthread_setname_np(pthread_t, const char*)])],
+            [AC_MSG_RESULT(no)])
         CPPFLAGS="$glib_save_CPPFLAGS"
 ])
 
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index bd3c9a1..184cdf9 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -1231,6 +1231,8 @@ g_system_thread_set_name (const gchar *name)
   prctl (PR_SET_NAME, name, 0, 0, 0, 0); /* on Linux */
 #elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
   pthread_setname_np(name); /* on OS X and iOS */
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+  pthread_setname_np(pthread_self(), name); /* on Solaris */
 #endif
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]