From cf8fc3d64fce55e363b556fa6ade28dcd34e0307 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Tue, 25 Nov 2025 11:31:32 -0500 Subject: [PATCH] Add tests for pthread_set_name_np() and pthread_setname_np() Looks like the conversion from autoconf to CMake dropped these tests along the way. --- CMakeLists.txt | 2 ++ config.h.cmake | 2 ++ lib/base/utility.cpp | 4 +--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef59d95de..e4386cedf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,6 +371,8 @@ check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS) check_function_exists(pipe2 HAVE_PIPE2) check_function_exists(nice HAVE_NICE) check_function_exists(malloc_info HAVE_MALLOC_INFO) +check_function_exists(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP) +check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP) check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR) check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO) check_include_file_cxx(cxxabi.h HAVE_CXXABI_H) diff --git a/config.h.cmake b/config.h.cmake index 02ab9d7a0..2bfadb4a0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -9,6 +9,8 @@ #cmakedefine HAVE_CXXABI_H #cmakedefine HAVE_NICE #cmakedefine HAVE_MALLOC_INFO +#cmakedefine HAVE_PTHREAD_SET_NAME_NP +#cmakedefine HAVE_PTHREAD_SETNAME_NP #cmakedefine HAVE_EDITLINE #cmakedefine HAVE_SYSTEMD diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index 7189f5a24..658c781e4 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -1320,9 +1320,7 @@ void Utility::SetThreadName(const String& name, bool os) #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 +#elif defined(HAVE_PTHREAD_SETNAME_NP) /* HAVE_PTHREAD_SET_NAME_NP */ # ifdef __APPLE__ pthread_setname_np(name.CStr()); # else /* __APPLE__ */