From 8ba5af70494579f215fc0451da31bc9627585092 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 1 Feb 2017 07:37:29 +0100 Subject: [PATCH] Use C++11 clock implementation instead implementation platform specific code ourselves (#4358) * Use C++11 standard chrono API instead of platform specific code (fixes Mac OS X < 10.12) * Divide by /2 to get 2ms steps --- radio/src/targets/simu/simpgmspace.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index e4109f092..b2a54f03f 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #if !defined _MSC_VER || defined __GNUC__ #include @@ -97,14 +98,8 @@ uint16_t getTmr2MHz() U64 CoGetOSTime(void) { - // one tick is 2ms -#if defined(_MSC_VER) - return GetTickCount()/2; -#else - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ((U64)ts.tv_sec * 1000 + ts.tv_nsec / 1000000) /2; -#endif + auto now = std::chrono::steady_clock::now(); + return (U64) std::chrono::duration_cast(now.time_since_epoch()).count() / 2; } void simuInit()