mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-12 22:02:00 +00:00
Use RDTSC equivalent on AARCH64.
This commit is contained in:
parent
196d2efc86
commit
eeb67bcec3
2 changed files with 16 additions and 6 deletions
|
@ -76,8 +76,9 @@ inline uint64_t rdtsc()
|
||||||
while (upper != temp);
|
while (upper != temp);
|
||||||
return (static_cast<unsigned long long>(upper) << 32) | lower;
|
return (static_cast<unsigned long long>(upper) << 32) | lower;
|
||||||
#elif defined __aarch64__
|
#elif defined __aarch64__
|
||||||
// TODO: Implement and test on ARM64
|
uint64_t vct;
|
||||||
return 0;
|
asm volatile("mrs %0, cntvct_el0":"=r"(vct));
|
||||||
|
return vct;
|
||||||
#elif defined __i386__
|
#elif defined __i386__
|
||||||
if (CPU.bRDTSC)
|
if (CPU.bRDTSC)
|
||||||
{
|
{
|
||||||
|
@ -186,14 +187,15 @@ inline uint64_t rdtsc()
|
||||||
unsigned int lower, upper, temp;
|
unsigned int lower, upper, temp;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
asm volatile ("mftbu %0 \n mftb %1 \n mftbu %2 \n"
|
asm volatile ("mftbu %0 \n mftb %1 \n mftbu %2 \n"
|
||||||
: "=r"(upper), "=r"(lower), "=r"(temp));
|
: "=r"(upper), "=r"(lower), "=r"(temp));
|
||||||
}
|
}
|
||||||
while (upper != temp);
|
while (upper != temp);
|
||||||
return (static_cast<unsigned long long>(upper) << 32) | lower;
|
return (static_cast<unsigned long long>(upper) << 32) | lower;
|
||||||
#elif defined __aarch64__
|
#elif defined __aarch64__
|
||||||
// TODO: Implement and test on ARM64
|
uint64_t vct;
|
||||||
return 0;
|
asm volatile("mrs %0, cntvct_el0":"=r"(vct));
|
||||||
|
return vct;
|
||||||
#elif defined __i386__ // i386
|
#elif defined __i386__ // i386
|
||||||
if (CPU.bRDTSC)
|
if (CPU.bRDTSC)
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,7 +144,15 @@ void CalculateCPUSpeed()
|
||||||
{
|
{
|
||||||
PerfAvailable = false;
|
PerfAvailable = false;
|
||||||
PerfToMillisec = PerfToSec = 0.;
|
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
|
// [MK] read from perf values if we can
|
||||||
struct perf_event_attr pe;
|
struct perf_event_attr pe;
|
||||||
memset(&pe,0,sizeof(struct perf_event_attr));
|
memset(&pe,0,sizeof(struct perf_event_attr));
|
||||||
|
|
Loading…
Reference in a new issue