summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOwen Rudge <owen@owenrudge.net>2020-12-11 15:20:13 +0000
committerOwen Rudge <owen@owenrudge.net>2021-01-18 08:57:58 +0000
commit6d95ed53dc81a2951585c5bf94a5dba77842c8f0 (patch)
tree90d0f9fe38f8b4adb28785cea0b144fa70268e21 /src
parent2d9e164ec47aac60c48e9dce29753ab2df8e4ba0 (diff)
downloadopenttd-6d95ed53dc81a2951585c5bf94a5dba77842c8f0.tar.xz
Feature: Add support for rdtsc for ARM-based Windows (MSVC)
Diffstat (limited to 'src')
-rw-r--r--src/cpu.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cpu.cpp b/src/cpu.cpp
index bafa0f735..b93f0fa5e 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -16,11 +16,18 @@
/* rdtsc for MSC_VER, uses simple inline assembly, or _rdtsc
* from external win64.asm because VS2005 does not support inline assembly */
-#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && !defined(RDTSC_AVAILABLE)
+#if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE)
#include <intrin.h>
+#include <windows.h>
uint64 ottd_rdtsc()
{
+#if defined(_M_ARM)
+ return __rdpmccntr64();
+#elif defined(_M_ARM64)
+ return _ReadStatusReg(ARM64_PMCCNTR_EL0);
+#else
return __rdtsc();
+#endif
}
#define RDTSC_AVAILABLE
#endif