From 30a7ebef629447de120a7de33380f02556505e47 Mon Sep 17 00:00:00 2001 From: Dan Ponte Date: Thu, 5 Oct 2023 10:38:36 -0400 Subject: [PATCH] Fix build on FreeBSD. Apply https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/commit/2083c9a5dd3482caee59544c1ffa9700c473e978 --- setup.py | 2 ++ webrtc-audio-processing/meson.build | 20 +++++++++++++++++++ .../rtc_base/platform_thread_types.cc | 16 +++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/setup.py b/setup.py index 031cf5d..fdda7b3 100644 --- a/setup.py +++ b/setup.py @@ -380,6 +380,8 @@ "'-D_USE_MATH_DEFINES'", ] libraries += ["winmm"] +elif system == "freebsd": + system_cflags += ["-DWEBRTC_BSD", "-DWEBRTC_THREAD_RR", "-DWEBRTC_POSIX"] else: raise ValueError(f"Unsupported system: {system}") diff --git a/webrtc-audio-processing/meson.build b/webrtc-audio-processing/meson.build index 3843e92..bd2decf 100644 --- a/webrtc-audio-processing/meson.build +++ b/webrtc-audio-processing/meson.build @@ -91,6 +91,26 @@ 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 == '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 == '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 == '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__'] # this one is for MinGW to get format specifiers from inttypes.h in C++ diff --git a/webrtc-audio-processing/webrtc-audio-processing-1/rtc_base/platform_thread_types.cc b/webrtc-audio-processing/webrtc-audio-processing-1/rtc_base/platform_thread_types.cc index ea1dd61..e4861e9 100644 --- a/webrtc-audio-processing/webrtc-audio-processing-1/rtc_base/platform_thread_types.cc +++ b/webrtc-audio-processing/webrtc-audio-processing-1/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 @@ -111,6 +123,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 }