diff --git a/compat/timespec_get.c b/compat/timespec_get.c index 350e912fd0..fb9adca7a1 100644 --- a/compat/timespec_get.c +++ b/compat/timespec_get.c @@ -22,6 +22,28 @@ # include #endif +#ifdef _WIN32 +#include + +int timespec_get(struct timespec *ts, int base) +{ + FILETIME ft; + ULARGE_INTEGER s; + ULONGLONG t; + + if (base != TIME_UTC) + return 0; + + GetSystemTimeAsFileTime(&ft); + s.LowPart = ft.dwLowDateTime; + s.HighPart = ft.dwHighDateTime; + t = s.QuadPart - 116444736000000000ULL; + ts->tv_sec = t / 10000000; + ts->tv_nsec = ((int) (t % 10000000)) * 100; + return base; +} +#else /* !_WIN32 */ + #include #include /* _POSIX_TIMERS */ #ifndef _POSIX_TIMERS @@ -58,3 +80,4 @@ int timespec_get(struct timespec *ts, int base) } return base; } +#endif /* !_WIN32 */