diff options
| author | 2024-10-19 11:07:04 -0400 | |
|---|---|---|
| committer | 2024-10-19 11:18:15 -0400 | |
| commit | b8abe660fab174d37f8f49142f2261e93f463527 (patch) | |
| tree | 407b1e7c9113ca2d628775bf7d6921e93df722d2 /src/util/timer | |
| parent | 9e63fb59e7b8506183172869ea44b68cdec29be5 (diff) | |
| download | libnaunet-b8abe660fab174d37f8f49142f2261e93f463527.tar.gz libnaunet-b8abe660fab174d37f8f49142f2261e93f463527.tar.bz2 libnaunet-b8abe660fab174d37f8f49142f2261e93f463527.zip | |
Simplify packet_pool, various fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/util/timer')
| -rw-r--r-- | src/util/timer/timer_windows.c | 29 |
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; } |