X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fdropin.c;h=6d40850763d00b5867e7b853e3d35527a4b1447a;hp=f1a51ac85f28395107c9309658ec73035c01cb66;hb=706d855e507980de3845556989d7de7a3b9c76e8;hpb=d917c8cb6b69475d568ccbe82389b9f2b3eb5e80 diff --git a/src/dropin.c b/src/dropin.c index f1a51ac8..6d408507 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -1,7 +1,7 @@ /* dropin.c -- a set of drop-in replacements for libc functions Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2011 Guus Sliepen + 2000-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,8 +158,18 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { #ifndef HAVE_GETTIMEOFDAY int gettimeofday(struct timeval *tv, void *tz) { +#ifdef HAVE_MINGW + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + uint64_t lt = (uint64_t)ft.dwLowDateTime | ((uint64_t)ft.dwHighDateTime << 32); + lt -= 116444736000000000ULL; + tv->tv_sec = lt / 10000000; + tv->tv_usec = (lt / 10) % 1000000; +#else +#warning No high resolution time source! tv->tv_sec = time(NULL); tv->tv_usec = 0; +#endif return 0; } #endif