1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

Kernel: Make TimeManagement use AK::Time internally

I don't dare touch the multi-threading logic and locking mechanism, so it stays
timespec for now. However, this could and should be changed to AK::Time, and I
bet it will simplify the "increment_time_since_boot()" code.
This commit is contained in:
Ben Wiederhake 2021-02-27 23:56:16 +01:00 committed by Andreas Kling
parent 91c72faa3c
commit c040e64b7d
8 changed files with 39 additions and 38 deletions

View file

@ -34,11 +34,12 @@ KResultOr<int> Process::sys$clock_gettime(clockid_t clock_id, Userspace<timespec
{
REQUIRE_PROMISE(stdio);
auto ts = TimeManagement::the().current_time(clock_id);
if (ts.is_error())
return ts.error();
auto time = TimeManagement::the().current_time(clock_id);
if (time.is_error())
return time.error();
if (!copy_to_user(user_ts, &ts.value()))
auto ts = time.value().to_timespec();
if (!copy_to_user(user_ts, &ts))
return EFAULT;
return 0;
}
@ -56,8 +57,7 @@ KResultOr<int> Process::sys$clock_settime(clockid_t clock_id, Userspace<const ti
switch (clock_id) {
case CLOCK_REALTIME:
// FIXME: Should use AK::Time internally
TimeManagement::the().set_epoch_time(ts->to_timespec());
TimeManagement::the().set_epoch_time(ts.value());
break;
default:
return EINVAL;