Files
nym/cpu-cycles/libcpucycles/cpucycles/ppc64-mftb.c
T
Drazen Urch 7bd1550195 libcpucycles (#3219)
* Checkpoint

* cpu cycle ffi

* Rename

* mixnode feature

* Bundle libcpucycles
2023-03-27 16:34:10 +02:00

31 lines
557 B
C

// version 20230105
// public domain
// djb
// adapted from supercop/cpucycles/powerpccpuinfo.c
#include "cpucycles_internal.h"
long long ticks(void)
{
unsigned int high, low, newhigh;
unsigned long long result;
do {
asm volatile(
"mftbu %0; mftb %1; mftbu %2"
: "=r" (high), "=r" (low), "=r" (newhigh)
);
} while (newhigh != high);
result = high;
result <<= 32;
result |= low;
return result;
}
long long ticks_setup(void)
{
if (!cpucycles_works(ticks)) return cpucycles_SKIP;
return cpucycles_FINDMULTIPLIER;
}