aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/c.h2
-rw-r--r--src/include/port.h4
-rw-r--r--src/include/port/win32.h18
-rw-r--r--src/include/port/win32/sys/socket.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 634b21fa949..af1be9499ef 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -58,7 +58,7 @@
#endif
#include "postgres_ext.h"
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 || defined(WIN64)
#define errcode __msvc_errcode
#include <crtdefs.h>
#undef errcode
diff --git a/src/include/port.h b/src/include/port.h
index 7ad464c07dc..4d40cef7b4b 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -325,8 +325,12 @@ extern FILE *pgwin32_fopen(const char *, const char *);
#define fopen(a,b) pgwin32_fopen(a,b)
#endif
+#ifndef popen
#define popen(a,b) _popen(a,b)
+#endif
+#ifndef pclose
#define pclose(a) _pclose(a)
+#endif
/* New versions of MingW have gettimeofday, old mingw and msvc don't */
#ifndef HAVE_GETTIMEOFDAY
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index 93439f763d0..6d99ecbe88d 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -4,7 +4,16 @@
#define WIN32_ONLY_COMPILER
#endif
+/*
+ * Make sure _WIN32_WINNT has the minumum required value.
+ * Leave a higher value in place.
+*/
+#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
+#undefine _WIN32_WINNT
+#endif
+#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
+#endif
/*
* Always build with SSPI support. Keep it as a #define in case
* we want a switch to disable it sometime in the future.
@@ -17,10 +26,17 @@
#undef mkdir
#undef ERROR
+
+/*
+ * The Mingw64 headers choke if this is already defined - they
+ * define it themselves.
+ */
+#if !defined(WIN64) || defined(WIN32_ONLY_COMPILER)
#define _WINSOCKAPI_
-#include <windows.h>
+#endif
#include <winsock2.h>
#include <ws2tcpip.h>
+#include <windows.h>
#undef small
#include <process.h>
#include <signal.h>
diff --git a/src/include/port/win32/sys/socket.h b/src/include/port/win32/sys/socket.h
index 6947ec07d62..edaee6a894c 100644
--- a/src/include/port/win32/sys/socket.h
+++ b/src/include/port/win32/sys/socket.h
@@ -13,6 +13,7 @@
*/
#include <winsock2.h>
#include <ws2tcpip.h>
+#include <windows.h>
#undef ERROR
#undef small