diff options
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/BUILD.bazel | 2 | ||||
-rw-r--r-- | absl/debugging/CMakeLists.txt | 2 | ||||
-rw-r--r-- | absl/debugging/failure_signal_handler.cc | 4 | ||||
-rw-r--r-- | absl/debugging/internal/address_is_readable.cc | 5 |
4 files changed, 9 insertions, 4 deletions
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel index a01408910ac4..8f521bec4692 100644 --- a/absl/debugging/BUILD.bazel +++ b/absl/debugging/BUILD.bazel @@ -134,6 +134,7 @@ cc_library( "//absl/base", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:errno_saver", "//absl/base:raw_logging_internal", ], ) @@ -174,6 +175,7 @@ cc_library( "//absl/base:config", "//absl/base:core_headers", "//absl/base:dynamic_annotations", + "//absl/base:errno_saver", "//absl/base:raw_logging_internal", ], ) diff --git a/absl/debugging/CMakeLists.txt b/absl/debugging/CMakeLists.txt index 66886c7a0949..77336159393d 100644 --- a/absl/debugging/CMakeLists.txt +++ b/absl/debugging/CMakeLists.txt @@ -118,6 +118,7 @@ absl_cc_library( absl::base absl::config absl::core_headers + absl::errno_saver absl::raw_logging_internal PUBLIC ) @@ -156,6 +157,7 @@ absl_cc_library( absl::core_headers absl::config absl::dynamic_annotations + absl::errno_saver absl::raw_logging_internal ) diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index cd141ecf5d32..1f69bfa84dd9 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc @@ -41,6 +41,7 @@ #include <ctime> #include "absl/base/attributes.h" +#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/sysinfo.h" #include "absl/debugging/internal/examine_stack.h" @@ -214,9 +215,8 @@ static void InstallOneFailureHandler(FailureSignalData* data, #endif static void WriteToStderr(const char* data) { - int old_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; absl::raw_logging_internal::SafeWriteToStderr(data, strlen(data)); - errno = old_errno; } static void WriteSignalMessage(int signo, void (*writerfn)(const char*)) { diff --git a/absl/debugging/internal/address_is_readable.cc b/absl/debugging/internal/address_is_readable.cc index f45e59b3836a..65376063669f 100644 --- a/absl/debugging/internal/address_is_readable.cc +++ b/absl/debugging/internal/address_is_readable.cc @@ -35,10 +35,12 @@ ABSL_NAMESPACE_END #include <fcntl.h> #include <sys/syscall.h> #include <unistd.h> + #include <atomic> #include <cerrno> #include <cstdint> +#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/raw_logging.h" namespace absl { @@ -67,7 +69,7 @@ static void Unpack(uint64_t x, int *pid, int *read_fd, int *write_fd) { // This is a namespace-scoped variable for correct zero-initialization. static std::atomic<uint64_t> pid_and_fds; // initially 0, an invalid pid. bool AddressIsReadable(const void *addr) { - int save_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; // We test whether a byte is readable by using write(). Normally, this would // be done via a cached file descriptor to /dev/null, but linux fails to // check whether the byte is readable when the destination is /dev/null, so @@ -126,7 +128,6 @@ bool AddressIsReadable(const void *addr) { std::memory_order_relaxed); } } while (errno == EBADF); - errno = save_errno; return bytes_written == 1; } |