diff options
author | bunnei <bunneidev@gmail.com> | 2020-03-27 15:42:13 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-03-27 15:42:13 +0100 |
commit | a60f34a850c3a17e501edfec9089121c23bb78a5 (patch) | |
tree | 3b5bf3c64e00289863ca11ea3f864ad2f6c0d584 /src/core/hle/service/time/time.cpp | |
parent | Merge pull request #3564 from makigumo/maxwell_to_vk_sscaled (diff) | |
download | yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar.gz yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar.bz2 yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar.lz yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar.xz yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.tar.zst yuzu-a60f34a850c3a17e501edfec9089121c23bb78a5.zip |
Diffstat (limited to 'src/core/hle/service/time/time.cpp')
-rw-r--r-- | src/core/hle/service/time/time.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 749b7be70..ce859f18d 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -308,6 +308,35 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot)); } +void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_Time, "called"); + + IPC::RequestParser rp{ctx}; + const auto snapshot_a = rp.PopRaw<Clock::ClockSnapshot>(); + const auto snapshot_b = rp.PopRaw<Clock::ClockSnapshot>(); + + Clock::TimeSpanType time_span_type{}; + s64 span{}; + if (const ResultCode result{snapshot_a.steady_clock_time_point.GetSpanBetween( + snapshot_b.steady_clock_time_point, span)}; + result != RESULT_SUCCESS) { + if (snapshot_a.network_time && snapshot_b.network_time) { + time_span_type = + Clock::TimeSpanType::FromSeconds(snapshot_b.network_time - snapshot_a.network_time); + } else { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ERROR_TIME_NOT_FOUND); + return; + } + } else { + time_span_type = Clock::TimeSpanType::FromSeconds(span); + } + + IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw(time_span_type.nanoseconds); +} + void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; |