From 2083c9a5dd3482caee59544c1ffa9700c473e978 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 7 Jan 2020 18:08:24 +0000 Subject: [PATCH] Add support for BSD systems In file included from webrtc/rtc_base/platform_thread_types.cc:11: webrtc/rtc_base/platform_thread_types.h:47:1: error: unknown type name 'PlatformThreadId' PlatformThreadId CurrentThreadId(); ^ webrtc/rtc_base/platform_thread_types.h:52:1: error: unknown type name 'PlatformThreadRef' PlatformThreadRef CurrentThreadRef(); ^ webrtc/rtc_base/platform_thread_types.h:55:29: error: unknown type name 'PlatformThreadRef' bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b); ^ webrtc/rtc_base/platform_thread_types.h:55:57: error: unknown type name 'PlatformThreadRef' bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b); ^ webrtc/rtc_base/platform_thread_types.cc:30:1: error: unknown type name 'PlatformThreadId' PlatformThreadId CurrentThreadId() { ^ webrtc/rtc_base/platform_thread_types.cc:51:1: error: unknown type name 'PlatformThreadRef' PlatformThreadRef CurrentThreadRef() { ^ webrtc/rtc_base/platform_thread_types.cc:61:29: error: unknown type name 'PlatformThreadRef' bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) { ^ webrtc/rtc_base/platform_thread_types.cc:61:57: error: unknown type name 'PlatformThreadRef' bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) { ^ webrtc/rtc_base/time_utils.cc:194:2: error: Unsupported platform. #error Unsupported platform. ^ In file included from webrtc/rtc_base/platform_thread.cc:11: In file included from webrtc/rtc_base/platform_thread.h:22: In file included from webrtc/rtc_base/thread_checker.h:17: In file included from webrtc/rtc_base/synchronization/sequence_checker.h:17: webrtc/rtc_base/synchronization/mutex.h:28:2: error: Unsupported platform. #error Unsupported platform. ^ webrtc/rtc_base/synchronization/mutex.h:52:3: error: unknown type name 'MutexImpl' MutexImpl impl_; ^ --- meson.build | 5 +++++ webrtc/rtc_base/platform_thread_types.cc | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/meson.build b/meson.build index de8cd75..70ba26f 100644 --- a/meson.build +++ b/meson.build @@ -70,6 +70,11 @@ elif host_system == 'linux' os_deps += [cc.find_library('rt', required : false)] os_deps += [dependency('threads')] have_posix = true +elif (host_system == 'dragonfly' or host_system == 'freebsd' or + host_system == 'netbsd' or host_system == 'openbsd') + os_cflags += ['-DWEBRTC_BSD', '-DWEBRTC_THREAD_RR'] + os_deps += [dependency('threads')] + have_posix = true elif host_system == 'windows' platform_cflags += ['-DWEBRTC_WIN', '-D_WIN32', '-U__STRICT_ANSI__'] os_deps += [cc.find_library('winmm')] diff --git a/webrtc/rtc_base/platform_thread_types.cc b/webrtc/rtc_base/platform_thread_types.cc index b0243b4..1315aae 100644 --- a/webrtc/rtc_base/platform_thread_types.cc +++ b/webrtc/rtc_base/platform_thread_types.cc @@ -15,6 +15,12 @@ #include #endif +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) // WEBRTC_BSD +#include +#elif defined(__NetBSD__) // WEBRTC_BSD +#include +#endif + #if defined(WEBRTC_WIN) #include "rtc_base/arraysize.h" @@ -39,6 +45,12 @@ PlatformThreadId CurrentThreadId() { return zx_thread_self(); #elif defined(WEBRTC_LINUX) return syscall(__NR_gettid); +#elif defined(__DragonFly__) || defined(__FreeBSD__) // WEBRTC_BSD + return pthread_getthreadid_np(); +#elif defined(__NetBSD__) // WEBRTC_BSD + return _lwp_self(); +#elif defined(__OpenBSD__) // WEBRTC_BSD + return getthrid(); #elif defined(__EMSCRIPTEN__) return static_cast(pthread_self()); #else @@ -109,6 +121,10 @@ void SetCurrentThreadName(const char* name) { prctl(PR_SET_NAME, reinterpret_cast(name)); // NOLINT #elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS) pthread_setname_np(name); +#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) // WEBRTC_BSD + pthread_set_name_np(pthread_self(), name); +#elif defined(__NetBSD__) // WEBRTC_BSD + pthread_setname_np(pthread_self(), "%s", (void*)name); #endif } -- GitLab