diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2022-08-09 11:41:13 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2022-08-09 11:41:13 +0200 |
commit | cb88701a8c2f155a898fa1af637f9377c8db71d8 (patch) | |
tree | 79f38a8f8cff8d501068fb5f82b771eb9f87bc1e /include/arch | |
parent | a1b9127d160fb41b1e68892aa8daa68f69e96d90 (diff) |
posix counter: switch to clock_monotonic
Diffstat (limited to 'include/arch')
-rw-r--r-- | include/arch/posix/driver/counter.h | 10 |
1 files changed, 5 insertions, 5 deletions
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 <stdint.h> #include <time.h> -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; } }; |