LibC: Implement clock in terms of clock_gettime
This allows clock to "just work" after I update clock_gettime to support CLOCK_PROCESS_CPUTIME_ID.
This commit is contained in:
@@ -20,8 +20,11 @@ int nanosleep(const struct timespec* rqtp, struct timespec* rmtp)
|
|||||||
|
|
||||||
clock_t clock(void)
|
clock_t clock(void)
|
||||||
{
|
{
|
||||||
dwarnln("TODO: clock");
|
timespec ts;
|
||||||
|
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
return ((uint64_t)ts.tv_sec * CLOCKS_PER_SEC)
|
||||||
|
+ ((uint64_t)ts.tv_nsec * CLOCKS_PER_SEC / 1'000'000'000);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t time(time_t* tloc)
|
time_t time(time_t* tloc)
|
||||||
|
|||||||
Reference in New Issue
Block a user