Skip to content

Commit 2f016c4

Browse files
Abseil Teamcopybara-github
authored andcommitted
Move the Arm implementation of UnscaledCycleClock::Now() into the header file, like the x86 implementation, so it can be more easily inlined.
PiperOrigin-RevId: 713382023 Change-Id: I2d65116865f1ebc310b9779991f5dd6f01aad77c
1 parent 65b7da1 commit 2f016c4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

absl/base/internal/unscaledcycleclock.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ double UnscaledCycleClock::Frequency() {
105105

106106
#elif defined(__aarch64__)
107107

108-
// System timer of ARMv8 runs at a different frequency than the CPU's.
109-
// The frequency is fixed, typically in the range 1-50MHz. It can be
110-
// read at CNTFRQ special register. We assume the OS has set up
111-
// the virtual timer properly.
112-
int64_t UnscaledCycleClock::Now() {
113-
int64_t virtual_timer_value;
114-
asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
115-
return virtual_timer_value;
116-
}
117-
118108
double UnscaledCycleClock::Frequency() {
119109
uint64_t aarch64_timer_frequency;
120110
asm volatile("mrs %0, cntfrq_el0" : "=r"(aarch64_timer_frequency));

absl/base/internal/unscaledcycleclock.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ inline int64_t UnscaledCycleClock::Now() {
8585
return static_cast<int64_t>((high << 32) | low);
8686
}
8787

88+
#elif defined(__aarch64__)
89+
90+
// System timer of ARMv8 runs at a different frequency than the CPU's.
91+
// The frequency is fixed, typically in the range 1-50MHz. It can be
92+
// read at CNTFRQ special register. We assume the OS has set up
93+
// the virtual timer properly.
94+
inline int64_t UnscaledCycleClock::Now() {
95+
int64_t virtual_timer_value;
96+
asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
97+
return virtual_timer_value;
98+
}
99+
88100
#endif
89101

90102
} // namespace base_internal

0 commit comments

Comments
 (0)