+#ifdef _WIN32
+static void w32_time_to_timeval(struct timeval* tv, const FILETIME* ft)
+{
+ unsigned __int64 tm;
+ tm = (unsigned __int64)ft->dwHighDateTime << 32;
+ tm |= ft->dwLowDateTime;
+ tm /= 10;
+ tm -= 11644473600000000ULL;
+ tv->tv_sec = (long)(tm / 1000000L);
+ tv->tv_usec = (long)(tm % 1000000L);
+}
+
+static void w32_times_to_timeval(struct timeval* tv, const FILETIME* kernel_time, const FILETIME* user_time)
+{
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64)kernel_time->dwHighDateTime << 32;
+ ktm |= kernel_time->dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64)user_time->dwHighDateTime << 32;
+ utm |= user_time->dwLowDateTime;
+ utm /= 10;
+ tv->tv_sec = (long)(ktm / 1000000L) + (long)(utm / 1000000L);
+ tv->tv_usec = (long)(ktm % 1000000L) + (long)(utm % 1000000L);
+}
+#endif
+