Backport changes to allow building with MinGW 64 bit compiler.
authorAndrew Dunstan <andrew@dunslane.net>
Sat, 9 Apr 2011 21:59:27 +0000 (17:59 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Sat, 9 Apr 2011 21:59:27 +0000 (17:59 -0400)
These changes have been in HEAD for some time with no ill effect. They
are only being backported to 9.0, as the required WINNT version was not
high enough before that.

config/ac_func_accept_argtypes.m4
configure
src/include/c.h
src/include/port.h
src/include/port/win32.h
src/include/port/win32/sys/socket.h
src/port/getaddrinfo.c
src/test/regress/resultmap

index 4ac5ce0eb9458edaa70e4e1b44f563446f05826d..c64f3f8ffb61bf6eaa28dc01a93295a3b0f2a935 100644 (file)
@@ -38,6 +38,7 @@ dnl
 # 'int' as the result, because that ought to work best.
 #
 # On Win32, accept() returns 'unsigned int PASCAL' 
+# Win64 uses SOCKET for return and arg1
 
 AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
 [AC_MSG_CHECKING([types of arguments for accept()])
@@ -45,8 +46,8 @@ AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
  [AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
   [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
    [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
-    [for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
-      for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
+    [for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET'; do
+      for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
        for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
         for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
          AC_TRY_COMPILE(
index a4f4c9ef34e61a43e8acd7d8eb08ff7796a3f4ac..3338eea3cf53e35e13348f608ca8661168fddc3f 100755 (executable)
--- a/configure
+++ b/configure
@@ -18472,8 +18472,8 @@ else
      if test "${ac_cv_func_accept_arg3+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-      for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
-      for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
+      for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET'; do
+      for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
        for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
         for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
          cat >conftest.$ac_ext <<_ACEOF
index bec1a8cc85183fccdf1d3550d9e22c4fa4e3e55e..1f2813c90f677d89f948054e133b6d1b82c1de24 100644 (file)
@@ -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
index 65b80ef513412b748866a3e4122ea29c0bb7c2a4..2794002ca9ec60fbf721ee7e6891913ab8863261 100644 (file)
@@ -333,8 +333,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
index 1473d9e8c3c3e546d47f396af1a8067e7c5d98e2..5d41fd3ac74e0579ec72b2c03a4141ba799b41e0 100644 (file)
@@ -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
+#undef _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.
 #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>
index 97a504179918761a9324e8747236768ce6f98ffa..e811919c979cb0a9182ceebe672e91ecf0b5557b 100644 (file)
@@ -13,6 +13,7 @@
  */
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#include <windows.h>
 
 #undef ERROR
 #undef small
index 4133aed54d75d89c9e34d1966f0035157c4d9dc5..cf658a4eb50873dffcfc57d841ff52a67e319430 100644 (file)
@@ -329,8 +329,7 @@ gai_strerror(int errcode)
            return "Not enough memory";
 #endif
 #ifdef EAI_NODATA
-#ifndef WIN32_ONLY_COMPILER        /* MSVC complains because another case has the
-                                * same value */
+#if !defined(WIN64) && !defined(WIN32_ONLY_COMPILER) /* MSVC/WIN64 duplicate */
        case EAI_NODATA:
            return "No host data of that type was found";
 #endif
index 7bfcee29b4841beb296f8c681bf78e8087712f0d..d02d221d56fd5d35420499181d012a9b8d7c1fa0 100644 (file)
@@ -1,11 +1,14 @@
 float4:out:i.86-pc-mingw32=float4-exp-three-digits.out
+float4:out:x86_64-w64-mingw32=float4-exp-three-digits.out
 float4:out:i.86-pc-win32vc=float4-exp-three-digits.out
 float8:out:i.86-.*-freebsd=float8-small-is-zero.out
 float8:out:i.86-.*-openbsd=float8-small-is-zero.out
 float8:out:i.86-.*-netbsd=float8-small-is-zero.out
 float8:out:m68k-.*-netbsd=float8-small-is-zero.out
 float8:out:i.86-pc-mingw32=float8-exp-three-digits-win32.out
+float8:out:x86_64-w64-mingw32=float8-exp-three-digits-win32.out
 float8:out:i.86-pc-win32vc=float8-exp-three-digits-win32.out
 float8:out:i.86-pc-cygwin=float8-small-is-zero.out
 int8:out:i.86-pc-mingw32=int8-exp-three-digits.out
+int8:out:x86_64-w64-mingw32=int8-exp-three-digits.out
 int8:out:i.86-pc-win32vc=int8-exp-three-digits.out