Skip to content

Commit 451b715

Browse files
committed
1 parent 7564a33 commit 451b715

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/cpucounter.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
uint64_t cpucounter(void)
55
{
66
uint64_t low, high;
7-
__asm__ __volatile__ ("rdtscp" : "=a" (low), "=d" (high) : : "%ecx");
7+
__asm__ __volatile__("rdtscp"
8+
: "=a"(low), "=d"(high)
9+
:
10+
: "%ecx");
811
return (high << 32) | low;
912
}
1013
#elif defined(__aarch64__)
1114
uint64_t cpucounter(void)
1215
{
1316
uint64_t virtual_timer_value;
14-
__asm__ __volatile__ ("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
17+
__asm__ __volatile__("mrs %0, cntvct_el0"
18+
: "=r"(virtual_timer_value));
1519
return virtual_timer_value;
1620
}
1721
#endif

src/cpucounter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ unsafe fn cpucounter() -> u64 {
1010
(high << 32) | low
1111
}
1212

13-
1413
// https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
1514
#[cfg(asm)]
1615
#[inline]
1716
#[cfg(any(target_arch = "aarch64"))]
1817
unsafe fn cpucounter() -> u64 {
1918
let (vtm): (u64);
20-
asm!("mrs %0, cntvct_el0" : "=r"(vtm));
19+
//asm!("mrs %0, cntvct_el0" : "=r"(vtm));
20+
asm!("mrs %0, {}", in(cntvct_el0), out(reg) vtm);
2121
vtm
2222
}
2323

0 commit comments

Comments
 (0)