From aca9a23c83838997f22b9f6e6f9b6fc98f8b4705 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 10 May 2023 07:41:38 -0400 Subject: [PATCH] fixed OpenBSD support (#921) - Usage of syscall() is not allowed - Use getthrid() to retreive the thread ID --- src/raw_logging.cc | 3 ++- src/utilities.cc | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/raw_logging.cc b/src/raw_logging.cc index 9e6cf17..540ec66 100644 --- a/src/raw_logging.cc +++ b/src/raw_logging.cc @@ -60,7 +60,8 @@ #endif #if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \ - (!(defined(GLOG_OS_MACOSX))) && !defined(GLOG_OS_EMSCRIPTEN) + (!(defined(GLOG_OS_MACOSX)) && !(defined(GLOG_OS_OPENBSD))) && \ + !defined(GLOG_OS_EMSCRIPTEN) #define safe_write(fd, s, len) syscall(SYS_write, fd, s, len) #else // Not so safe, but what can you do? diff --git a/src/utilities.cc b/src/utilities.cc index 8b0a1ea..f825470 100644 --- a/src/utilities.cc +++ b/src/utilities.cc @@ -292,6 +292,8 @@ pid_t GetTID() { return getpid(); // Linux: getpid returns thread ID when gettid is absent #elif defined GLOG_OS_WINDOWS && !defined GLOG_OS_CYGWIN return static_cast(GetCurrentThreadId()); +#elif defined GLOG_OS_OPENBSD + return getthrid(); #elif defined(HAVE_PTHREAD) // If none of the techniques above worked, we use pthread_self(). return (pid_t)(uintptr_t)pthread_self();