mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
build: check for SetThreadDescription() at configure time
This commit is contained in:
@@ -76,6 +76,9 @@
|
||||
/* Define this symbol if you have posix_fallocate */
|
||||
#cmakedefine HAVE_POSIX_FALLOCATE 1
|
||||
|
||||
/* Define this symbol if you have SetThreadDescription */
|
||||
#cmakedefine HAVE_SETTHREADDESCRIPTION 1
|
||||
|
||||
/* Define this symbol if platform supports unix domain sockets */
|
||||
#cmakedefine HAVE_SOCKADDR_UN 1
|
||||
|
||||
|
||||
@@ -76,6 +76,10 @@ check_cxx_source_compiles("
|
||||
" HAVE_STRONG_GETAUXVAL
|
||||
)
|
||||
|
||||
# Check for SetThreadDescription(), which is missing from mingw-w64 headers
|
||||
# before 12.0.0.
|
||||
check_cxx_symbol_exists(SetThreadDescription "windows.h" HAVE_SETTHREADDESCRIPTION)
|
||||
|
||||
# Check for UNIX sockets.
|
||||
check_cxx_source_compiles("
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bitcoin-build-config.h> // IWYU pragma: keep
|
||||
|
||||
#include <util/threadnames.h>
|
||||
#include <util/check.h>
|
||||
|
||||
@@ -18,7 +20,7 @@
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef HAVE_SETTHREADDESCRIPTION
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -33,7 +35,7 @@ static void SetThreadName(const char* name)
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#elif defined(__APPLE__)
|
||||
pthread_setname_np(name);
|
||||
#elif defined(WIN32)
|
||||
#elif defined(HAVE_SETTHREADDESCRIPTION)
|
||||
// Thread names are ASCII-only, so widening each character is sufficient as
|
||||
// a conversion to UTF-16.
|
||||
const std::wstring wname{name, name + std::strlen(name)};
|
||||
|
||||
Reference in New Issue
Block a user