summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/time/clock_types.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/time/clock_types.h20
1 files changed, 20 insertions, 0 deletions
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 <boost/safe_numerics/safe_integer.hpp>
+
#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<s64> this_time_point{time_point};
+ const boost::safe_numerics::safe<s64> 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()};
}