From c23acb9b5636e7b908fba03d6b3584d8f80dba6d Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 12 Apr 2023 13:26:48 -0700 Subject: Synchronization: Consolidate the logic for whether steady clocks are supported for relative timeouts PiperOrigin-RevId: 523789416 Change-Id: Ide4cfdcae9ea7bffca3355c80ea9c8833a9536e6 --- absl/synchronization/internal/kernel_timeout.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'absl/synchronization/internal/kernel_timeout.cc') diff --git a/absl/synchronization/internal/kernel_timeout.cc b/absl/synchronization/internal/kernel_timeout.cc index bfbf282f..48ea6287 100644 --- a/absl/synchronization/internal/kernel_timeout.cc +++ b/absl/synchronization/internal/kernel_timeout.cc @@ -21,9 +21,13 @@ #include #include // NOLINT(build/c++11) #include +#include +#include #include #include +#include "absl/base/attributes.h" +#include "absl/base/call_once.h" #include "absl/base/config.h" #include "absl/time/time.h" @@ -37,15 +41,12 @@ constexpr int64_t KernelTimeout::kMaxNanos; #endif int64_t KernelTimeout::SteadyClockNow() { -#ifdef __GOOGLE_GRTE_VERSION__ - // go/btm requires synchronized clocks, so we have to use the system - // clock. - return absl::GetCurrentTimeNanos(); -#else + if (!SupportsSteadyClock()) { + return absl::GetCurrentTimeNanos(); + } return std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()) .count(); -#endif } KernelTimeout::KernelTimeout(absl::Time t) { -- cgit v1.2.3