2022-05-13 11:45:40 +00:00
|
|
|
#ifndef LUMENARIUM_LINUX_TIME_H
|
|
|
|
#define LUMENARIUM_LINUX_TIME_H 1
|
|
|
|
|
2022-07-18 11:31:48 +00:00
|
|
|
#define NANOS_PER_SECOND 1000000000
|
2022-05-13 11:45:40 +00:00
|
|
|
Ticks
|
|
|
|
os_get_ticks()
|
|
|
|
{
|
2022-07-18 11:31:48 +00:00
|
|
|
struct timespec ts = {};
|
|
|
|
s32 r = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
|
|
|
|
assert(r == 0);
|
|
|
|
s64 nanos = (s64)ts.tv_sec * NANOS_PER_SECOND;
|
|
|
|
nanos += (s64)ts.tv_nsec;
|
|
|
|
|
|
|
|
Ticks result = {
|
|
|
|
.value = nanos
|
|
|
|
};
|
|
|
|
return result;
|
2022-05-13 11:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r64
|
|
|
|
os_get_ticks_per_second()
|
|
|
|
{
|
2022-07-18 11:31:48 +00:00
|
|
|
return NANOS_PER_SECOND;
|
2022-05-13 11:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LUMENARIUM_LINUX_TIME_H
|