[glib] Stop using ptrctl for thread names



commit 99bdfd1bcb921c987b29a0780fa7c50c3155341e
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Apr 26 06:35:06 2016 -0400

    Stop using ptrctl for thread names
    
    We now prefer pthread_setname_np when available, and don't
    need the linux specific API anymore. Also change the test
    for this functionality to use pthread_getname_np.

 configure.ac         |    2 +-
 glib/gthread-posix.c |   11 +++--------
 glib/tests/thread.c  |   10 ++++------
 3 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b2ef445..86ca32e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -709,7 +709,7 @@ AC_CHECK_HEADERS([sys/param.h sys/resource.h mach/mach_time.h])
 AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h])
 AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h])
 AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
-AC_CHECK_HEADERS([linux/magic.h sys/prctl.h])
+AC_CHECK_HEADERS([linux/magic.h])
 
 # Some versions of MSC lack these
 AC_CHECK_HEADERS([dirent.h sys/time.h])
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 184cdf9..9e49e9c 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -59,9 +59,6 @@
 #ifdef HAVE_SCHED_H
 #include <sched.h>
 #endif
-#ifdef HAVE_SYS_PRCTL_H
-#include <sys/prctl.h>
-#endif
 #ifdef G_OS_WIN32
 #include <windows.h>
 #endif
@@ -1227,12 +1224,10 @@ g_system_thread_exit (void)
 void
 g_system_thread_set_name (const gchar *name)
 {
-#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_NAME)
-  prctl (PR_SET_NAME, name, 0, 0, 0, 0); /* on Linux */
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+  pthread_setname_np (pthread_self(), name); /* on Linux and Solaris */
 #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 */
+  pthread_setname_np (name); /* on OS X and iOS */
 #endif
 }
 
diff --git a/glib/tests/thread.c b/glib/tests/thread.c
index 11d847b..707485e 100644
--- a/glib/tests/thread.c
+++ b/glib/tests/thread.c
@@ -170,14 +170,12 @@ test_thread5 (void)
 static gpointer
 thread6_func (gpointer data)
 {
-#ifdef HAVE_SYS_PRCTL_H
-#ifdef PR_GET_NAME
-  const gchar name[16];
+#ifdef HAVE_PTHREAD_SETNAME_NP_WITH_TID
+  char name[16];
 
-  prctl (PR_GET_NAME, name, 0, 0, 0, 0);
+  pthread_getname_np (pthread_self(), name, 16);
 
-  g_assert_cmpstr (name, ==, (gchar*)data);
-#endif
+  g_assert_cmpstr (name, ==, data);
 #endif
 
   return NULL;


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