summaryrefslogtreecommitdiff
path: root/src/arch/posix
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-12-11 10:28:25 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-12-11 10:28:25 +0100
commit2253c912c86b5196e17657ee067abfc7afa4d652 (patch)
treec10d2722e0c44355bded196209bfba6d5827d06c /src/arch/posix
parent540974f8f109aa8874f032eddf59819c76eb018e (diff)
Add basic uptime getter, improve loop support
Diffstat (limited to 'src/arch/posix')
-rw-r--r--src/arch/posix/Makefile.inc2
-rw-r--r--src/arch/posix/driver/uptime.cc11
2 files changed, 12 insertions, 1 deletions
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 <time.h>
+
+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;