From 1aed4ad849e89f00281afb6654367994f99b6110 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Wed, 6 Sep 2023 03:35:24 +0200 Subject: Fix timespec_get impl --- source/kit/time.h | 9 ++++++--- source/kit_test/shared.inl.h | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/kit/time.h b/source/kit/time.h index e6dcb4a..01fa239 100644 --- a/source/kit/time.h +++ b/source/kit/time.h @@ -17,6 +17,9 @@ # endif # include +# define KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS 116444736000000000ull +# define KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS 10000000ull + static int timespec_get(struct timespec *ts, int base) { if (ts == NULL || base != TIME_UTC) return 0; @@ -29,9 +32,9 @@ static int timespec_get(struct timespec *ts, int base) { date.HighPart = ft.dwHighDateTime; date.LowPart = ft.dwLowDateTime; ticks = (LONGLONG) (date.QuadPart - - _TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS); - ts->tv_sec = ticks / _TIMESPEC_IMPL_TICKS_PER_SECONDS; - ts->tv_nsec = (ticks % _TIMESPEC_IMPL_TICKS_PER_SECONDS) * 100; + KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS); + ts->tv_sec = ticks / KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS; + ts->tv_nsec = (ticks % KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS) * 100; return base; } diff --git a/source/kit_test/shared.inl.h b/source/kit_test/shared.inl.h index f000786..11b42bb 100644 --- a/source/kit_test/shared.inl.h +++ b/source/kit_test/shared.inl.h @@ -22,6 +22,10 @@ # endif # include +# define KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS \ + 116444736000000000ull +# define KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS 10000000ull + static int timespec_get(struct timespec *ts, int base) { if (ts == NULL || base != TIME_UTC) return 0; @@ -34,9 +38,9 @@ static int timespec_get(struct timespec *ts, int base) { date.HighPart = ft.dwHighDateTime; date.LowPart = ft.dwLowDateTime; ticks = (LONGLONG) (date.QuadPart - - _TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS); - ts->tv_sec = ticks / _TIMESPEC_IMPL_TICKS_PER_SECONDS; - ts->tv_nsec = (ticks % _TIMESPEC_IMPL_TICKS_PER_SECONDS) * 100; + KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS); + ts->tv_sec = ticks / KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS; + ts->tv_nsec = (ticks % KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS) * 100; return base; } -- cgit v1.2.3