Detect pthread_getname_np explicitly.
At least one libc (musl) defines pthread_setname_np without defining pthread_getname_np. Detect the presence of each individually, rather than inferring both must be defined if set is.
This commit is contained in:
parent
b3c5690b7e
commit
95f0a77fde
31
configure.ac
31
configure.ac
@ -1745,6 +1745,37 @@ dnl Check if we have dlsym support.
|
||||
if test "x${je_cv_pthread_setname_np}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETNAME_NP], [ ])
|
||||
fi
|
||||
dnl Check if pthread_getname_np is not necessarily present despite
|
||||
dnl the pthread_setname_np counterpart
|
||||
JE_COMPILABLE([pthread_getname_np(3)], [
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
], [
|
||||
{
|
||||
char *name = malloc(16);
|
||||
pthread_getname_np(pthread_self(), name, 16);
|
||||
free(name);
|
||||
}
|
||||
], [je_cv_pthread_getname_np])
|
||||
if test "x${je_cv_pthread_getname_np}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_HAVE_PTHREAD_GETNAME_NP], [ ])
|
||||
fi
|
||||
dnl Check if pthread_get_name_np is not necessarily present despite
|
||||
dnl the pthread_set_name_np counterpart
|
||||
JE_COMPILABLE([pthread_get_name_np(3)], [
|
||||
#include <pthread.h>
|
||||
#include <pthread_np.h>
|
||||
#include <stdlib.h>
|
||||
], [
|
||||
{
|
||||
char *name = malloc(16);
|
||||
pthread_get_name_np(pthread_self(), name, 16);
|
||||
free(name);
|
||||
}
|
||||
], [je_cv_pthread_get_name_np])
|
||||
if test "x${je_cv_pthread_get_name_np}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_HAVE_PTHREAD_GET_NAME_NP], [ ])
|
||||
fi
|
||||
fi
|
||||
|
||||
JE_APPEND_VS(CPPFLAGS, -D_REENTRANT)
|
||||
|
@ -85,6 +85,12 @@
|
||||
/* Defined if pthread_setname_np(3) is available. */
|
||||
#undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
|
||||
/* Defined if pthread_getname_np(3) is available. */
|
||||
#undef JEMALLOC_HAVE_PTHREAD_GETNAME_NP
|
||||
|
||||
/* Defined if pthread_get_name_np(3) is available. */
|
||||
#undef JEMALLOC_HAVE_PTHREAD_GET_NAME_NP
|
||||
|
||||
/*
|
||||
* Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
|
||||
*/
|
||||
|
@ -292,8 +292,11 @@ void prof_unwind_init() {
|
||||
|
||||
static int
|
||||
prof_sys_thread_name_read_impl(char *buf, size_t limit) {
|
||||
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
#if defined(JEMALLOC_HAVE_PTHREAD_GETNAME_NP)
|
||||
return pthread_getname_np(pthread_self(), buf, limit);
|
||||
#elif defined(JEMALLOC_HAVE_PTHREAD_GET_NAME_NP)
|
||||
pthread_get_name_np(pthread_self(), buf, limit);
|
||||
return 0;
|
||||
#else
|
||||
return ENOSYS;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user