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.
This commit is contained in:
Matthias Clasen 2016-04-26 06:35:06 -04:00
parent 28f0160031
commit 99bdfd1bcb
3 changed files with 8 additions and 15 deletions

View File

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

View File

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

View File

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