diff options
| author | 2018-12-29 22:57:38 -0500 | |
|---|---|---|
| committer | 2018-12-29 22:57:38 -0500 | |
| commit | f80229b67671f87d3adcd3bcfc7b1fa14ee1eda3 (patch) | |
| tree | 9962a5bffab187728595bd07f1970ce87f91af70 /src | |
| parent | Merge pull request #1955 from bunnei/g8r8-fix (diff) | |
| parent | service/time: Minor cleanup to GetClockSnapshot() (diff) | |
| download | yuzu-f80229b67671f87d3adcd3bcfc7b1fa14ee1eda3.tar.gz yuzu-f80229b67671f87d3adcd3bcfc7b1fa14ee1eda3.tar.xz yuzu-f80229b67671f87d3adcd3bcfc7b1fa14ee1eda3.zip | |
Merge pull request #1964 from lioncash/time
service/time: Minor cleanup
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.h | 12 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 60b201d06..16564de24 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -264,14 +264,12 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | |||
| 264 | LOG_DEBUG(Service_Time, "called"); | 264 | LOG_DEBUG(Service_Time, "called"); |
| 265 | 265 | ||
| 266 | IPC::RequestParser rp{ctx}; | 266 | IPC::RequestParser rp{ctx}; |
| 267 | auto unknown_u8 = rp.PopRaw<u8>(); | 267 | const auto initial_type = rp.PopRaw<u8>(); |
| 268 | |||
| 269 | ClockSnapshot clock_snapshot{}; | ||
| 270 | 268 | ||
| 271 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( | 269 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( |
| 272 | std::chrono::system_clock::now().time_since_epoch()) | 270 | std::chrono::system_clock::now().time_since_epoch()) |
| 273 | .count()}; | 271 | .count()}; |
| 274 | CalendarTime calendar_time{}; | 272 | |
| 275 | const std::time_t time(time_since_epoch); | 273 | const std::time_t time(time_since_epoch); |
| 276 | const std::tm* tm = std::localtime(&time); | 274 | const std::tm* tm = std::localtime(&time); |
| 277 | if (tm == nullptr) { | 275 | if (tm == nullptr) { |
| @@ -280,16 +278,19 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | |||
| 280 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find appropriate error code | 278 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find appropriate error code |
| 281 | return; | 279 | return; |
| 282 | } | 280 | } |
| 283 | SteadyClockTimePoint steady_clock_time_point{CoreTiming::cyclesToMs(CoreTiming::GetTicks()) / | ||
| 284 | 1000}; | ||
| 285 | 281 | ||
| 286 | LocationName location_name{"UTC"}; | 282 | const SteadyClockTimePoint steady_clock_time_point{ |
| 283 | CoreTiming::cyclesToMs(CoreTiming::GetTicks()) / 1000, {}}; | ||
| 284 | |||
| 285 | CalendarTime calendar_time{}; | ||
| 287 | calendar_time.year = tm->tm_year + 1900; | 286 | calendar_time.year = tm->tm_year + 1900; |
| 288 | calendar_time.month = tm->tm_mon + 1; | 287 | calendar_time.month = tm->tm_mon + 1; |
| 289 | calendar_time.day = tm->tm_mday; | 288 | calendar_time.day = tm->tm_mday; |
| 290 | calendar_time.hour = tm->tm_hour; | 289 | calendar_time.hour = tm->tm_hour; |
| 291 | calendar_time.minute = tm->tm_min; | 290 | calendar_time.minute = tm->tm_min; |
| 292 | calendar_time.second = tm->tm_sec; | 291 | calendar_time.second = tm->tm_sec; |
| 292 | |||
| 293 | ClockSnapshot clock_snapshot{}; | ||
| 293 | clock_snapshot.system_posix_time = time_since_epoch; | 294 | clock_snapshot.system_posix_time = time_since_epoch; |
| 294 | clock_snapshot.network_posix_time = time_since_epoch; | 295 | clock_snapshot.network_posix_time = time_since_epoch; |
| 295 | clock_snapshot.system_calendar_time = calendar_time; | 296 | clock_snapshot.system_calendar_time = calendar_time; |
| @@ -302,9 +303,10 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | |||
| 302 | clock_snapshot.network_calendar_info = additional_info; | 303 | clock_snapshot.network_calendar_info = additional_info; |
| 303 | 304 | ||
| 304 | clock_snapshot.steady_clock_timepoint = steady_clock_time_point; | 305 | clock_snapshot.steady_clock_timepoint = steady_clock_time_point; |
| 305 | clock_snapshot.location_name = location_name; | 306 | clock_snapshot.location_name = LocationName{"UTC"}; |
| 306 | clock_snapshot.clock_auto_adjustment_enabled = 1; | 307 | clock_snapshot.clock_auto_adjustment_enabled = 1; |
| 307 | clock_snapshot.ipc_u8 = unknown_u8; | 308 | clock_snapshot.type = initial_type; |
| 309 | |||
| 308 | IPC::ResponseBuilder rb{ctx, 2}; | 310 | IPC::ResponseBuilder rb{ctx, 2}; |
| 309 | rb.Push(RESULT_SUCCESS); | 311 | rb.Push(RESULT_SUCCESS); |
| 310 | ctx.WriteBuffer(&clock_snapshot, sizeof(ClockSnapshot)); | 312 | ctx.WriteBuffer(&clock_snapshot, sizeof(ClockSnapshot)); |
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index ea43fbea7..f11affe95 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -22,7 +22,6 @@ struct CalendarTime { | |||
| 22 | u8 hour; | 22 | u8 hour; |
| 23 | u8 minute; | 23 | u8 minute; |
| 24 | u8 second; | 24 | u8 second; |
| 25 | INSERT_PADDING_BYTES(1); | ||
| 26 | }; | 25 | }; |
| 27 | static_assert(sizeof(CalendarTime) == 0x8, "CalendarTime structure has incorrect size"); | 26 | static_assert(sizeof(CalendarTime) == 0x8, "CalendarTime structure has incorrect size"); |
| 28 | 27 | ||
| @@ -30,7 +29,7 @@ struct CalendarAdditionalInfo { | |||
| 30 | u32_le day_of_week; | 29 | u32_le day_of_week; |
| 31 | u32_le day_of_year; | 30 | u32_le day_of_year; |
| 32 | std::array<u8, 8> name; | 31 | std::array<u8, 8> name; |
| 33 | INSERT_PADDING_BYTES(1); | 32 | u8 is_dst; |
| 34 | s32_le utc_offset; | 33 | s32_le utc_offset; |
| 35 | }; | 34 | }; |
| 36 | static_assert(sizeof(CalendarAdditionalInfo) == 0x18, | 35 | static_assert(sizeof(CalendarAdditionalInfo) == 0x18, |
| @@ -42,8 +41,10 @@ struct TimeZoneRule { | |||
| 42 | }; | 41 | }; |
| 43 | 42 | ||
| 44 | struct SteadyClockTimePoint { | 43 | struct SteadyClockTimePoint { |
| 44 | using SourceID = std::array<u8, 16>; | ||
| 45 | |||
| 45 | u64_le value; | 46 | u64_le value; |
| 46 | INSERT_PADDING_WORDS(4); | 47 | SourceID source_id; |
| 47 | }; | 48 | }; |
| 48 | static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size"); | 49 | static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size"); |
| 49 | 50 | ||
| @@ -66,8 +67,9 @@ struct ClockSnapshot { | |||
| 66 | SteadyClockTimePoint steady_clock_timepoint; | 67 | SteadyClockTimePoint steady_clock_timepoint; |
| 67 | LocationName location_name; | 68 | LocationName location_name; |
| 68 | u8 clock_auto_adjustment_enabled; | 69 | u8 clock_auto_adjustment_enabled; |
| 69 | u8 ipc_u8; | 70 | u8 type; |
| 70 | INSERT_PADDING_BYTES(2); | 71 | u8 version; |
| 72 | INSERT_PADDING_BYTES(1); | ||
| 71 | }; | 73 | }; |
| 72 | static_assert(sizeof(ClockSnapshot) == 0xd0, "ClockSnapshot is an invalid size"); | 74 | static_assert(sizeof(ClockSnapshot) == 0xd0, "ClockSnapshot is an invalid size"); |
| 73 | 75 | ||