summaryrefslogtreecommitdiff
path: root/include/arch/posix/driver
diff options
context:
space:
mode:
Diffstat (limited to 'include/arch/posix/driver')
-rw-r--r--include/arch/posix/driver/counter.h10
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 &copy);
- 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;
}
};