diff --git a/Core/Time.h b/Core/Time.h index 7e8c679c..72256570 100644 --- a/Core/Time.h +++ b/Core/Time.h @@ -236,9 +236,15 @@ static __inline __attribute__((always_inline)) uint64_t rdtsc() { +#if defined(__i386) || defined(__x86_64__) uint32_t lo, hi; __asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi)); return ((uint64_t(hi) << 32) | lo); +#elif defined(__powerpc64__) + return (__builtin_ppc_get_timebase()); +#else +#error "Unsupported platform." +#endif } /** diff --git a/Core/TimeTest.cc b/Core/TimeTest.cc index 56b4cf80..5f8a01db 100644 --- a/Core/TimeTest.cc +++ b/Core/TimeTest.cc @@ -257,7 +257,13 @@ TEST(CoreTime, rdtsc_progressTimingSensitive) { usleep(1000); uint64_t b = Time::rdtsc(); EXPECT_LT(a, b); +#if defined(__i386) || defined(__x86_64__) EXPECT_LT(a + 1000 * 1000, b); +#elif defined(__powerpc64__) + EXPECT_LT(a + 1000 * 500, b); +#else +#error "Unsupported platform." +#endif EXPECT_LT(b, a + 10 * 1000 * 1000); }