From c40428716c90be361a28cfc4f077a31f4501a93c Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Wed, 1 Jul 2026 08:13:14 +0000 Subject: [PATCH] cycles.c: add powerpc64* support Currently build fails on FreeBSD/powerpc64{le,} without that. --- criterion-measurement/cbits/cycles.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/criterion-measurement/cbits/cycles.c b/criterion-measurement/cbits/cycles.c index 2cdee78..b6b059d 100644 --- a/criterion-measurement/cbits/cycles.c +++ b/criterion-measurement/cbits/cycles.c @@ -18,6 +18,19 @@ StgWord64 criterion_rdtsc(void) return ret; } +#elif powerpc64le_HOST_ARCH || powerpc64_HOST_ARCH + +StgWord64 criterion_rdtsc(void) +{ + // Read the PowerPC Time Base: a monotonically-increasing 64-bit counter + // that is the architectural analogue of x86's TSC. SPR 268 returns the + // full 64-bit Time Base on 64-bit PowerPC (this is what the deprecated + // `mftb` mnemonic expanded to). + StgWord64 ret; + __asm__ __volatile__ ("mfspr %0, 268" : "=r"(ret)); + return ret; +} + #elif x86_64_HOST_ARCH || i386_HOST_ARCH StgWord64 criterion_rdtsc(void)