Skip to content

Commit

Permalink
Merge pull request #7 from amigan/freebsd
Browse files Browse the repository at this point in the history
Fix build on FreeBSD.
  • Loading branch information
synesthesiam authored Oct 18, 2023
2 parents caec324 + 30a7ebe commit 7be98ca
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
20 changes: 20 additions & 0 deletions webrtc-audio-processing/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#include <sys/syscall.h>
#endif

#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
#include <pthread_np.h>
#elif defined(__NetBSD__) // WEBRTC_BSD
#include <lwp.h>
#endif

#if defined(WEBRTC_WIN)
#include "rtc_base/arraysize.h"

Expand All @@ -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<PlatformThreadId>(pthread_self());
#else
Expand Down Expand Up @@ -111,6 +123,10 @@ void SetCurrentThreadName(const char* name) {
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(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
}

Expand Down

0 comments on commit 7be98ca

Please sign in to comment.