NetKDTime: Use re-entrant variants of gmtime
Makes these implementations more thread-safe by design. These likely won't be run on any other thread, but we may as well just use the re-entrant variant if it's available.
This commit is contained in:
parent
f2292467ad
commit
f03da37693
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/chrono.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/EXI/EXI_DeviceIPL.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
|
@ -93,10 +95,10 @@ u64 NetKDTimeDevice::GetAdjustedUTC() const
|
|||
|
||||
time_t dst_diff{};
|
||||
const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH);
|
||||
tm* const gm_time = gmtime(¤t_time);
|
||||
tm gm_time = fmt::gmtime(current_time);
|
||||
|
||||
const u32 emulated_time = mktime(gm_time);
|
||||
if (gm_time->tm_isdst == 1)
|
||||
const u32 emulated_time = mktime(&gm_time);
|
||||
if (gm_time.tm_isdst == 1)
|
||||
dst_diff = 3600;
|
||||
|
||||
return u64(s64(emulated_time) + utcdiff - dst_diff);
|
||||
|
@ -108,10 +110,10 @@ void NetKDTimeDevice::SetAdjustedUTC(u64 wii_utc)
|
|||
|
||||
time_t dst_diff{};
|
||||
const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH);
|
||||
tm* const gm_time = gmtime(¤t_time);
|
||||
tm gm_time = fmt::gmtime(current_time);
|
||||
|
||||
const u32 emulated_time = mktime(gm_time);
|
||||
if (gm_time->tm_isdst == 1)
|
||||
const u32 emulated_time = mktime(&gm_time);
|
||||
if (gm_time.tm_isdst == 1)
|
||||
dst_diff = 3600;
|
||||
|
||||
utcdiff = s64(emulated_time - wii_utc - dst_diff);
|
||||
|
|
Loading…
Reference in New Issue