summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/time/clock_types.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-12-23 00:10:59 +0100
committerbunnei <bunneidev@gmail.com>2020-01-04 19:48:30 +0100
commitfab2607c6bae25f50912b32e1cbbfb5a6191916c (patch)
treebdcff3de0871a546f8e1399a6b1ba2869a569d04 /src/core/hle/service/time/clock_types.h
parentsystem_archive: Add a basic HLE implementation for time zone binary. (diff)
downloadyuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar.gz
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar.bz2
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar.lz
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar.xz
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.tar.zst
yuzu-fab2607c6bae25f50912b32e1cbbfb5a6191916c.zip
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()};
}