From 2db013d891c2a6ff78db5488dbee484a3321c65b Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 23 Sep 2020 00:59:41 +0200 Subject: [PATCH] use GetTickCount()/GetTickCount64() under windows GetTickCount() when GetTickCount64() is not available --- miniupnpc/minissdpc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index 881aa70..f2a1fa3 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -453,7 +453,16 @@ parseMSEARCHReply(const char * reply, int size, static int upnp_gettimeofday(struct timeval * tv) { -#if defined(CLOCK_MONOTONIC_FAST) || defined(CLOCK_MONOTONIC) +#if defined(_WIN32) +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + ULONGLONG ts = GetTickCount64(); +#else + DWORD ts = GetTickCount(); +#endif + tv->tv_sec = ts / 1000; + tv->tv_usec = (ts % 1000) * 1000; + return 0; /* success */ +#elif defined(CLOCK_MONOTONIC_FAST) || defined(CLOCK_MONOTONIC) struct timespec ts; int ret_code = clock_gettime(UPNP_CLOCKID, &ts); if (ret_code == 0)