--- libupnp/threadutil/inc/ThreadPool.h	2011-01-20 07:46:57.000000000 +0100
+++ libupnp.new/threadutil/inc/ThreadPool.h	2011-09-23 01:36:12.000000000 +0200
@@ -45,6 +45,7 @@
 #include <errno.h>

 #ifdef WIN32
+	#ifndef _TIMEZONE_DEFINED
 	#include <time.h>
 	struct timezone
 	{
@@ -52,6 +53,7 @@
 		int  tz_dsttime;     /* type of dst correction */
 	};
 	int gettimeofday(struct timeval *tv, struct timezone *tz);
+	#endif
 #else /* WIN32 */
 	#include <sys/param.h>
 	#include <sys/time.h> /* for gettimeofday() */
--- libupnp-1.6.16/upnp/inc/upnp.h.orig	2012-03-22 00:15:38.000000000 +0100
+++ libupnp-1.6.16/upnp/inc/upnp.h	2012-03-28 18:58:55.043642000 +0200
@@ -61,6 +61,20 @@
 	/* Other systems ??? */
 #endif
 
+#   if defined( __MINGW32__ )
+#       if !defined( _OFF_T_ )
+            typedef long long _off_t;
+            typedef _off_t off_t;
+#           define _OFF_T_
+#       else
+#           ifdef off_t
+#               undef off_t
+#           endif
+#           define off_t long long
+#       endif
+#   endif
+
+
 #define LINE_SIZE  (size_t)180
 #define NAME_SIZE  (size_t)256
 #define MNFT_NAME_SIZE  64
--- pupnp-release-1.6.25/threadutil/src/ThreadPool.c.orig	2018-05-29 14:18:14.387352400 +0300
+++ pupnp-release-1.6.25/threadutil/src/ThreadPool.c	2018-05-29 14:20:39.327207000 +0300
@@ -263,7 +263,7 @@
 #elif defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
 	setpriority(PRIO_PROCESS, 0, 0);
 	retVal = 0;
-#elif defined(WIN32)
+#elif defined(_MSC_VER)
 	retVal = sched_setscheduler(0, in);
 #elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
 	struct sched_param current;
@@ -415,7 +415,7 @@
 	struct timeval t;
   
 	gettimeofday(&t, NULL);
-#if defined(WIN32)
+#if defined(_MSC_VER)
 	srand((unsigned int)t.tv_usec + (unsigned int)ithread_get_current_thread_id().p);
 #elif defined(BSD) || defined(__OSX__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
 	srand((unsigned int)t.tv_usec + (unsigned int)ithread_get_current_thread_id());
@@ -429,7 +429,7 @@
 		} idu;
 
 		idu.tid = ithread_get_current_thread_id();
-		srand((unsigned int)t.millitm + idu.i);
+		srand((unsigned int)t.tv_usec + idu.i);
 	}
 #endif
 }
@@ -1233,7 +1233,7 @@
 }
 #endif /* STATS */
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(_TIMEZONE_DEFINED)
 	#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
 		#define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
 	#else
