components/gnome/glib2/patches/10-named-threads.patch
changeset 5891 196a7310cc4d
equal deleted inserted replaced
5890:e3686c085735 5891:196a7310cc4d
       
     1 Submitted upstream in
       
     2 https://bugzilla.gnome.org/show_bug.cgi?id=747478#c23
       
     3 
       
     4 From 6b754f34d278038ff9daa3672399e5eb9b07da65 Mon Sep 17 00:00:00 2001
       
     5 From: Alan Coopersmith <[email protected]>
       
     6 Date: Sun, 6 Dec 2015 11:17:39 -0800
       
     7 Subject: [PATCH] gthread: add thread name support on Solaris
       
     8 
       
     9 ---
       
    10  configure.ac         | 10 ++++++++++
       
    11  glib/gthread-posix.c |  2 ++
       
    12  2 files changed, 12 insertions(+)
       
    13 
       
    14 diff --git a/configure.ac b/configure.ac
       
    15 index 339defc..ccaead2 100644
       
    16 --- a/configure.ac
       
    17 +++ b/configure.ac
       
    18 @@ -2174,6 +2174,16 @@ AS_IF([ test x"$have_threads" = xposix], [
       
    19               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
       
    20                  [Have function pthread_setname_np(const char*)])],
       
    21              [AC_MSG_RESULT(no)])
       
    22 +        dnl Sets thread names on Solaris 11.3 & higher
       
    23 +        AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
       
    24 +        AC_LINK_IFELSE(
       
    25 +            [AC_LANG_PROGRAM(
       
    26 +                [#include <pthread.h>],
       
    27 +                [pthread_setname_np(pthread_self(), "example")])],
       
    28 +            [AC_MSG_RESULT(yes)
       
    29 +             AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
       
    30 +                [Have function pthread_setname_np(pthread_t, const char*)])],
       
    31 +            [AC_MSG_RESULT(no)])
       
    32          CPPFLAGS="$glib_save_CPPFLAGS"
       
    33  ])
       
    34  
       
    35 diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
       
    36 index bd3c9a1..184cdf9 100644
       
    37 --- a/glib/gthread-posix.c
       
    38 +++ b/glib/gthread-posix.c
       
    39 @@ -1231,6 +1231,8 @@ g_system_thread_set_name (const gchar *name)
       
    40    prctl (PR_SET_NAME, name, 0, 0, 0, 0); /* on Linux */
       
    41  #elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
       
    42    pthread_setname_np(name); /* on OS X and iOS */
       
    43 +#elif defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
       
    44 +  pthread_setname_np(pthread_self(), name); /* on Solaris */
       
    45  #endif
       
    46  }
       
    47  
       
    48 -- 
       
    49 2.6.1
       
    50