From 2253c912c86b5196e17657ee067abfc7afa4d652 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 11 Dec 2017 10:28:25 +0100 Subject: Add basic uptime getter, improve loop support --- src/arch/posix/Makefile.inc | 2 +- src/arch/posix/driver/uptime.cc | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/arch/posix/driver/uptime.cc (limited to 'src/arch/posix') diff --git a/src/arch/posix/Makefile.inc b/src/arch/posix/Makefile.inc index 9dd723d..7553fd4 100644 --- a/src/arch/posix/Makefile.inc +++ b/src/arch/posix/Makefile.inc @@ -5,7 +5,7 @@ CXX = g++ INCLUDES += -Iinclude/posix TARGETS += src/arch/posix/arch.cc src/arch/posix/driver/gpio.cc -TARGETS += src/arch/posix/driver/stdout.cc +TARGETS += src/arch/posix/driver/stdout.cc src/arch/posix/driver/uptime.cc OBJECTS = ${TARGETS:.cc=.o} diff --git a/src/arch/posix/driver/uptime.cc b/src/arch/posix/driver/uptime.cc new file mode 100644 index 0000000..040b51c --- /dev/null +++ b/src/arch/posix/driver/uptime.cc @@ -0,0 +1,11 @@ +#include "driver/uptime.h" +#include + +uint64_t Uptime::get() +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return (uint64_t)ts.tv_nsec + (1000000ULL * ((uint64_t)ts.tv_sec % 256)); +} + +Uptime uptime; -- cgit v1.2.3