aboutsummaryrefslogtreecommitdiff
path: root/win32port
diff options
context:
space:
mode:
authorYucong Sun <thefallentree@user.github.invalid>2020-11-23 20:21:58 +0000
committerAndy Green <andy@warmcat.com>2020-11-28 10:58:38 +0000
commita72e975613bce74d11802f0d5c2edb085c044c82 (patch)
treec6e935f844ed27a788e418ed52e6fcf321a8153d /win32port
parentacfd3491b9b06b9751c0576d736a8d09f5a69617 (diff)
downloadlibwebsockets-a72e975613bce74d11802f0d5c2edb085c044c82.tar.gz
mingw: libevent build fixes
Diffstat (limited to 'win32port')
-rw-r--r--win32port/win32helpers/gettimeofday.c34
-rw-r--r--win32port/win32helpers/gettimeofday.h8
2 files changed, 23 insertions, 19 deletions
diff --git a/win32port/win32helpers/gettimeofday.c b/win32port/win32helpers/gettimeofday.c
index 08385c23..be5ac11e 100644
--- a/win32port/win32helpers/gettimeofday.c
+++ b/win32port/win32helpers/gettimeofday.c
@@ -1,11 +1,12 @@
-#include <time.h>
-#include <windows.h> //I've omitted context line
-
-#include "gettimeofday.h"
-
-int gettimeofday(struct timeval *tv, struct timezone *tz)
-{
- FILETIME ft;
+#include <time.h>
+#include <windows.h>
+
+#include "gettimeofday.h"
+
+#ifndef LWS_MINGW_SUPPORT
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
@@ -19,11 +20,11 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
- tv->tv_sec = (long)(tmpres / 1000000UL);
- tv->tv_usec = (long)(tmpres % 1000000UL);
- }
-
- if (NULL != tz) {
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz) {
if (!tzflag) {
_tzset();
tzflag++;
@@ -31,6 +32,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
-
- return 0;
-}
+
+ return 0;
+}
+#endif
diff --git a/win32port/win32helpers/gettimeofday.h b/win32port/win32helpers/gettimeofday.h
index 33e7a750..4531fa80 100644
--- a/win32port/win32helpers/gettimeofday.h
+++ b/win32port/win32helpers/gettimeofday.h
@@ -10,11 +10,11 @@
#endif
#ifdef LWS_MINGW_SUPPORT
- #include <winsock2.h>
+ #include <sys/time.h>
#endif
-#ifndef _TIMEZONE_DEFINED
-struct timezone
+#ifndef _TIMEZONE_DEFINED
+struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
@@ -22,6 +22,8 @@ struct timezone
#endif
+#ifndef LWS_MINGW_SUPPORT
int gettimeofday(struct timeval *tv, struct timezone *tz);
+#endif
#endif