diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-02-27 23:56:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-02 08:36:08 +0100 |
commit | c040e64b7d231fc374e99882751c58f50e116339 (patch) | |
tree | f84a2d3537407baaab28e47d5bf12dc0355507ae /Kernel/Syscalls | |
parent | 91c72faa3c15129c7bd4a91ad3edf451cd38cbee (diff) | |
download | serenity-c040e64b7d231fc374e99882751c58f50e116339.zip |
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.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/alarm.cpp | 3 | ||||
-rw-r--r-- | Kernel/Syscalls/clock.cpp | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/Kernel/Syscalls/alarm.cpp b/Kernel/Syscalls/alarm.cpp index ff3de1350c..18104863ed 100644 --- a/Kernel/Syscalls/alarm.cpp +++ b/Kernel/Syscalls/alarm.cpp @@ -45,8 +45,7 @@ KResultOr<unsigned> Process::sys$alarm(unsigned seconds) } if (seconds > 0) { - // FIXME: Should use AK::Time internally - auto deadline = Time::from_timespec(TimeManagement::the().current_time(CLOCK_REALTIME_COARSE).value()); + auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME_COARSE).value(); deadline = deadline + Time::from_seconds(seconds); m_alarm_timer = TimerQueue::the().add_timer_without_id(CLOCK_REALTIME_COARSE, deadline, [this]() { [[maybe_unused]] auto rc = send_signal(SIGALRM, nullptr); diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index d883e6ac04..5296644141 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -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; |