diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-09-18 08:27:02 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-09-18 10:27:55 +0200 |
commit | 5f4d64f4f3ca633a147eda995ab6613a446a4f0e (patch) | |
tree | 61882f396e990a342536a40ab9b95d27276de7b0 /drivers/unix/thread_posix.cpp | |
parent | 2d9b409103f8bb0ee565b40cc3d4709939862e56 (diff) |
Linux/BSD: Fix support for NetBSD
Add __NetBSD__ to `platform_config.h` so that it can find `alloca`
and use the proper `pthread_setname_np` format.
Rename RANDOM_MAX to avoid conflict with NetBSD stdlib.
Fixes #42145.
Diffstat (limited to 'drivers/unix/thread_posix.cpp')
-rw-r--r-- | drivers/unix/thread_posix.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index aa1b5019ca..285088342b 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -29,17 +29,17 @@ /*************************************************************************/ #include "thread_posix.h" -#include "core/script_language.h" #if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(NO_THREADS) +#include "core/os/memory.h" +#include "core/safe_refcount.h" +#include "core/script_language.h" + #ifdef PTHREAD_BSD_SET_NAME #include <pthread_np.h> #endif -#include "core/os/memory.h" -#include "core/safe_refcount.h" - static void _thread_id_key_destr_callback(void *p_value) { memdelete(static_cast<Thread::ID *>(p_value)); } @@ -126,6 +126,8 @@ Error ThreadPosix::set_name_func_posix(const String &p_name) { #ifdef PTHREAD_BSD_SET_NAME pthread_set_name_np(running_thread, p_name.utf8().get_data()); int err = 0; // Open/FreeBSD ignore errors in this function +#elif defined(PTHREAD_NETBSD_SET_NAME) + int err = pthread_setname_np(running_thread, "%s", const_cast<char *>(p_name.utf8().get_data())); #else int err = pthread_setname_np(running_thread, p_name.utf8().get_data()); #endif // PTHREAD_BSD_SET_NAME |