diff options
author | Owen Rudge <owen@owenrudge.net> | 2020-12-11 15:20:13 +0000 |
---|---|---|
committer | Owen Rudge <owen@owenrudge.net> | 2021-01-18 08:57:58 +0000 |
commit | 6d95ed53dc81a2951585c5bf94a5dba77842c8f0 (patch) | |
tree | 90d0f9fe38f8b4adb28785cea0b144fa70268e21 | |
parent | 2d9e164ec47aac60c48e9dce29753ab2df8e4ba0 (diff) | |
download | openttd-6d95ed53dc81a2951585c5bf94a5dba77842c8f0.tar.xz |
Feature: Add support for rdtsc for ARM-based Windows (MSVC)
-rw-r--r-- | src/cpu.cpp | 9 |
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 |