From b9707b7d7845f9710ae6d5906827b833fdcc2754 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 6 Sep 2023 13:30:04 -0700 Subject: 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 --- absl/base/internal/sysinfo.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'absl/base/internal') 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 #endif +#ifdef __FreeBSD__ +#include +#endif + +#ifdef __NetBSD__ +#include +#endif + #if defined(__myriad2__) #include #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(tid); } +#elif defined(__OpenBSD__) + +pid_t GetTID() { return getthrid(); } + +#elif defined(__NetBSD__) + +pid_t GetTID() { return static_cast(_lwp_self()); } + #elif defined(__native_client__) pid_t GetTID() { -- cgit v1.2.3