From db1c3672881ac63626966634ce1d8788d1390519 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 16 Dec 2024 10:01:27 +0100 Subject: [PATCH 1/3] win32: define struct timezone for non-mingw-w32 The compiler complains if the structure used in the .c file is defined after an anonymous version was used in the header. --- include/win32/win32_compat.h | 8 +++++++- win32/win32_compat.c | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/win32/win32_compat.h b/include/win32/win32_compat.h index 70214b79..e11bf70b 100755 --- a/include/win32/win32_compat.h +++ b/include/win32/win32_compat.h @@ -150,9 +150,15 @@ struct pollfd { int getpid(void); int win32_inet_pton(int af, const char * src, void * dst); int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout); -int win32_gettimeofday(struct timeval *tv, struct timezone *tz); #ifdef __MINGW32__ # define win32_gettimeofday mingw_gettimeofday +#else +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; +int win32_gettimeofday(struct timeval *tv, struct timezone *tz); #endif #define DllExport diff --git a/win32/win32_compat.c b/win32/win32_compat.c index 36547886..fb5f0aa4 100644 --- a/win32/win32_compat.c +++ b/win32/win32_compat.c @@ -157,12 +157,6 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo) #endif #ifndef __MINGW32__ -struct timezone -{ - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - int win32_gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ft; From c8f31cee078e3f378fc2c9b0eb30128d3f0bc612 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 16 Dec 2024 10:02:36 +0100 Subject: [PATCH 2/3] win32: don't include win32_compat.h in libnfs-raw.h The file is not installed, and it's not needed. --- include/nfsc/libnfs-raw.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/nfsc/libnfs-raw.h b/include/nfsc/libnfs-raw.h index 80d31f4e..0bd88a20 100644 --- a/include/nfsc/libnfs-raw.h +++ b/include/nfsc/libnfs-raw.h @@ -39,10 +39,6 @@ #include "ps3_compat.h" #endif -#ifdef WIN32 -#include -#endif - #include #if defined(HAVE_SYS_UIO_H) || (defined(__APPLE__) && defined(__MACH__)) From f7cc1fefc50209ac822e8f68f79150b142354fce Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 16 Dec 2024 10:06:20 +0100 Subject: [PATCH 3/3] win32: fix build with MSVC strndup doesn't exist, but there's a compat version for that. --- include/win32/win32_compat.h | 2 +- lib/nfs_v4.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/win32/win32_compat.h b/include/win32/win32_compat.h index e11bf70b..09f8eb11 100755 --- a/include/win32/win32_compat.h +++ b/include/win32/win32_compat.h @@ -163,7 +163,7 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz); #define DllExport -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) char* libnfs_strndup(const char *s, size_t n); #define strndup libnfs_strndup #endif diff --git a/lib/nfs_v4.c b/lib/nfs_v4.c index 948187de..60f03437 100644 --- a/lib/nfs_v4.c +++ b/lib/nfs_v4.c @@ -88,6 +88,10 @@ #include #endif +#ifdef WIN32 +#include +#endif + #include #include #include