#include "../../winwrap.h" #include "timer.h" f64 nn_get_tick(void) { LARGE_INTEGER result; QueryPerformanceCounter(&result); return result.QuadPart / (f64)performance_frequency.QuadPart; } // https://stackoverflow.com/a/46024468 static const s64 UNIX_TIME_START = 0x019DB1DED53E8000; // January 1st, 1970 in "ticks" u64 nn_get_timestamp(void) { FILETIME ft; #ifdef NAUNET_WIN32_COMPAT_MODE GetSystemTimeAsFileTime(&ft); #else // https://github.com/llvm/llvm-project/commit/3ec634e65a02d5f443cc982e9e00ec4e51143d07 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \ (_WIN32_WINNT >= _WIN32_WINNT_WIN10) GetSystemTimePreciseAsFileTime(&ft); #else #error "GetSystemTimePreciseAsFileTime() requested but not supported." #endif #endif return (((LARGE_INTEGER){ .LowPart = ft.dwLowDateTime, .HighPart = ft.dwHighDateTime }).QuadPart - UNIX_TIME_START) / 10u; }