diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-09-06 03:31:15 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-09-06 03:31:15 +0200 |
commit | 50257aaab2fe845e515058fb42e1aaa7f2e6fae8 (patch) | |
tree | d2b66be29f9dd244829bb1978f01021d324df547 /source | |
parent | 684be371508fd505ad02c4a387cd69ce12152931 (diff) | |
download | kit-50257aaab2fe845e515058fb42e1aaa7f2e6fae8.zip |
test
Diffstat (limited to 'source')
-rw-r--r-- | source/kit/time.h | 19 | ||||
-rw-r--r-- | source/kit_test/shared.inl.h | 17 |
2 files changed, 34 insertions, 2 deletions
diff --git a/source/kit/time.h b/source/kit/time.h index cf0f070..e6dcb4a 100644 --- a/source/kit/time.h +++ b/source/kit/time.h @@ -17,7 +17,24 @@ # endif # include <Windows.h> -static int timespec_get(struct timespec *ts, int base) { } +static int timespec_get(struct timespec *ts, int base) { + if (ts == NULL || base != TIME_UTC) + return 0; + + FILETIME ft; + ULARGE_INTEGER date; + LONGLONG ticks; + + GetSystemTimeAsFileTime(&ft); + 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; + + return base; +} #endif #endif diff --git a/source/kit_test/shared.inl.h b/source/kit_test/shared.inl.h index 34ccb07..b96897c 100644 --- a/source/kit_test/shared.inl.h +++ b/source/kit_test/shared.inl.h @@ -22,7 +22,22 @@ # endif # include <Windows.h> -static int timespec_get(struct timespec *ts, int base) { } +static int timespec_get(struct timespec *ts, int base) { + if (ts == NULL || base != TIME_UTC) + return 0; + FILETIME ft; + ULARGE_INTEGER date; + LONGLONG ticks; + + GetSystemTimeAsFileTime(&ft); + 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; + return base; +} # endif #endif // kit/time.h |