--- a/time_stamp_counter/src/time_stamp_counter_stubs.c 2025-04-15 10:15:33.000000000 +0800 +++ b/time_stamp_counter/src/time_stamp_counter_stubs.c 2026-08-07 19:02:56.000000000 +0800 @@ -44,6 +44,17 @@ asm volatile("mrs %0, cntvct_el0" : "=r" (tsc)); return tsc; } +#elif defined(__powerpc__) || defined(__POWERPC__) +static uint64_t rdtsc() +{ + uint32_t hi, lo, hi2; + do { + __asm__ __volatile__ ("mftbu %0" : "=r"(hi)); + __asm__ __volatile__ ("mftb %0" : "=r"(lo)); + __asm__ __volatile__ ("mftbu %0" : "=r"(hi2)); + } while (hi != hi2); + return (((uint64_t)hi) << 32) | ((uint64_t)lo); +} #endif CAMLprim CAMLweakdef uint64_t caml_rdtsc_unboxed(value unit) {