diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-05-03 21:10:08 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-05-03 21:10:08 +0200 |
commit | 25de5e761daab8b897a4f09ff8503e6f43c299f9 (patch) | |
tree | a9a1c185c7f89d67f9250e42b2aa53eefc9a6770 /code/posix/time.c |
initial commit
Diffstat (limited to 'code/posix/time.c')
-rw-r--r-- | code/posix/time.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/code/posix/time.c b/code/posix/time.c new file mode 100644 index 0000000..3dd3920 --- /dev/null +++ b/code/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; +} |