From 50cc77a5ad212ea9c0283c6606d0057b806d2c12 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Fri, 20 Dec 2024 21:42:05 +0000 Subject: [PATCH] iprovide cycle clock counter for hppa diff --git a/third-party/benchmark/src/cycleclock.h b/third-party/benchmark/src/cycleclock.h index d4f1330b671d..5847900a9b7d 100644 --- a/third-party/benchmark/src/cycleclock.h +++ b/third-party/benchmark/src/cycleclock.h @@ -228,6 +228,16 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { struct timeval tv; gettimeofday(&tv, nullptr); return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; +#elif defined(__hppa__) + // HP PARISC provides a user-readable clock counter (cr16), but + // it's not syncronized across CPUs and only 32-bit wide when built + // as 32-bit binary. + // Use clock_gettime(CLOCK_MONOTONIC, ...) instead of gettimeofday + // because is provides nanosecond resolution. + // Initialize to always return 0 if clock_gettime fails. + struct timespec ts = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &ts); + return static_cast(ts.tv_sec) * 1000000000 + ts.tv_nsec; #else // The soft failover to a generic implementation is automatic only for ARM. // For other platforms the developer is expected to make an attempt to create