summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-02-06 12:24:15 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-02-06 13:07:25 +0300
commitab91e4e84d166fb7536056ae95d55c00d2ea2f46 (patch)
tree2aeb2809ddd992011880e66b54275f89326281d9 /configure.ac
parent9eddcfa3233581e24676967d5734e5a4f1b2c7be (diff)
downloadbdwgc-ab91e4e84d166fb7536056ae95d55c00d2ea2f46.tar.gz
Set name of GC marker threads
Issue #300 (bdwgc). The threads are named as "GC-marker-<n>". For now, the detection of pthread_setname_np availability and kind is implemented in configure only. On Darwin, the GC mprotect thread name is set too. * configure.ac [$THREADS==posix] (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID, HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG, HAVE_PTHREAD_SETNAME_NP_WITH_TID): Check for pthread_setname_np; set the relevant HAVE_x macro. * include/private/gc_priv.h [__CYGWIN__ && GC_THREADS && !_GNU_SOURCE] (_GNU_SOURCE): Define. * os_dep.c [MPROTECT_VDB && DARWIN && HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID] (GC_mprotect_thread): Call pthread_setname_np(). * pthread_support.c [PARALLEL_MARK] (set_marker_thread_name): Define. * win32_threads.c [PARALLEL_MARK] (set_marker_thread_name): Likewise. * pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Call set_marker_thread_name(id). * win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac31
1 files changed, 31 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 9df8f444..050ad147 100644
--- a/configure.ac
+++ b/configure.ac
@@ -780,6 +780,37 @@ AC_TRY_LINK([#include <setjmp.h>],
AC_DEFINE([GC_NO_SIGSETJMP], [1], [Missing sigsetjmp function.])])
CFLAGS="$old_CFLAGS"
+# pthread_setname_np, if available, may have 1, 2 or 3 arguments.
+AS_IF([test "$THREADS" = posix],
+ [AC_MSG_CHECKING(for pthread_setname_np)
+ old_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_setname_np("thread-name")],
+ [AC_MSG_RESULT([yes (w/o tid)])
+ AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1],
+ [Define to use 'pthread_setname_np(const char*)' function.])],
+ [AC_TRY_LINK([#include <pthread.h>],
+ [pthread_setname_np(pthread_self(), "thread-name-%u", 0)],
+ [AC_MSG_RESULT([yes (with tid and arg)])
+ AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1],
+ [Define to use 'pthread_setname_np(pthread_t, const char*, void *)'
+ function.])],
+ [AC_TRY_LINK([
+#ifdef __CYGWIN__
+#define _GNU_SOURCE 1
+#elif defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)
+#define _GNU_SOURCE 1
+#endif
+#include <pthread.h>],
+ [pthread_setname_np(pthread_self(), "thread-name")],
+ [AC_MSG_RESULT([yes (with tid)])
+ AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID], [1],
+ [Define to use 'pthread_setname_np(pthread_t, const char*)'
+ function.])],
+ [AC_MSG_RESULT(no)])])])
+ CFLAGS="$old_CFLAGS"])
+
# Check for AViiON Machines running DGUX
ac_is_dgux=no
AC_CHECK_HEADER(sys/dg_sys_info.h,