summaryrefslogtreecommitdiff
path: root/ecp/src/platform/posix/time.c
blob: 49a85e74fe15ccd1e33693e306ad5a9d08e657a4 (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
25
26
27
28
29
30
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>

#include <ecp/core.h>
#include <ecp/tm.h>

int ecp_tm_init(ECPContext *ctx) {
    return ECP_OK;
}

ecp_sts_t ecp_tm_get_s(void) {
    return time(NULL);
}

ecp_sts_t ecp_tm_get_ms(void) {
    struct timeval tv;
    ecp_sts_t ms_now;

    gettimeofday(&tv, NULL);
    ms_now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
    return ms_now;
}

void ecp_tm_sleep(ecp_sts_t msec) {
    usleep(msec * 1000);
}

void ecp_tm_timer_set(ecp_sts_t next) {}