summaryrefslogtreecommitdiff
path: root/code/core/posix/time.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2017-05-23 14:19:26 +0200
committerUros Majstorovic <majstor@majstor.org>2017-05-23 14:19:26 +0200
commit3ef6719f47b734b12c0b11c725b7f12e3fb3c08a (patch)
treea635ac65bfc72d126d97e48e22c38ac33343b4f4 /code/core/posix/time.c
parent922e8313f2b3f6157a61b3c867fdc3832bb92a68 (diff)
fs layout updated
Diffstat (limited to 'code/core/posix/time.c')
-rw-r--r--code/core/posix/time.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/code/core/posix/time.c b/code/core/posix/time.c
new file mode 100644
index 0000000..3dd3920
--- /dev/null
+++ b/code/core/posix/time.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+#include <sys/time.h>
+
+#include <core.h>
+
+static unsigned int t_abstime_ms(unsigned int msec) {
+ struct timeval tv;
+ unsigned int ms_now;
+
+ gettimeofday(&tv, NULL);
+ ms_now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ return ms_now + msec;
+}
+
+static void t_sleep_ms(unsigned int msec) {
+ usleep(msec*1000);
+}
+
+int ecp_time_init(ECPTimeIface *t) {
+ t->init = 1;
+ t->abstime_ms = t_abstime_ms;
+ t->sleep_ms = t_sleep_ms;
+ return 0;
+}