summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-26 06:35:06 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-04-26 06:35:06 -0400
commit99bdfd1bcb921c987b29a0780fa7c50c3155341e (patch)
tree1757ce11cefa624ae72e31be99e2cabd3bcf2065
parent28f01600315cec9e44a8ed656fb9210bfebaf887 (diff)
downloadglib-99bdfd1bcb921c987b29a0780fa7c50c3155341e.tar.gz
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.
-rw-r--r--configure.ac2
-rw-r--r--glib/gthread-posix.c11
-rw-r--r--glib/tests/thread.c10
3 files changed, 8 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index b2ef4455f..86ca32e44 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 184cdf9ea..9e49e9ce6 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 11d847b78..707485ef4 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;