aboutsummaryrefslogtreecommitdiff
path: root/src/os/linux/linux_time.c
blob: 9a8f2cf023f895266edcba7c6635479fea37672f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#define _POSIX_C_SOURCE 200809L

#include <os/os.h>

#include <string.h>
#include <time.h>

OSTime
os_time_get_now(void)
{
    struct timespec ts;
    memset(&ts, 0, sizeof(ts));
    i32 err = clock_gettime(CLOCK_REALTIME, &ts);
    if (err != 0) {
        printf("failed to get time\n");
    }

    OSTime result;
    result.seconds = ts.tv_sec;
    result.nanoseconds = ts.tv_nsec;
    return result;
}