gthread: add thread name support on Solaris

https://bugzilla.gnome.org/show_bug.cgi?id=747478
This commit is contained in:
Alan Coopersmith 2015-12-06 11:17:39 -08:00 committed by Matthias Clasen
parent 3301b852a2
commit 28f0160031
2 changed files with 12 additions and 0 deletions

View File

@ -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"
])

View File

@ -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
}