about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-02-21 12:27:26 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-02-21 12:27:53 +0100
commit0d43b16fd5b6e9dbd3b6683843d8b3c1df4f7c8b (patch)
tree81c0d88144bc07e6d60fc4fc7c8d2879b039919f /src/emu
parentb179bd24154f890fe28e44c94dd667ea99ccbf45 (diff)
downloadbox64-0d43b16fd5b6e9dbd3b6683843d8b3c1df4f7c8b.tar.gz
box64-0d43b16fd5b6e9dbd3b6683843d8b3c1df4f7c8b.zip
[ARM64] Used Hardware counter for RDTSC emulation ([ARM64_DYNAREC] too)
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/x64emu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c
index 38f2f20a..77626fdc 100644
--- a/src/emu/x64emu.c
+++ b/src/emu/x64emu.c
@@ -585,9 +585,13 @@ uint64_t ReadTSC(x64emu_t* emu)
     
     //TODO: implement hardware counter read? (only available in kernel space?)
     // Read the TimeStamp Counter as 64bits.
-    // this is supposed to be the number of instructions executed since last reset
+    // this is supposed to be the number of cycle executed since last reset
     // fall back to gettime...
-#ifndef NOGETCLOCK
+#ifdef ARM64
+    uint64_t val;
+    asm volatile("mrs %0, cntvct_el0" : "=r" (val));
+    return val;
+#elif !defined(NOGETCLOCK)
     struct timespec ts;
     clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
     return (uint64_t)(ts.tv_sec) * 1000000000LL + ts.tv_nsec;