From e487480ca94ccbfa07e55e561ddca1f28747294d Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 12 Mar 2018 20:13:49 +0000 Subject: [PATCH] Thread: unbreak build on BSDs after ac82ecf387c6 Utilities/Thread.cpp:1644:2: error: use of undeclared identifier 'pthread_setname_np'; did you mean 'pthread_set_name_np'? pthread_setname_np(pthread_self(), m_name.substr(0, 15).c_str()); ^~~~~~~~~~~~~~~~~~ pthread_set_name_np /usr/include/pthread_np.h:58:6: note: 'pthread_set_name_np' declared here void pthread_set_name_np(pthread_t, const char *); ^ --- Utilities/Thread.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 5dd766f729..52299871d5 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -21,7 +21,7 @@ #include #include #endif -#if defined(__DragonFly__) || defined(__FreeBSD__) +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include #define cpu_set_t cpuset_t #endif @@ -1640,7 +1640,13 @@ void thread_ctrl::initialize() } #endif -#ifndef _WIN32 +#if defined(__APPLE__) + pthread_setname_np(m_name.substr(0, 15).c_str()); +#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) + pthread_set_name_np(pthread_self(), m_name.c_str()); +#elif defined(__NetBSD__) + pthread_setname_np(pthread_self(), "%s", (void*)m_name.c_str()); +#elif !defined(_WIN32) pthread_setname_np(pthread_self(), m_name.substr(0, 15).c_str()); #endif }