From 1ee6e020bb623e91df9c10a161efd01ba2a45603 Mon Sep 17 00:00:00 2001 From: Wander Lairson Costa Date: Tue, 23 Jun 2020 20:20:14 +0000 Subject: [PATCH] eina_test_lock.c: Implement clock_gettime for Windows Reviewed-by: Stefan Schmidt Reviewed-by: Vincent Torri Differential Revision: https://phab.enlightenment.org/D12023 --- src/tests/eina/eina_test_lock.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tests/eina/eina_test_lock.c b/src/tests/eina/eina_test_lock.c index 583ca1a7a9..bbf036b203 100644 --- a/src/tests/eina/eina_test_lock.c +++ b/src/tests/eina/eina_test_lock.c @@ -53,6 +53,25 @@ clock_gettime(int mode, struct timespec* ts) return 0; } + +# elif defined(_WIN32) + +# define CLOCK_REALTIME 0 + +int +clock_gettime(int mode, struct timespec* ts) +{ + FILETIME sys_time; + ULARGE_INTEGER li_sys_time; + + GetSystemTimeAsFileTime(&sys_time); + li_sys_time.u.LowPart = sys_time.dwLowDateTime; + li_sys_time.u.HighPart = sys_time.dwHighDateTime; + ts->tv_sec = li_sys_time.QuadPart / 10000000UL; + ts->tv_nsec = (li_sys_time.QuadPart % 10000000UL) * 100UL; + return 0; +} + # else /* ! __MACH__ */ # error No support for clock_gettime() # endif /* __MACH__ */