blob: 3dd39201e38bd768b517c9db393d53d69cb73020 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
}
|