[-/+] Nuke std::tm dependency from the public api
[*] Major bug in heap allocation, am brain damaged
This commit is contained in:
parent
48417b5fff
commit
7316aa0f8f
@ -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<typename Dest_t>
|
||||
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<typename In_t>
|
||||
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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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<void *>(length, 32);
|
||||
#endif
|
||||
}
|
||||
@ -123,7 +124,7 @@ namespace Aurora::Memory
|
||||
mutex_ = AuThreadPrimitives::MutexUnique();
|
||||
if (!mutex_) return false;
|
||||
|
||||
base_ = Memory::FAlloc<void *>(length);
|
||||
base_ = HeapLargeAllocate(length);
|
||||
if (!base_) return false;
|
||||
|
||||
heap_ = o1heapInit(base_, length,
|
||||
|
@ -100,7 +100,7 @@ namespace Aurora::Process
|
||||
}
|
||||
|
||||
path.resize(std::strlen(path.c_str()));
|
||||
splitter = '\\';
|
||||
splitter = '/';
|
||||
|
||||
#elif defined(AURORA_PLATFORM_ANDROID)
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace Aurora::Time
|
||||
return frequency = static_cast<double>(high_res_clock::period::den) / static_cast<double>(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;
|
||||
|
Loading…
Reference in New Issue
Block a user