diff options
author | Derek Mauro <dmauro@google.com> | 2023-09-06 13:30:04 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-09-06 13:32:37 -0700 |
commit | b9707b7d7845f9710ae6d5906827b833fdcc2754 (patch) | |
tree | cdb0b65145f46b7207e7e8656df5af24b2ed97fb /absl/base/internal | |
parent | a74b796ab3f114f6991479c9ad9e4c1a0dad3a4b (diff) |
Use native methods to implement absl::base_internal::GetPID() on
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
https://github.com/abseil/abseil-cpp/commit/88cc63ef739d83277b492e881be72e9069fcb1fe
Fixes #1518
PiperOrigin-RevId: 563200172
Change-Id: Ifd1b65c84e3631075248bc2e01b8f047dc72d201
Diffstat (limited to 'absl/base/internal')
-rw-r--r-- | absl/base/internal/sysinfo.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc index 8bcc4faf..5b427fa5 100644 --- a/absl/base/internal/sysinfo.cc +++ b/absl/base/internal/sysinfo.cc @@ -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 @@ -421,7 +429,7 @@ pid_t GetTID() { return tid; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) pid_t GetTID() { uint64_t tid; @@ -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() { |