From 4cd232ca208be04eb16e24e77a7704982b0c8fd9 Mon Sep 17 00:00:00 2001 From: LWSS Date: Thu, 1 Oct 2020 14:59:11 -0700 Subject: [PATCH] GetClockTicks() - keep other arch in mind --- neo/sys/posix/posix_main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp index ad164e3e..8c32dff4 100644 --- a/neo/sys/posix/posix_main.cpp +++ b/neo/sys/posix/posix_main.cpp @@ -261,14 +261,20 @@ double Sys_GetClockTicks() "pop %%ebx\n" : "=r"( lo ), "=r"( hi ) ); return ( double ) lo + ( double ) 0xFFFFFFFF * hi; -#else -//#error unsupported CPU // RB begin +#elif defined( __x86_64__ ) uint32_t lo, hi; __asm__ __volatile__ ( "rdtsc" : "=a" (lo), "=d" (hi)); return ( ( ( uint64_t )hi ) << 32 ) | lo; -// RB end +#else + //#error unsupported CPU + struct timespec now; + + clock_gettime( CLOCK_MONOTONIC, &now ); + + return now.tv_sec * 1000000000LL + now.tv_nsec; #endif +// RB end } /*