0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-10-21 06:21:40 +00:00
ryujinx-fork/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs
Thomas Guillemard 1f3a34dd7a Implement time:* 2.0.0 & 3.0.0 commands (#735)
* Finish ISteadyClock implementation

* Implement IsStandardNetworkSystemClockAccuracySufficient

Also use signed values for offsets and TimeSpanType

* Address comments

* Fix one missing nit and improve one comment
2019-07-15 19:52:35 +02:00

62 lines
1.5 KiB
C#

using Ryujinx.HLE.Utilities;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
[StructLayout(LayoutKind.Sequential)]
struct TimeSpanType
{
public long NanoSeconds;
public TimeSpanType(long nanoSeconds)
{
NanoSeconds = nanoSeconds;
}
public long ToSeconds()
{
return NanoSeconds / 1000000000;
}
public static TimeSpanType FromTicks(ulong ticks, ulong frequency)
{
return new TimeSpanType((long)ticks * 1000000000 / (long)frequency);
}
}
[StructLayout(LayoutKind.Sequential)]
struct SteadyClockTimePoint
{
public long TimePoint;
public UInt128 ClockSourceId;
public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan)
{
outSpan = 0;
if (ClockSourceId == other.ClockSourceId)
{
try
{
outSpan = checked(other.TimePoint - TimePoint);
return ResultCode.Success;
}
catch (OverflowException)
{
return ResultCode.Overflow;
}
}
return ResultCode.Overflow;
}
}
[StructLayout(LayoutKind.Sequential)]
struct SystemClockContext
{
public long Offset;
public SteadyClockTimePoint SteadyTimePoint;
}
}