7bd1550195
* Checkpoint * cpu cycle ffi * Rename * mixnode feature * Bundle libcpucycles
31 lines
557 B
C
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;
|
|
}
|