Build fix: Check if pthread_setname_np() is available.

This commit is contained in:
Gunnar Beutner 2013-09-08 13:13:37 +02:00
parent df729d5514
commit 161c933edc
2 changed files with 13 additions and 6 deletions

View File

@ -52,6 +52,9 @@ AD_INIT_ASCIIDOC([icinga], [docs])
AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
CFLAGS="$CFLAGS -D_GNU_SOURCE -pthread"
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE -pthread"
AC_PROG_INSTALL
AC_PROG_LEX
AC_PROG_YACC
@ -71,7 +74,7 @@ AC_CHECK_LIB(m, floor)
AC_CHECK_LIB(socket, getsockname)
AC_CHECK_LIB(ws2_32, getsockname)
AC_CHECK_LIB(shlwapi, PathRemoveFileSpecA)
AC_CHECK_FUNCS([backtrace_symbols execvpe pipe2])
AC_CHECK_FUNCS([backtrace_symbols execvpe pipe2 pthread_set_name_np pthread_setname_np])
CFLAGS="$CFLAGS -Wall -Wextra"
CXXFLAGS="$CXXFLAGS -Wall -Wextra"

View File

@ -525,14 +525,18 @@ void Utility::SetThreadName(const String& name, bool os)
WindowsSetThreadName(name.CStr());
#endif /* _WIN32 */
#ifdef HAVE_PTHREAD_SET_NAME_NP
pthread_set_name_np(pthread_self(), name.CStr());
#endif /* HAVE_PTHREAD_SET_NAME_NP */
#ifdef HAVE_PTHREAD_SETNAME_NP
# ifdef __APPLE__
pthread_setname_np(name.CStr());
#endif /* __APPLE__ */
#ifdef __linux__
# else /* __APPLE__ */
String tname = name.SubStr(0, 15);
pthread_setname_np(pthread_self(), tname.CStr());
#endif /* __linux__ */
# endif /* __APPLE__ */
#endif /* HAVE_PTHREAD_SETNAME_NP */
}
String Utility::GetThreadName(void)