From 387cac0ec5de5488212fab27210da60b0931d3ee Mon Sep 17 00:00:00 2001 From: pkubaj Date: Tue, 3 Jan 2023 17:41:09 +0000 Subject: [PATCH] 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. --- libs/ardour/ardour/cycles.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/cycles.h b/libs/ardour/ardour/cycles.h index 035e966dc4..4d4920219e 100644 --- a/libs/ardour/ardour/cycles.h +++ b/libs/ardour/ardour/cycles.h @@ -72,13 +72,23 @@ static inline cycles_t get_cycles (void) #elif defined(__powerpc64__) +#ifdef __linux__ #include 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