summaryrefslogtreecommitdiff
path: root/src/util/timer
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/timer')
-rw-r--r--src/util/timer/timer_windows.c29
1 files changed, 5 insertions, 24 deletions
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 <al/lib.h>
-
#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;
}