Pull commit eeb67bcec3 from GZDoom: Use RDTSC equivalent on AARCH64.

This commit is contained in:
Rachael Alexanderson 2022-03-25 14:56:51 -04:00
parent 26179c56cf
commit 16c81f0b1f
2 changed files with 16 additions and 6 deletions

View file

@ -144,7 +144,15 @@ void CalculateCPUSpeed()
{
PerfAvailable = false;
PerfToMillisec = PerfToSec = 0.;
#ifdef __linux__
#ifdef __aarch64__
// [MK] on aarch64 rather than having to calculate cpu speed, there is
// already an independent frequency for the perf timer
uint64_t frq;
asm volatile("mrs %0, cntfrq_el0":"=r"(frq));
PerfAvailable = true;
PerfToSec = 1./frq;
PerfToMillisec = PerfToSec*1000.;
#elif defined(__linux__)
// [MK] read from perf values if we can
struct perf_event_attr pe;
memset(&pe,0,sizeof(struct perf_event_attr));