AuroraRuntime/Source/Time/AuClock.cpp

586 lines
23 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuClock.cpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-13
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
#include "AuClock.hpp"
2023-04-21 21:08:56 +00:00
#include "Time.hpp"
2021-06-27 21:25:29 +00:00
#if defined(AURORA_IS_MODERNNT_DERIVED)
// TODO (Reece): ....
// benchmarking:
// https://github.com/microsoft/STL/issues/2085
2023-09-10 16:18:31 +00:00
static AuUInt64 _GetSteadyTimeNS()
{
static const long long gFreq = _Query_perf_frequency();
const long long uCounter = _Query_perf_counter();
2023-09-10 16:18:31 +00:00
if (gFreq == 10000000)
{
return uCounter * 100;
}
else if (gFreq == 1000000)
{
return uCounter * 1000;
}
else if (gFreq == 100000)
{
return uCounter * 10000;
}
else if (gFreq == 100000000)
{
return uCounter * 10;
}
else if (gFreq == 1000000000)
{
return uCounter;
}
2023-09-10 16:18:31 +00:00
else
{
// 6 branches: the default threshold for most jit and language compiler backends to decide to pick a jump table, if the values were in a close range
// otherwise, back to a tree of paths. either way, im sure 6 if elses are faster than grug math with large numbers, modulus, division, and multiplication
const long long uWhole = (uCounter / gFreq) * 1'000'000'000ull;
const long long uPart = (uCounter % gFreq) * 1'000'000'000ull / gFreq;
return uWhole + uPart;
}
}
// ~3.0741 seconds
2023-09-10 16:18:31 +00:00
//using high_res_clock = steady_clock_fast;
// holy fuck, we're keeping this
// ~2x improvement
#else
// ~6.07 seconds
2023-09-10 16:18:31 +00:00
//using high_res_clock = std::chrono::high_resolution_clock;
#endif
#if defined(AURORA_IS_POSIX_DERIVED)
#include <sys/resource.h>
#endif
2021-06-27 21:25:29 +00:00
using sys_clock = std::chrono::system_clock;
using steady_clock = std::chrono::steady_clock;
2021-06-27 21:25:29 +00:00
#if defined(AURORA_PLATFORM_WIN32)
#define timegm _mkgmtime
2021-06-27 21:25:29 +00:00
#endif
static sys_clock::duration gEpoch;
static sys_clock::duration gUnixDelta;
static auto InitEpoch()
{
std::tm start{0, 15, 10, 29, 7, 101, 0, 0, 0};
2021-06-27 21:25:29 +00:00
auto epoch = sys_clock::from_time_t(timegm(&start)).time_since_epoch();
std::tm unixStart{};
unixStart.tm_mday = 1;
unixStart.tm_year = 70;
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
// dont care what the spec says, you can't trust some ms stls
// sys_clock can have its own epoch for all we care
auto nixEpoch = sys_clock::from_time_t(timegm(&unixStart)).time_since_epoch();
2021-06-27 21:25:29 +00:00
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
gUnixDelta = epoch - nixEpoch;
2021-06-27 21:25:29 +00:00
gEpoch = epoch;
return 0;
}
static auto ___ = InitEpoch();
template<typename T>
static inline T NormalizeEpoch(T sysEpoch)
{
return sysEpoch - gEpoch;
}
template<typename T>
static inline T DecodeEpoch(T auroraEpoch)
{
return auroraEpoch + gEpoch;
}
template<typename Clock_t, typename Duration_t>
static auto TimeFromDurationSinceEpoch(Duration_t in)
{
auto duration = std::chrono::duration_cast<typename Clock_t::duration>(in);
2021-06-27 21:25:29 +00:00
return std::chrono::time_point<Clock_t>(DecodeEpoch(duration));
}
template<typename Duration_t>
static time_t CalculateTimeT(AuUInt64 in)
{
return sys_clock::to_time_t(TimeFromDurationSinceEpoch<sys_clock>(Duration_t(in)));
}
2023-09-10 16:18:31 +00:00
static AuInt64 _CurrentClockMS()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(NormalizeEpoch(sys_clock::now().time_since_epoch())).count();
}
static AuInt64 _CurrentClockNS()
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(NormalizeEpoch(sys_clock::now().time_since_epoch())).count();
}
2021-06-27 21:25:29 +00:00
namespace Aurora::Time
{
// removed from public header / deprecating
AUKN_SYM AuUInt64 HighResClock();
AUKN_SYM AuUInt64 HighResClockNS();
AUKN_SYM AuUInt64 HighResClockMS();
AUKN_SYM AuUInt64 HighResClockJiffies();
2021-06-27 21:25:29 +00:00
AUKN_SYM time_t SToCTime(AuInt64 time)
{
return CalculateTimeT<std::chrono::seconds>(time);
}
AUKN_SYM time_t NSToCTime(AuInt64 time)
{
return CalculateTimeT<std::chrono::nanoseconds>(time);
}
AUKN_SYM time_t MSToCTime(AuInt64 time)
{
return CalculateTimeT<std::chrono::milliseconds>(time);
}
AUKN_SYM AuInt64 CurrentClock()
2021-06-27 21:25:29 +00:00
{
return NormalizeEpoch(sys_clock::now().time_since_epoch()).count();
}
AUKN_SYM AuInt64 CurrentClockMS()
2021-06-27 21:25:29 +00:00
{
2023-09-10 16:18:31 +00:00
return _CurrentClockMS();
2021-06-27 21:25:29 +00:00
}
AUKN_SYM AuInt64 CurrentClockNS()
2021-06-27 21:25:29 +00:00
{
2023-09-10 16:18:31 +00:00
return _CurrentClockNS();
2021-06-27 21:25:29 +00:00
}
AUKN_SYM AuUInt64 SteadyClock()
{
2023-04-21 21:08:56 +00:00
#if defined(AURORA_IS_MODERNNT_DERIVED)
return _Query_perf_counter();
2023-09-10 16:18:31 +00:00
#else
2023-04-21 21:08:56 +00:00
return SteadyClockNS() / (1000000000ull / SteadyClockJiffies());
2023-09-10 16:18:31 +00:00
#endif
}
AUKN_SYM AuUInt64 SteadyClockMS()
{
#if defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
if (::clock_gettime(CLOCK_MONOTONIC, &spec) == 0)
{
return AuSToMS<AuUInt64>(spec.tv_sec) + AuNSToMS<AuUInt64>(spec.tv_nsec);
}
2023-09-10 16:18:31 +00:00
else
{
return 0;
}
#elif defined(AURORA_IS_MODERNNT_DERIVED)
return AuNSToMS<AuUInt64>(_GetSteadyTimeNS());
#else
return std::chrono::duration_cast<std::chrono::milliseconds>(steady_clock::now().time_since_epoch()).count();
2023-09-10 16:18:31 +00:00
#endif
}
AUKN_SYM AuUInt64 SteadyClockNS()
{
#if defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
if (::clock_gettime(CLOCK_MONOTONIC, &spec) == 0)
{
return AuMSToNS<AuUInt64>(AuSToMS<AuUInt64>(spec.tv_sec)) + (AuUInt64)spec.tv_nsec;
}
2023-09-10 16:18:31 +00:00
else
{
return 0;
}
#elif defined(AURORA_IS_MODERNNT_DERIVED)
return _GetSteadyTimeNS();
#else
return std::chrono::duration_cast<std::chrono::nanoseconds>(steady_clock::now().time_since_epoch()).count();
#endif
2023-09-10 16:18:31 +00:00
}
AUKN_SYM AuUInt64 SteadyClockJiffies()
{
static AuUInt64 gFrequency = 0;
if (gFrequency != 0)
{
return gFrequency;
}
2023-09-10 16:18:31 +00:00
#if defined(AURORA_COMPILER_MSVC)
return gFrequency = _Query_perf_frequency();
#elif defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
if (::clock_getres(CLOCK_MONOTONIC, &spec) == 0)
{
if (spec.tv_nsec && !spec.tv_sec)
{
return gFrequency = 1000000000ull / spec.tv_nsec;
}
}
return gFrequency = (1000000000ull / 100ull);
#else
return gFrequency = static_cast<double>(steady_clock::period::den) / static_cast<double>(steady_clock::period::num);
#endif
}
AUKN_SYM AuInt64 CTimeToMS(time_t time)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(NormalizeEpoch(sys_clock::from_time_t(time).time_since_epoch())).count();
}
AuInt64 CTimeNSNormalize(AuUInt64 time)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(NormalizeEpoch(std::chrono::nanoseconds(time))).count();
}
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
#if defined(AURORA_IS_POSIX_DERIVED)
enum class EPseudoPosixClock
{
eUser,
eKernel,
eAll
};
static AuUInt64 GetPOSIXTimeEx(struct rusage *usage, EPseudoPosixClock e)
{
struct timeval *tv {};
switch (e)
{
case EPseudoPosixClock::eAll:
{
return GetPOSIXTimeEx(usage, EPseudoPosixClock::eKernel) +
GetPOSIXTimeEx(usage, EPseudoPosixClock::eUser);
}
case EPseudoPosixClock::eUser:
{
tv = &usage->ru_utime;
break;
}
case EPseudoPosixClock::eKernel:
{
tv = &usage->ru_stime;
break;
}
};
auto uMS = AuSToMS<AuUInt64>(tv->tv_sec);
auto uNS = AuMSToNS<AuUInt64>(uMS) +
tv->tv_usec * 1'000ull;
return uNS;
}
static AuUInt64 GetPOSIXTime(bool bThread, EPseudoPosixClock e)
{
struct rusage usage;
getrusage(bThread ? RUSAGE_THREAD : RUSAGE_SELF,
&usage);
return GetPOSIXTimeEx(&usage, e);
}
#if !defined(CLOCK_THREAD_CPUTIME_ID)
#define CLOCK_THREAD_CPUTIME_ID 0
#endif
#if !defined(CLOCK_PROCESS_CPUTIME_ID)
#define CLOCK_PROCESS_CPUTIME_ID 0
#endif
#endif
#if defined(AURORA_IS_MODERNNT_DERIVED)
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
#define ADD_CLOCK_FAMILY(fn, type, expr, posixId, posixCall) \
AUKN_SYM AuUInt64 fn ## ClockJiffies(); \
\
AUKN_SYM AuUInt64 fn ## ClockMS() \
{ \
return AuNSToMS<AuUInt64>(fn ## ClockNS()); \
} \
\
AUKN_SYM AuUInt64 fn ## ClockNS() \
{ \
FILETIME creation, exit, kernel, user; \
if (::Get ## type ## Times(GetCurrent ## type(), &creation, &exit, &kernel, &user)) \
{ \
ULARGE_INTEGER ullUser; \
{ \
ullUser.LowPart = user.dwLowDateTime; \
ullUser.HighPart = user.dwHighDateTime; \
} \
\
ULARGE_INTEGER ullKernel; \
{ \
ullKernel.LowPart = kernel.dwLowDateTime; \
ullKernel.HighPart = kernel.dwHighDateTime; \
} \
return (expr) * 100ull; \
} \
return HighResClockNS(); \
} \
\
AUKN_SYM AuUInt64 fn ## Clock() \
{ \
FILETIME creation, exit, kernel, user; \
\
if (::Get ## type ## Times(GetCurrent ## type(), &creation, &exit, &kernel, &user)) \
{ \
ULARGE_INTEGER ullUser; \
{ \
ullUser.LowPart = user.dwLowDateTime; \
ullUser.HighPart = user.dwHighDateTime; \
} \
\
ULARGE_INTEGER ullKernel; \
{ \
ullKernel.LowPart = kernel.dwLowDateTime; \
ullKernel.HighPart = kernel.dwHighDateTime; \
} \
return expr; \
} \
\
return fn ##ClockNS() / (1000000000ull / fn ## ClockJiffies()); \
} \
\
AUKN_SYM AuUInt64 fn ## ClockJiffies() \
{ \
return 1000000000ull / 100u; \
2021-06-27 21:25:29 +00:00
}
#elif defined(AURORA_IS_POSIX_DERIVED)
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
#define ADD_CLOCK_FAMILY(fn, type, expr, posixId, posixCall) \
AUKN_SYM AuUInt64 fn ## ClockJiffies(); \
\
AUKN_SYM AuUInt64 fn ## ClockMS() \
{ \
if (!posixId) \
{ \
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
return AuNSToMS<AuUInt64>(GetPOSIXTime AU_WHAT(posixCall)); \
} \
return AuNSToMS<AuUInt64>(fn ## ClockNS()); \
} \
\
AUKN_SYM AuUInt64 fn ## ClockNS() \
{ \
if (!posixId) \
{ \
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
return GetPOSIXTime AU_WHAT(posixCall); \
} \
::timespec spec {}; \
if (::clock_gettime(posixId, &spec) == 0) \
{ \
return AuMSToNS<AuUInt64>(AuSToMS<AuUInt64>(spec.tv_sec)) + (AuUInt64)spec.tv_nsec; \
} \
return HighResClockNS(); \
} \
\
AUKN_SYM AuUInt64 fn ## Clock() \
{ \
if (!posixId) \
{ \
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
return fn ##ClockNS() / 1000ull; \
} \
return fn ##ClockNS() / (1000000000ull / fn ## ClockJiffies()); \
} \
\
AUKN_SYM AuUInt64 fn ## ClockJiffies() \
{ \
if (!posixId) \
{ \
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
return 1'000'000ull; \
} \
static AuUInt64 frequency = 0; \
if (frequency != 0) \
{ \
return frequency; \
} \
\
::timespec spec {}; \
if (::clock_getres(posixId, &spec) == 0) \
{ \
if (spec.tv_nsec && !spec.tv_sec) \
{ \
return frequency = 1000000000ull / spec.tv_nsec; \
} \
else \
{ \
SysUnreachable(); \
return 0; \
} \
} \
\
return HighResClockJiffies(); \
2023-04-21 21:08:56 +00:00
}
#else
2021-06-27 21:25:29 +00:00
AUKN_SYM AuUInt64 fn ## ClockMS()
2023-04-21 21:08:56 +00:00
{
return 0;
2023-04-21 21:08:56 +00:00
}
AUKN_SYM AuUInt64 fn ## ClockNS()
2021-06-27 21:25:29 +00:00
{
return 0;
2023-04-21 21:08:56 +00:00
}
AUKN_SYM AuUInt64 fn ## Clock()
2023-04-21 21:08:56 +00:00
{
return 0;
2023-04-21 21:08:56 +00:00
}
AUKN_SYM AuUInt64 fn ## ClockJiffies()
2023-04-21 21:08:56 +00:00
{
return 0;
2023-04-21 21:08:56 +00:00
}
#endif
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
2023-08-28 15:34:21 +00:00
ADD_CLOCK_FAMILY(Process, Process, (ullUser.QuadPart + ullKernel.QuadPart), /*CLOCK_PROCESS_CPUTIME_ID*/ 0, (false, EPseudoPosixClock::eAll));
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
ADD_CLOCK_FAMILY(ProcessKernel, Process, (ullKernel.QuadPart), 0, (false, EPseudoPosixClock::eKernel));
2023-08-28 15:34:21 +00:00
ADD_CLOCK_FAMILY(ProcessUser, Process, (ullUser.QuadPart), /*CLOCK_PROCESS_CPUTIME_ID*/0, (false, EPseudoPosixClock::eUser));
ADD_CLOCK_FAMILY(Thread, Thread, (ullUser.QuadPart + ullKernel.QuadPart), /*CLOCK_THREAD_CPUTIME_ID*/0, (true, EPseudoPosixClock::eAll));
[+] Begin work on a POSIX 2001 based clock implementation as opposed to the retarded stinking free-shit glibc toddlers hacked together alongside linux vdso. Once again, a POSIX spec from 2001 and NT kernel releases from 2 decades ago are much better than whatever the hell Linux toddlers are up to in the 2020s. Fuck your 1998 POSIX1.b UNIX ass interface with extensions that dont even provide the functionality of POSIX 2001. Much like how UWP is forcing us to support Windows XP, Linux retardation is pushing us towards legacy POSIX support (the deprecation of AuProcesses pidfd requirements, now this) Alongside this, https://gitea.reece.sx/AuroraSupport/AuroraRuntime/issues/60, this is yet another monthly reminder that the Linux kernel maintainers are the most useless incompetent boomers gluing forced-source drivers into a monolithic mess. PS: if i wasnt malding before, i am now after trying to unearth the context of this disaster. https://nextcloud.reece.sx/index.php/s/jx82SsygJYWSir6/preview https://nextcloud.reece.sx/index.php/s/RpRpNbnBixyMT5G/preview https://nextcloud.reece.sx/index.php/s/NfMfDCcxL6sfXCf/preview https://nextcloud.reece.sx/index.php/s/7A4t5JNzzFctPT6/preview https://nextcloud.reece.sx/index.php/s/cyYwm8GPLKiLFqS/preview Bills peen company had this figured out before < LINUX 2.2 1999 EVEN HAD CLOCK APIs. ARE YOU FUCKING KIDDING? LINUXs MAIN CLOCK IMPLEMENTATION WASNT EVEN DONE UNTIL 2002 BY ONE GEORGE BECAUSE PATHER DIDNT FUCK IT UP ENOUGH? Freetards should get the wall. I don't know how these braindead fuckers could've ever eaten a bowl of cereal without choking on the milk and dying. * 2002-10-15 Posix Clocks & timers by George Anzinger [...] These are all the functions necessary to implement POSIX clocks & timers Meanwhile at Microsoft in 1997, ... I just cant anymore. Why the fuck are we even paying lip service to Linshit?
2023-08-03 22:51:27 +00:00
ADD_CLOCK_FAMILY(ThreadKernel, Thread, (ullKernel.QuadPart), 0, (true, EPseudoPosixClock::eKernel));
2023-08-28 15:34:21 +00:00
ADD_CLOCK_FAMILY(ThreadUser, Thread, (ullUser.QuadPart), /*CLOCK_THREAD_CPUTIME_ID*/0, (true, EPseudoPosixClock::eUser));
2021-06-27 21:25:29 +00:00
AUKN_SYM AuInt64 ConvertAuroraToUnixMS(AuInt64 in)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::milliseconds(in) + gUnixDelta).count();
}
AUKN_SYM AuInt64 ConvertAuroraToUnixNS(AuInt64 in)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds(in) + gUnixDelta).count();
}
AUKN_SYM AuInt64 ConvertUnixToAuroraMS(AuInt64 in)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::milliseconds(in) - gUnixDelta).count();
}
AUKN_SYM AuInt64 ConvertUnixToAuroraNS(AuInt64 in)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds(in) - gUnixDelta).count();
}
AUKN_SYM tm ToCivilTime(AuInt64 time, bool UTC)
2021-06-27 21:25:29 +00:00
{
2022-03-08 01:36:12 +00:00
std::tm ret {};
2021-06-27 21:25:29 +00:00
auto timet = MSToCTime(time);
if (UTC)
{
2022-03-08 01:36:12 +00:00
#if defined(AURORA_COMPILER_MSVC)
2021-06-27 21:25:29 +00:00
auto tm = gmtime_s(&ret, &timet);
2022-03-08 01:36:12 +00:00
#else
auto tm = gmtime_r(&timet, &ret);
2022-03-08 01:36:12 +00:00
#endif
#if defined(AURORA_COMPILER_MSVC)
2021-06-27 21:25:29 +00:00
SysAssert(!tm, "couldn't convert civil time");
2022-03-08 01:36:12 +00:00
#else
2021-06-27 21:25:29 +00:00
SysAssert(tm, "couldn't convert civil time");
2022-03-08 01:36:12 +00:00
#endif
2021-06-27 21:25:29 +00:00
}
else
{
2022-03-08 01:36:12 +00:00
#if defined(AURORA_COMPILER_MSVC)
2021-06-27 21:25:29 +00:00
if (localtime_s(&ret, &timet))
#else
2021-06-27 21:25:29 +00:00
if (!localtime_r(&timet, &ret))
#endif
2021-06-27 21:25:29 +00:00
{
SysPushErrorGeneric("Couldn't convert local civil time");
return ToCivilTime(time, true);
2021-06-27 21:25:29 +00:00
}
}
tm _;
_.CopyFrom(ret);
return _;
2021-06-27 21:25:29 +00:00
}
AUKN_SYM AuInt64 FromCivilTime(const tm &time, bool UTC)
2021-06-27 21:25:29 +00:00
{
::tm tm;
2021-06-27 21:25:29 +00:00
time_t timet;
2022-03-08 01:36:12 +00:00
time.CopyTo(tm);
2021-06-27 21:25:29 +00:00
if (UTC)
{
tm.tm_isdst = 0;
timet = timegm(&tm);
}
else
{
tm.tm_isdst = -1; // out of the 2 crts i've bothered to check, out of 3, this is legal
2021-06-27 21:25:29 +00:00
timet = mktime(&tm);
}
2022-03-08 01:36:12 +00:00
2021-06-27 21:25:29 +00:00
if ((timet == 0) || (timet == -1))
{
return 0;
}
2022-03-08 01:36:12 +00:00
2021-06-27 21:25:29 +00:00
return std::chrono::duration_cast<std::chrono::milliseconds>(NormalizeEpoch(std::chrono::system_clock::from_time_t(timet).time_since_epoch())).count();
}
AUKN_SYM tm NormalizeCivilTimezone(const Time::tm &time, ETimezoneShift shift)
{
if ((time.tm_isdst == 0) && (shift == ETimezoneShift::eUTC))
{
return time;
}
return ToCivilTime(FromCivilTime(time, shift == ETimezoneShift::eUTC));
}
2023-04-21 21:08:56 +00:00
#pragma region TO_DEPRECATE
// [soon to be] @deprecated / was used by benchmarks to measure thread time
2023-04-21 21:08:56 +00:00
AUKN_SYM AuUInt64 HighResClock()
{
return SteadyClock();
2023-04-21 21:08:56 +00:00
}
AUKN_SYM AuUInt64 HighResClockMS()
{
return SteadyClockMS();
2023-04-21 21:08:56 +00:00
}
AUKN_SYM AuUInt64 HighResClockNS()
{
return SteadyClockNS();
2023-04-21 21:08:56 +00:00
}
2023-04-22 22:08:49 +00:00
AUKN_SYM AuUInt64 HighResClockJiffies()
{
return SteadyClockJiffies();
2023-04-22 22:08:49 +00:00
}
2023-04-21 21:08:56 +00:00
#pragma endregion TO_DEPRECATE
2022-03-08 01:36:12 +00:00
}