[commit: ghc] master: Add a configure test for pthread_setname_np (4b69d96)
git at git.haskell.org
git at git.haskell.org
Tue Oct 14 19:08:23 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/4b69d96b3d2758bbc06c58ea44a975c6e08d7400/ghc
>---------------------------------------------------------------
commit 4b69d96b3d2758bbc06c58ea44a975c6e08d7400
Author: Simon Marlow <marlowsd at gmail.com>
Date: Mon Oct 13 18:30:30 2014 +0100
Add a configure test for pthread_setname_np
>---------------------------------------------------------------
4b69d96b3d2758bbc06c58ea44a975c6e08d7400
configure.ac | 16 ++++++++++++++++
rts/posix/OSThreads.c | 2 ++
2 files changed, 18 insertions(+)
diff --git a/configure.ac b/configure.ac
index f992c0d..7bd599f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -896,6 +896,22 @@ AC_TRY_LINK_FUNC(printf\$LDBLStub,
[Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
])
+dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
+dnl a different single-argument version.
+AC_CHECK_LIB(pthread, pthread_setname_np)
+AC_MSG_CHECKING(for pthread_setname_np)
+AC_TRY_LINK(
+[
+#define _GNU_SOURCE
+#include <pthread.h>
+],
+[pthread_setname_np(pthread_self(), "name");],
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
+ [Define to 1 if you have the glibc version of pthread_setname_np]),
+ AC_MSG_RESULT(no)
+)
+
dnl ** check for eventfd which is needed by the I/O manager
AC_CHECK_HEADERS([sys/eventfd.h])
AC_CHECK_FUNCS([eventfd])
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index e880b89..fb6d9d4 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -135,7 +135,9 @@ createOSThread (OSThreadId* pId, char *name,
int result = pthread_create(pId, NULL, (void *(*)(void *))startProc, param);
if (!result) {
pthread_detach(*pId);
+#if HAVE_PTHREAD_SETNAME_NP
pthread_setname_np(*pId, name);
+#endif
}
return result;
}
More information about the ghc-commits
mailing list