From f03da376939f962ba3e51dc76786d041c2052345 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 23 Jan 2024 14:30:41 -0500 Subject: [PATCH] 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. --- Source/Core/Core/IOS/Network/KD/NetKDTime.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp b/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp index 6764be4053..6095ae458d 100644 --- a/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp +++ b/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp @@ -5,6 +5,8 @@ #include +#include + #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);