From b8abe660fab174d37f8f49142f2261e93f463527 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 19 Oct 2024 11:07:04 -0400 Subject: Simplify packet_pool, various fixes Signed-off-by: Andrew Opalach --- src/util/timer/timer_windows.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'src/util/timer') diff --git a/src/util/timer/timer_windows.c b/src/util/timer/timer_windows.c index 007efed..edd1297 100644 --- a/src/util/timer/timer_windows.c +++ b/src/util/timer/timer_windows.c @@ -1,5 +1,3 @@ -#include - #include "../../winwrap.h" #include "timer.h" @@ -11,29 +9,12 @@ f64 aki_get_tick(void) return result.QuadPart / (f64)performance_frequency.QuadPart; } -static SYSTEMTIME unix_epoch = { - .wYear = 1970, - .wMonth = 1, - .wDayOfWeek = 4, - .wDay = 1, - .wHour = 0, - .wMinute = 0, - .wSecond = 0, - .wMilliseconds = 0 -}; +// https://stackoverflow.com/a/46024468 +static const s64 UNIX_TIME_START = 0x019DB1DED53E8000; // January 1st, 1970 in "ticks" u64 aki_get_timestamp(void) { - FILETIME result0, result1; - SystemTimeToFileTime(&unix_epoch, &result0); - ULARGE_INTEGER li0 = { - .LowPart = result0.dwLowDateTime, - .HighPart = result0.dwHighDateTime - }; - GetSystemTimePreciseAsFileTime(&result1); - ULARGE_INTEGER li1 = { - .LowPart = result1.dwLowDateTime, - .HighPart = result1.dwHighDateTime - }; - return (li1.QuadPart - li0.QuadPart) / 10L; + FILETIME ft; + GetSystemTimePreciseAsFileTime(&ft); + return (((LARGE_INTEGER){ .LowPart = ft.dwLowDateTime, .HighPart = ft.dwHighDateTime }).QuadPart - UNIX_TIME_START) / 10Lu; } -- cgit v1.2.3-101-g0448