13
0

Fix build on FreeBSD/powerpc64*

Only glibc has __ppc_get_timebase() function. On FreeBSD use the same assembly call that __ppc_get_timebase() actually executes.

This probably should be extended to musl and OpenBSD, but I have no way of checking that.
This commit is contained in:
pkubaj 2023-01-03 17:41:09 +00:00 committed by Robin Gareus
parent 380005f50f
commit 387cac0ec5
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -72,13 +72,23 @@ static inline cycles_t get_cycles (void)
#elif defined(__powerpc64__)
#ifdef __linux__
#include <sys/platform/ppc.h>
typedef uint64_t cycles_t;
static inline cycles_t get_cycles(void)
{
return __ppc_get_timebase();
}
#elif defined(__FreeBSD__)
typedef uint64_t cycles_t;
static inline cycles_t get_cycles(void)
{
cycles_t tbr;
asm volatile("mfspr %0, 268" : "=r"(tbr));
return tbr;
}
#endif
#elif defined(__powerpc__)
#define CPU_FTR_601 0x00000100