From a6c1a5c6d0a1fd92fff3e499ce44ee4b0c5d1db3 Mon Sep 17 00:00:00 2001 From: eska Date: Sat, 9 Jan 2016 15:56:31 +0100 Subject: [PATCH] Fix pthread renaming in Open/FreeBSD --- drivers/unix/thread_posix.cpp | 11 ++++++++++- platform/x11/platform_config.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 21bd95eade3..bd33c812982 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -30,6 +30,10 @@ #if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED) +#ifdef PTHREAD_BSD_SET_NAME +#include +#endif + #include "os/memory.h" Thread::ID ThreadPosix::get_ID() const { @@ -100,9 +104,14 @@ Error ThreadPosix::set_name(const String& p_name) { #else + #ifdef PTHREAD_BSD_SET_NAME + pthread_set_name_np(pthread, p_name.utf8().get_data()); + int err = 0; // Open/FreeBSD ignore errors in this function + #else int err = pthread_setname_np(pthread, p_name.utf8().get_data()); + #endif // PTHREAD_BSD_SET_NAME - #endif + #endif // PTHREAD_RENAME_SELF return err == 0 ? OK : ERR_INVALID_PARAMETER; diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h index 5a333f4a0d5..aac50c27c2e 100644 --- a/platform/x11/platform_config.h +++ b/platform/x11/platform_config.h @@ -31,6 +31,7 @@ #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) #include +#define PTHREAD_BSD_SET_NAME #endif #define GLES2_INCLUDE_H "gl_context/glew.h"