Commit 8e456850 by Derek Mauro Committed by Copybara-Service

Disable the use of the fast GetCurrentTimeNanos() algorithm based on

the cyclecounter by default, since it may be unsafe in some situations
(for example, if the system may enter a sleep state).

Fixes #1460

PiperOrigin-RevId: 535641718
Change-Id: I41c9cc4bc7a8ae7280ff9df00abd57668205045b
parent 0f718c56
...@@ -48,17 +48,16 @@ Time Now() { ...@@ -48,17 +48,16 @@ Time Now() {
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
// Decide if we should use the fast GetCurrentTimeNanos() algorithm // Decide if we should use the fast GetCurrentTimeNanos() algorithm based on the
// based on the cyclecounter, otherwise just get the time directly // cyclecounter, otherwise just get the time directly from the OS on every call.
// from the OS on every call. This can be chosen at compile-time via // By default, the fast algorithm based on the cyclecount is disabled because in
// certain situations, for example, if the OS enters a "sleep" mode, it may
// produce incorrect values immediately upon waking.
// This can be chosen at compile-time via
// -DABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS=[0|1] // -DABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS=[0|1]
#ifndef ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS #ifndef ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS
#if ABSL_USE_UNSCALED_CYCLECLOCK
#define ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS 1
#else
#define ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS 0 #define ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS 0
#endif #endif
#endif
#if defined(__APPLE__) || defined(_WIN32) #if defined(__APPLE__) || defined(_WIN32)
#include "absl/time/internal/get_current_time_chrono.inc" #include "absl/time/internal/get_current_time_chrono.inc"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment