summaryrefslogtreecommitdiff
path: root/code/ecp/posix/time.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
committerUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
commit0d0e9facfcea3cf96da3b63285865182fdd5477e (patch)
treecca42e7aab184cad981c794073a4376aa2616193 /code/ecp/posix/time.c
parent05e11f491b84a110b9ca08612df370b91e9bdcbc (diff)
refatoring dirs
Diffstat (limited to 'code/ecp/posix/time.c')
-rw-r--r--code/ecp/posix/time.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/code/ecp/posix/time.c b/code/ecp/posix/time.c
new file mode 100644
index 0000000..c7a238a
--- /dev/null
+++ b/code/ecp/posix/time.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+#include <sys/time.h>
+
+#include <core.h>
+
+static ecp_cts_t t_abstime_ms(ecp_cts_t msec) {
+ struct timeval tv;
+ ecp_cts_t ms_now;
+
+ gettimeofday(&tv, NULL);
+ ms_now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ return ms_now + msec;
+}
+
+static void t_sleep_ms(ecp_cts_t 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;
+}