diff options
author | Theo Buehler <botovq@users.noreply.github.com> | 2023-10-25 09:24:52 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-25 09:25:43 -0700 |
commit | 4a6ea63d35d28785b87c51536aed00362a94c5f9 (patch) | |
tree | 8407bc61f85e86d21128159ce3a8d360a47f8b55 /absl/base/internal | |
parent | b841db22f8d1d9cdbaacecf2e7c87ce270f8d96f (diff) | |
download | abseil-4a6ea63d35d28785b87c51536aed00362a94c5f9.tar.gz abseil-4a6ea63d35d28785b87c51536aed00362a94c5f9.tar.bz2 abseil-4a6ea63d35d28785b87c51536aed00362a94c5f9.zip |
PR #1553: Adapt to syscall(2) removal in OpenBSD
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1553
OpenBSD will remove its generic syscall(2) interface, so setting the ABSL_HAVE_SYSCALL_WRITE define will result in a linking failure soon.
Make direct use of the write(2) syscall instead. OpenBSD's libc does not do any buffering for write, so there is no change of behavior.
A [variant of this patch][1] has been in use since early this year in OpenBSD's ports. There's no need to set ABSL_LOW_LEVEL_WRITE_SUPPORTED since that's already done a few lines up.
[1]: https://github.com/openbsd/ports/commit/5f9e56cd982c1f1fa5af867e56355091e1817786
Merge 0dcc88a3cdab513c598587d85423135e85cec330 into b841db22f8d1d9cdbaacecf2e7c87ce270f8d96f
Merging this change closes #1553
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1553 from botovq:openbsd-syscall 0dcc88a3cdab513c598587d85423135e85cec330
PiperOrigin-RevId: 576552197
Change-Id: I13466703ddc9d50edf87da5d0c291aad642af49a
Diffstat (limited to 'absl/base/internal')
-rw-r--r-- | absl/base/internal/raw_logging.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc index 4c922ccf..69b94265 100644 --- a/absl/base/internal/raw_logging.cc +++ b/absl/base/internal/raw_logging.cc @@ -56,8 +56,7 @@ // ABSL_HAVE_SYSCALL_WRITE is defined when the platform provides the syscall // syscall(SYS_write, /*int*/ fd, /*char* */ buf, /*size_t*/ len); // for low level operations that want to avoid libc. -#if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && \ - !defined(__ANDROID__) +#if (defined(__linux__) || defined(__FreeBSD__)) && !defined(__ANDROID__) #include <sys/syscall.h> #define ABSL_HAVE_SYSCALL_WRITE 1 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1 @@ -93,8 +92,7 @@ constexpr char kTruncated[] = " ... (message truncated)\n"; bool VADoRawLog(char** buf, int* size, const char* format, va_list ap) ABSL_PRINTF_ATTRIBUTE(3, 0); bool VADoRawLog(char** buf, int* size, const char* format, va_list ap) { - if (*size < 0) - return false; + if (*size < 0) return false; int n = vsnprintf(*buf, static_cast<size_t>(*size), format, ap); bool result = true; if (n < 0 || n > *size) { @@ -122,8 +120,7 @@ constexpr int kLogBufSize = 3000; bool DoRawLog(char** buf, int* size, const char* format, ...) ABSL_PRINTF_ATTRIBUTE(3, 4); bool DoRawLog(char** buf, int* size, const char* format, ...) { - if (*size < 0) - return false; + if (*size < 0) return false; va_list ap; va_start(ap, format); int n = vsnprintf(*buf, static_cast<size_t>(*size), format, ap); @@ -242,8 +239,8 @@ void AsyncSignalSafeWriteError(const char* s, size_t len) { _write(/* stderr */ 2, s, static_cast<unsigned>(len)); #else // stderr logging unsupported on this platform - (void) s; - (void) len; + (void)s; + (void)len; #endif } @@ -258,7 +255,7 @@ void RawLog(absl::LogSeverity severity, const char* file, int line, bool RawLoggingFullySupported() { #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED return true; -#else // !ABSL_LOW_LEVEL_WRITE_SUPPORTED +#else // !ABSL_LOW_LEVEL_WRITE_SUPPORTED return false; #endif // !ABSL_LOW_LEVEL_WRITE_SUPPORTED } |