summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-12-29 18:29:57 -0500
committerGravatar Lioncash2018-12-29 21:42:13 -0500
commitfa97f50bff9d335dc30c7b0d445e296704505675 (patch)
tree31073d31f5e4d3d1e9ec762f91b4a70d71b5ea3f /src
parentservice/time: Fill in some structures and remove padding where not necessary (diff)
downloadyuzu-fa97f50bff9d335dc30c7b0d445e296704505675.tar.gz
yuzu-fa97f50bff9d335dc30c7b0d445e296704505675.tar.xz
yuzu-fa97f50bff9d335dc30c7b0d445e296704505675.zip
service/time: Minor cleanup to GetClockSnapshot()
Moves some variables closer to their actual usage sites.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/time/time.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 128329284..16564de24 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -266,12 +266,10 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
266 IPC::RequestParser rp{ctx}; 266 IPC::RequestParser rp{ctx};
267 const auto initial_type = rp.PopRaw<u8>(); 267 const auto initial_type = rp.PopRaw<u8>();
268 268
269 ClockSnapshot clock_snapshot{};
270
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.type = initial_type; 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));