From fab2607c6bae25f50912b32e1cbbfb5a6191916c Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 22 Dec 2019 18:10:59 -0500 Subject: service: time: Implement IsStandardNetworkSystemClockAccuracySufficient. --- src/core/hle/service/time/clock_types.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core/hle/service/time/clock_types.h') diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h index f2ef3ec53..3d5b0ff1e 100644 --- a/src/core/hle/service/time/clock_types.h +++ b/src/core/hle/service/time/clock_types.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "common/common_funcs.h" #include "common/common_types.h" #include "common/uuid.h" @@ -17,6 +19,24 @@ struct SteadyClockTimePoint { s64 time_point; Common::UUID clock_source_id; + ResultCode GetSpanBetween(SteadyClockTimePoint other, s64& span) const { + span = 0; + + if (clock_source_id != other.clock_source_id) { + return ERROR_TIME_MISMATCH; + } + + const boost::safe_numerics::safe this_time_point{time_point}; + const boost::safe_numerics::safe other_time_point{other.time_point}; + try { + span = other_time_point - this_time_point; + } catch (const std::exception&) { + return ERROR_OVERFLOW; + } + + return RESULT_SUCCESS; + } + static SteadyClockTimePoint GetRandom() { return {0, Common::UUID::Generate()}; } -- cgit v1.2.3