From cb88701a8c2f155a898fa1af637f9377c8db71d8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 9 Aug 2022 11:41:13 +0200 Subject: posix counter: switch to clock_monotonic --- include/arch/posix/driver/counter.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/arch/posix/driver/counter.h b/include/arch/posix/driver/counter.h index e37bfd7..5d10500 100644 --- a/include/arch/posix/driver/counter.h +++ b/include/arch/posix/driver/counter.h @@ -9,13 +9,13 @@ #include #include -typedef uint64_t counter_value_t; +typedef int64_t counter_value_t; typedef uint8_t counter_overflow_t; class Counter { private: Counter(const Counter ©); - uint64_t start_sec, start_nsec; + int64_t start_sec, start_nsec; public: uint64_t value; @@ -25,16 +25,16 @@ class Counter { inline void start() { struct timespec ts; - clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); start_sec = ts.tv_sec; start_nsec = ts.tv_nsec; } inline void stop() { struct timespec ts; - clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); - value = (ts.tv_sec - start_sec) * 1000000000UL; + value = (ts.tv_sec - start_sec) * 1000000000L; value += ts.tv_nsec - start_nsec; } }; -- cgit v1.2.3