summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-12-06 11:17:39 -0800
committerMatthias Clasen <mclasen@redhat.com>2016-04-26 06:18:34 -0400
commit28f01600315cec9e44a8ed656fb9210bfebaf887 (patch)
treefdb23dd49b2137838914002464d3a8e0a0e7e619
parent3301b852a20b3d1f75592d03dd4038d3ea2fed7c (diff)
downloadglib-28f01600315cec9e44a8ed656fb9210bfebaf887.tar.gz
gthread: add thread name support on Solaris
https://bugzilla.gnome.org/show_bug.cgi?id=747478
-rw-r--r--configure.ac10
-rw-r--r--glib/gthread-posix.c2
2 files changed, 12 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index ca5f7e9d2..b2ef4455f 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 bd3c9a10b..184cdf9ea 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
}