mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
Kernel: Support more clocks in sys$clock_getres()
Support all the available clocks in clock_getres(). Also, fix this function to use the actual ticks per second value, not the constant `_SC_CLK_TCK` (which is always equal to 8) and move the resolution computation logic to TimeManagement.
This commit is contained in:
parent
3c7a0ef1ac
commit
f6eb155167
3 changed files with 12 additions and 10 deletions
|
@ -98,16 +98,11 @@ ErrorOr<FlatPtr> Process::sys$clock_getres(Userspace<Syscall::SC_clock_getres_pa
|
|||
{
|
||||
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
||||
auto params = TRY(copy_typed_from_user(user_params));
|
||||
timespec ts {};
|
||||
switch (params.clock_id) {
|
||||
case CLOCK_REALTIME:
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000000 / _SC_CLK_TCK;
|
||||
TRY(copy_to_user(params.result, &ts));
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
TRY(TimeManagement::validate_clock_id(params.clock_id));
|
||||
|
||||
auto ts = TimeManagement::the().clock_resolution().to_timespec();
|
||||
TRY(copy_to_user(params.result, &ts));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue