diff --git a/Include/Aurora/Time/Clock.hpp b/Include/Aurora/Time/Clock.hpp index 4d995e23..a3c3b7e2 100644 --- a/Include/Aurora/Time/Clock.hpp +++ b/Include/Aurora/Time/Clock.hpp @@ -9,20 +9,61 @@ namespace Aurora::Time { + struct tm + { + int tm_sec {}; + int tm_min {}; + int tm_hour {}; + int tm_mday {1}; + int tm_mon {}; + int tm_year {70}; + int tm_wday {}; + int tm_yday {}; + int tm_isdst {-1}; + + template + void CopyTo(Dest_t &out) const + { + out.tm_sec = tm_sec; + out.tm_min = tm_min; + out.tm_hour = tm_hour; + out.tm_mday = tm_mday; + out.tm_mon = tm_mon; + out.tm_year = tm_year; + out.tm_wday = tm_wday; + out.tm_yday = tm_yday; + out.tm_isdst = tm_isdst; + } + + template + void CopyFrom(const In_t &in) + { + tm_sec = in.tm_sec; + tm_min = in.tm_min; + tm_hour = in.tm_hour; + tm_mday = in.tm_mday; + tm_mon = in.tm_mon; + tm_year = in.tm_year; + tm_wday = in.tm_wday; + tm_yday = in.tm_yday; + tm_isdst = in.tm_isdst; + } + }; + /** Converts milliseconds from the Aurora epoch to a civil timestamp structure similar to or of std::tm Range: 1900 -> 2001 +- 2^63-1 ms */ - AUKN_SYM std::tm ToCivilTime(AuInt64 time, bool UTC = true); + AUKN_SYM tm ToCivilTime(AuInt64 time, bool UTC = true); /** Converts civil time to milliseconds from the Aurora epoch Range: 1900 -> 2001 +- 2^63-1 ms */ - AUKN_SYM AuInt64 FromCivilTime(const std::tm &time, bool UTC = true); + AUKN_SYM AuInt64 FromCivilTime(const tm &time, bool UTC = true); /** Retrieves system clock in jiffies diff --git a/Source/Console/ConsoleMessage.cpp b/Source/Console/ConsoleMessage.cpp index 620e77aa..c3b85a60 100644 --- a/Source/Console/ConsoleMessage.cpp +++ b/Source/Console/ConsoleMessage.cpp @@ -30,9 +30,9 @@ namespace Aurora::Console AuString ConsoleMessage::StringifyTime(bool simple) const { - tm localized; + std::tm localized; - localized = Aurora::Time::ToCivilTime(time, false); + Aurora::Time::ToCivilTime(time, false).CopyTo(localized); if (simple) { diff --git a/Source/Crypto/X509/x509.cpp b/Source/Crypto/X509/x509.cpp index e56ad162..ba3c7bf9 100644 --- a/Source/Crypto/X509/x509.cpp +++ b/Source/Crypto/X509/x509.cpp @@ -341,14 +341,14 @@ namespace Aurora::Crypto::X509 static AuInt64 ConvertTime(const mbedtls_x509_time &time) { - std::tm tm = {}; + AuTime::tm tm = {}; tm.tm_year = time.year - 1900; tm.tm_mon = time.mon - 1; tm.tm_mday = time.day; tm.tm_sec = time.sec; tm.tm_min = time.min; tm.tm_hour = time.hour; - return Aurora::Time::FromCivilTime(tm, true); + return AuTime::FromCivilTime(tm, true); } AUKN_SYM bool Decode(const Certificate &der, DecodedCertificate &out) diff --git a/Source/Memory/Heap.cpp b/Source/Memory/Heap.cpp index fd74783c..a9896ecb 100644 --- a/Source/Memory/Heap.cpp +++ b/Source/Memory/Heap.cpp @@ -31,6 +31,7 @@ namespace Aurora::Memory // ideally we should page align. // i think mimalloc has fast paths with warnings for overly large passthrough allocations. unsure. // 32 alignment in the fastest way mimalloc can provide us memory seems adequate + // it's very easy for mimalloc to seethe at larger allocations, but it does have slowpaths to handle them return Memory::FAlloc(length, 32); #endif } @@ -123,7 +124,7 @@ namespace Aurora::Memory mutex_ = AuThreadPrimitives::MutexUnique(); if (!mutex_) return false; - base_ = Memory::FAlloc(length); + base_ = HeapLargeAllocate(length); if (!base_) return false; heap_ = o1heapInit(base_, length, diff --git a/Source/Process/Paths.cpp b/Source/Process/Paths.cpp index e1d94741..40154654 100644 --- a/Source/Process/Paths.cpp +++ b/Source/Process/Paths.cpp @@ -100,7 +100,7 @@ namespace Aurora::Process } path.resize(std::strlen(path.c_str())); - splitter = '\\'; + splitter = '/'; #elif defined(AURORA_PLATFORM_ANDROID) diff --git a/Source/Time/Clock.cpp b/Source/Time/Clock.cpp index 9e58820d..92848179 100644 --- a/Source/Time/Clock.cpp +++ b/Source/Time/Clock.cpp @@ -193,7 +193,7 @@ namespace Aurora::Time return frequency = static_cast(high_res_clock::period::den) / static_cast(high_res_clock::period::num); } - AUKN_SYM std::tm ToCivilTime(AuInt64 time, bool UTC) + AUKN_SYM tm ToCivilTime(AuInt64 time, bool UTC) { std::tm ret{}; auto timet = MSToCTime(time); @@ -220,18 +220,21 @@ namespace Aurora::Time #endif { LogWarn("Couldn't convert local civil time"); - ret = ToCivilTime(time, true); + return ToCivilTime(time, true); } } - //ret.tm_isdst = 0; - return ret; + tm _; + _.CopyFrom(ret); + return _; } - AUKN_SYM AuInt64 FromCivilTime(const std::tm &time, bool UTC) + AUKN_SYM AuInt64 FromCivilTime(const tm &time, bool UTC) { - auto tm = time; + ::tm tm; time_t timet; + time.CopyTo(tm); + if (UTC) { tm.tm_isdst = 0;