summaryrefslogtreecommitdiff
path: root/absl/base/internal/cycleclock.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-26 18:43:11 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-26 18:44:06 -0700
commitdf19c209961b44299aa047d7db0d3972d94a2d0b (patch)
tree5289010d9a0f1afd914c7e0a22657acb573e1772 /absl/base/internal/cycleclock.h
parent1cd889767e518d1bbb1bf8b226ee2c4dd3e85390 (diff)
Split configuration related to cycle clock into separate headers
PiperOrigin-RevId: 477043101 Change-Id: I009ea39ad61e7e78cdac51afc57a8ad5b4d8aa2d
Diffstat (limited to 'absl/base/internal/cycleclock.h')
-rw-r--r--absl/base/internal/cycleclock.h21
1 files changed, 3 insertions, 18 deletions
diff --git a/absl/base/internal/cycleclock.h b/absl/base/internal/cycleclock.h
index 9704e388..cbfdf579 100644
--- a/absl/base/internal/cycleclock.h
+++ b/absl/base/internal/cycleclock.h
@@ -47,6 +47,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
+#include "absl/base/internal/cycleclock_config.h"
#include "absl/base/internal/unscaledcycleclock.h"
namespace absl {
@@ -76,25 +77,9 @@ class CycleClock {
#if ABSL_USE_UNSCALED_CYCLECLOCK
static CycleClockSourceFunc LoadCycleClockSource();
-#ifdef NDEBUG
-#ifdef ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
- // Not debug mode and the UnscaledCycleClock frequency is the CPU
- // frequency. Scale the CycleClock to prevent overflow if someone
- // tries to represent the time as cycles since the Unix epoch.
- static constexpr int32_t kShift = 1;
-#else
- // Not debug mode and the UnscaledCycleClock isn't operating at the
- // raw CPU frequency. There is no need to do any scaling, so don't
- // needlessly sacrifice precision.
- static constexpr int32_t kShift = 0;
-#endif
-#else // NDEBUG
- // In debug mode use a different shift to discourage depending on a
- // particular shift value.
- static constexpr int32_t kShift = 2;
-#endif // NDEBUG
+ static constexpr int32_t kShift = kCycleClockShift;
+ static constexpr double kFrequencyScale = kCycleClockFrequencyScale;
- static constexpr double kFrequencyScale = 1.0 / (1 << kShift);
ABSL_CONST_INIT static std::atomic<CycleClockSourceFunc> cycle_clock_source_;
#endif // ABSL_USE_UNSCALED_CYCLECLOC