Skip to content

Commit

Permalink
rtc_base: define PlatformThread{Id,Ref} on OpenBSD
Browse files Browse the repository at this point in the history
pthread_self(3) returns a phtread_t (aka. pthread *) value.
  • Loading branch information
klemensn committed Dec 15, 2021
1 parent 442e338 commit 70e26fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rtc_base/platform_thread_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ typedef HRESULT(WINAPI* RTC_SetThreadDescription)(HANDLE hThread,
#if defined(WEBRTC_FREEBSD)
#include <sys/thr.h>
#include <pthread_np.h>
#elif defined(WEBRTC_OPENBSD)
#include <pthread_np.h>
#endif

namespace rtc {
Expand All @@ -51,7 +53,7 @@ PlatformThreadId CurrentThreadId() {
#elif defined(__EMSCRIPTEN__)
return static_cast<PlatformThreadId>(pthread_self());
#else
// Default implementation for nacl and solaris.
// Default implementation for nacl, openbsd and solaris.
return reinterpret_cast<PlatformThreadId>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
Expand Down Expand Up @@ -118,6 +120,8 @@ void SetCurrentThreadName(const char* name) {
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name)); // NOLINT
#elif defined(WEBRTC_FREEBSD)
pthread_setname_np(pthread_self(), name);
#elif defined(WEBRTC_OPENBSD)
pthread_set_name_np(pthread_self(), name);
#elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
pthread_setname_np(name);
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/rtc_base/platform_thread_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#elif defined(WEBRTC_FUCHSIA)
#include <zircon/types.h>
#include <zircon/process.h>
#elif defined(WEBRTC_OPENBSD)
#include <pthread.h>
#elif defined(WEBRTC_POSIX)
#include <pthread.h>
#include <unistd.h>
Expand All @@ -38,6 +40,9 @@ typedef DWORD PlatformThreadRef;
#elif defined(WEBRTC_FUCHSIA)
typedef zx_handle_t PlatformThreadId;
typedef zx_handle_t PlatformThreadRef;
#elif defined(WEBRTC_OPENBSD)
typedef uint64_t PlatformThreadId;
typedef pthread_t PlatformThreadRef;
#elif defined(WEBRTC_POSIX)
typedef pid_t PlatformThreadId;
typedef pthread_t PlatformThreadRef;
Expand Down

0 comments on commit 70e26fe

Please sign in to comment.