mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
Kernel+LibC: Implement clock_gettime() and clock_nanosleep()
Only the CLOCK_MONOTONIC clock is supported at the moment, and it only has millisecond precision. :^)
This commit is contained in:
parent
73b2cb9ed8
commit
cc68654a44
9 changed files with 127 additions and 7 deletions
|
@ -117,4 +117,18 @@ clock_t clock()
|
|||
times(&tms);
|
||||
return tms.tms_utime + tms.tms_stime;
|
||||
}
|
||||
|
||||
int clock_gettime(clockid_t clock_id, struct timespec* ts)
|
||||
{
|
||||
int rc = syscall(SC_clock_gettime, clock_id, ts);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec* requested_sleep, struct timespec* remaining_sleep)
|
||||
{
|
||||
Syscall::SC_clock_nanosleep_params params { clock_id, flags, requested_sleep, remaining_sleep };
|
||||
int rc = syscall(SC_clock_nanosleep, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue