From f68ea33d203fc1e1feb9186a0a821af3f85352d5 Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 16 Oct 2012 19:55:39 +0200 Subject: [PATCH] Use clock_gettime on Linux. --- benchmark.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/benchmark.c b/benchmark.c index 537a02590e..8f4690a6ef 100644 --- a/benchmark.c +++ b/benchmark.c @@ -22,6 +22,8 @@ #endif #elif defined(_XBOX360) #include +#elif defined(__linux__) +#include #endif rarch_perf_tick_t rarch_get_perf_counter(void) @@ -36,6 +38,13 @@ rarch_perf_tick_t rarch_get_perf_counter(void) __asm mov time_tmp.HighPart, edx; time = time_tmp.QuadPart; +#elif defined(__linux__) + struct timespec tv; + if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) == 0) + time = (rarch_perf_tick_t)tv.tv_sec * 1000000000 + (rarch_perf_tick_t)tv.tv_nsec; + else + time = 0; + #elif defined(__GNUC__) && !defined(RARCH_CONSOLE) #if defined(__i386__) || defined(__i486__) @@ -45,6 +54,7 @@ rarch_perf_tick_t rarch_get_perf_counter(void) asm volatile ("rdtsc" : "=a" (a), "=d" (d)); time = (rarch_perf_tick_t)a | ((rarch_perf_tick_t)d << 32); #endif + #elif defined(__ARM_ARCH_6__) || defined(ANDROID) asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time) ); #elif defined(__CELLOS_LV2__) || defined(GEKKO) || defined(_XBOX360)