Merge pull request #10638 from brad0/cmake_pthread_set_name

Add tests for pthread_set_name_np() and pthread_setname_np()
This commit is contained in:
Alvar 2025-11-27 12:07:27 +00:00 committed by GitHub
commit c4127d1d61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -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)

View file

@ -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

View file

@ -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__ */