From 5f4d64f4f3ca633a147eda995ab6613a446a4f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 18 Sep 2020 08:27:02 +0200 Subject: 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. --- platform/linuxbsd/platform_config.h | 12 ++++++++++-- platform/server/platform_config.h | 13 +++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'platform') diff --git a/platform/linuxbsd/platform_config.h b/platform/linuxbsd/platform_config.h index 764666681f..571ad03db0 100644 --- a/platform/linuxbsd/platform_config.h +++ b/platform/linuxbsd/platform_config.h @@ -31,7 +31,15 @@ #ifdef __linux__ #include #endif -#if defined(__FreeBSD__) || defined(__OpenBSD__) -#include + +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +#include // alloca +// FreeBSD and OpenBSD use pthread_set_name_np, while other platforms, +// include NetBSD, use pthread_setname_np. NetBSD's version however requires +// a different format, we handle this directly in thread_posix. +#ifdef __NetBSD__ +#define PTHREAD_NETBSD_SET_NAME +#else #define PTHREAD_BSD_SET_NAME #endif +#endif diff --git a/platform/server/platform_config.h b/platform/server/platform_config.h index bdff93f02b..73136ec81b 100644 --- a/platform/server/platform_config.h +++ b/platform/server/platform_config.h @@ -31,10 +31,19 @@ #if defined(__linux__) || defined(__APPLE__) #include #endif -#if defined(__FreeBSD__) || defined(__OpenBSD__) -#include + +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +#include // alloca +// FreeBSD and OpenBSD use pthread_set_name_np, while other platforms, +// include NetBSD, use pthread_setname_np. NetBSD's version however requires +// a different format, we handle this directly in thread_posix. +#ifdef __NetBSD__ +#define PTHREAD_NETBSD_SET_NAME +#else #define PTHREAD_BSD_SET_NAME #endif +#endif + #ifdef __APPLE__ #define PTHREAD_RENAME_SELF #endif -- cgit v1.2.3