diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/time/clock_types.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h index ed1eb5b2d..9fc01ea90 100644 --- a/src/core/hle/service/time/clock_types.h +++ b/src/core/hle/service/time/clock_types.h @@ -3,6 +3,8 @@ #pragma once +#include <ratio> + #include "common/common_funcs.h" #include "common/common_types.h" #include "common/uuid.h" @@ -59,21 +61,34 @@ static_assert(sizeof(SystemClockContext) == 0x20, "SystemClockContext is incorre static_assert(std::is_trivially_copyable_v<SystemClockContext>, "SystemClockContext must be trivially copyable"); +struct ContinuousAdjustmentTimePoint { + s64 measurement_offset; + s64 diff_scale; + u32 shift_amount; + s64 lower; + s64 upper; + Common::UUID clock_source_id; +}; +static_assert(sizeof(ContinuousAdjustmentTimePoint) == 0x38); +static_assert(std::is_trivially_copyable_v<ContinuousAdjustmentTimePoint>, + "ContinuousAdjustmentTimePoint must be trivially copyable"); + /// https://switchbrew.org/wiki/Glue_services#TimeSpanType struct TimeSpanType { s64 nanoseconds{}; - static constexpr s64 ns_per_second{1000000000ULL}; s64 ToSeconds() const { - return nanoseconds / ns_per_second; + return nanoseconds / std::nano::den; } static TimeSpanType FromSeconds(s64 seconds) { - return {seconds * ns_per_second}; + return {seconds * std::nano::den}; } - static TimeSpanType FromTicks(u64 ticks, u64 frequency) { - return FromSeconds(static_cast<s64>(ticks) / static_cast<s64>(frequency)); + template <u64 Frequency> + static TimeSpanType FromTicks(u64 ticks) { + using TicksToNSRatio = std::ratio<std::nano::den, Frequency>; + return {static_cast<s64>(ticks * TicksToNSRatio::num / TicksToNSRatio::den)}; } }; static_assert(sizeof(TimeSpanType) == 8, "TimeSpanType is incorrect size"); |