diff options
| author | 2019-06-04 19:52:42 -0400 | |
|---|---|---|
| committer | 2019-06-04 20:31:24 -0400 | |
| commit | 42f5fd0ab32b117901d0cae228103811719606ff (patch) | |
| tree | 66fed7f7c35ba2448006f1393a9b868ed29632d5 /src/core/hle | |
| parent | core/core_timing_utils: Simplify overload set (diff) | |
| download | yuzu-42f5fd0ab32b117901d0cae228103811719606ff.tar.gz yuzu-42f5fd0ab32b117901d0cae228103811719606ff.tar.xz yuzu-42f5fd0ab32b117901d0cae228103811719606ff.zip | |
core/core_timing_util: Use std::chrono types for specifying time units
Makes the interface more type-safe and consistent in terms of return
values.
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 9 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 2abf9efca..c73a40977 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -75,9 +75,9 @@ void Thread::WakeAfterDelay(s64 nanoseconds) { | |||
| 75 | 75 | ||
| 76 | // This function might be called from any thread so we have to be cautious and use the | 76 | // This function might be called from any thread so we have to be cautious and use the |
| 77 | // thread-safe version of ScheduleEvent. | 77 | // thread-safe version of ScheduleEvent. |
| 78 | const s64 cycles = Core::Timing::nsToCycles(std::chrono::nanoseconds{nanoseconds}); | ||
| 78 | Core::System::GetInstance().CoreTiming().ScheduleEventThreadsafe( | 79 | Core::System::GetInstance().CoreTiming().ScheduleEventThreadsafe( |
| 79 | Core::Timing::nsToCycles(nanoseconds), kernel.ThreadWakeupCallbackEventType(), | 80 | cycles, kernel.ThreadWakeupCallbackEventType(), callback_handle); |
| 80 | callback_handle); | ||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void Thread::CancelWakeupTimer() { | 83 | void Thread::CancelWakeupTimer() { |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index 45812d238..f425305d6 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | |||
| @@ -185,7 +185,8 @@ u32 nvhost_ctrl_gpu::GetGpuTime(const std::vector<u8>& input, std::vector<u8>& o | |||
| 185 | 185 | ||
| 186 | IoctlGetGpuTime params{}; | 186 | IoctlGetGpuTime params{}; |
| 187 | std::memcpy(¶ms, input.data(), input.size()); | 187 | std::memcpy(¶ms, input.data(), input.size()); |
| 188 | params.gpu_time = Core::Timing::cyclesToNs(Core::System::GetInstance().CoreTiming().GetTicks()); | 188 | const auto ns = Core::Timing::cyclesToNs(Core::System::GetInstance().CoreTiming().GetTicks()); |
| 189 | params.gpu_time = static_cast<u64_le>(ns.count()); | ||
| 189 | std::memcpy(output.data(), ¶ms, output.size()); | 190 | std::memcpy(output.data(), ¶ms, output.size()); |
| 190 | return 0; | 191 | return 0; |
| 191 | } | 192 | } |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index aa115935d..a6bb3beb0 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -108,8 +108,9 @@ private: | |||
| 108 | LOG_DEBUG(Service_Time, "called"); | 108 | LOG_DEBUG(Service_Time, "called"); |
| 109 | 109 | ||
| 110 | const auto& core_timing = Core::System::GetInstance().CoreTiming(); | 110 | const auto& core_timing = Core::System::GetInstance().CoreTiming(); |
| 111 | const SteadyClockTimePoint steady_clock_time_point{ | 111 | const auto ms = Core::Timing::cyclesToMs(core_timing.GetTicks()); |
| 112 | Core::Timing::cyclesToMs(core_timing.GetTicks()) / 1000}; | 112 | const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), |
| 113 | {}}; | ||
| 113 | IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2}; | 114 | IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2}; |
| 114 | rb.Push(RESULT_SUCCESS); | 115 | rb.Push(RESULT_SUCCESS); |
| 115 | rb.PushRaw(steady_clock_time_point); | 116 | rb.PushRaw(steady_clock_time_point); |
| @@ -284,8 +285,8 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | |||
| 284 | } | 285 | } |
| 285 | 286 | ||
| 286 | const auto& core_timing = Core::System::GetInstance().CoreTiming(); | 287 | const auto& core_timing = Core::System::GetInstance().CoreTiming(); |
| 287 | const SteadyClockTimePoint steady_clock_time_point{ | 288 | const auto ms = Core::Timing::cyclesToMs(core_timing.GetTicks()); |
| 288 | Core::Timing::cyclesToMs(core_timing.GetTicks()) / 1000, {}}; | 289 | const SteadyClockTimePoint steady_clock_time_point{static_cast<u64_le>(ms.count() / 1000), {}}; |
| 289 | 290 | ||
| 290 | CalendarTime calendar_time{}; | 291 | CalendarTime calendar_time{}; |
| 291 | calendar_time.year = tm->tm_year + 1900; | 292 | calendar_time.year = tm->tm_year + 1900; |