Skip to content

Commit

Permalink
Use native methods to implement absl::base_internal::GetPID() on
Browse files Browse the repository at this point in the history
FreeBSD, NetBSD, and OpenBSD

https://man.freebsd.org/cgi/man.cgi?query=pthread_getthreadid_np
https://man.netbsd.org/_lwp_self.2
https://man.openbsd.org/getthrid.2

This fixes a build break caused by
88cc63e

Fixes #1518

PiperOrigin-RevId: 563200172
Change-Id: Ifd1b65c84e3631075248bc2e01b8f047dc72d201
  • Loading branch information
derekmauro authored and Copybara-Service committed Sep 6, 2023
1 parent a74b796 commit b9707b7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion absl/base/internal/sysinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#include <sys/sysctl.h>
#endif

#ifdef __FreeBSD__
#include <pthread_np.h>
#endif

#ifdef __NetBSD__
#include <lwp.h>
#endif

#if defined(__myriad2__)
#include <rtems.h>
#endif
Expand Down Expand Up @@ -421,7 +429,7 @@ pid_t GetTID() {
return tid;
}

#elif defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__)

pid_t GetTID() {
uint64_t tid;
Expand All @@ -432,6 +440,14 @@ pid_t GetTID() {
return static_cast<pid_t>(tid);
}

#elif defined(__OpenBSD__)

pid_t GetTID() { return getthrid(); }

#elif defined(__NetBSD__)

pid_t GetTID() { return static_cast<pid_t>(_lwp_self()); }

#elif defined(__native_client__)

pid_t GetTID() {
Expand Down

0 comments on commit b9707b7

Please sign in to comment.