From bc8febdc85afc78fe70b05e7681e3f23c30c48c7 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 28 Jan 2011 12:20:55 -0500 Subject: [PATCH 1/3] minimal changes required for build --- config/ac_func_accept_argtypes.m4 | 4 ++-- configure | 4 ++-- src/include/c.h | 2 +- src/include/port.h | 4 ++++ src/include/port/win32.h | 8 +++++++- src/include/port/win32/sys/socket.h | 1 + src/port/getaddrinfo.c | 2 +- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/ac_func_accept_argtypes.m4 b/config/ac_func_accept_argtypes.m4 index 7cb5cb3776..f4059ec669 100644 --- a/config/ac_func_accept_argtypes.m4 +++ b/config/ac_func_accept_argtypes.m4 @@ -45,8 +45,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' '__int64'; do + for ac_cv_func_accept_arg1 in 'int' 'unsigned int' '__int64'; 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( diff --git a/configure b/configure index 8ff61a6f77..0b91294bba 100755 --- a/configure +++ b/configure @@ -18696,8 +18696,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' '__int64'; do + for ac_cv_func_accept_arg1 in 'int' 'unsigned int' '__int64'; 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 diff --git a/src/include/c.h b/src/include/c.h index 634b21fa94..af1be9499e 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 #undef errcode diff --git a/src/include/port.h b/src/include/port.h index 7ad464c07d..4d40cef7b4 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 93439f763d..6ad4108bfe 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -4,7 +4,9 @@ #define WIN32_ONLY_COMPILER #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 +19,14 @@ #undef mkdir #undef ERROR +#ifdef WIN64 +#define _WINSOCK2API_ +#else #define _WINSOCKAPI_ -#include +#endif #include #include +#include #undef small #include #include diff --git a/src/include/port/win32/sys/socket.h b/src/include/port/win32/sys/socket.h index 6947ec07d6..edaee6a894 100644 --- a/src/include/port/win32/sys/socket.h +++ b/src/include/port/win32/sys/socket.h @@ -13,6 +13,7 @@ */ #include #include +#include #undef ERROR #undef small diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c index 654858e639..9a59e4ad2b 100644 --- a/src/port/getaddrinfo.c +++ b/src/port/getaddrinfo.c @@ -329,7 +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 +#ifndef WIN32/* MSVC complains because another case has the * same value */ case EAI_NODATA: return "No host data of that type was found"; From c8ee651d632b3ee632d955cf3ceb13155ba883a0 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 28 Jan 2011 22:28:28 -0500 Subject: [PATCH 2/3] fix winsock declarations --- src/include/port/win32.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/include/port/win32.h b/src/include/port/win32.h index 6ad4108bfe..507a61e635 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -19,9 +19,7 @@ #undef mkdir #undef ERROR -#ifdef WIN64 -#define _WINSOCK2API_ -#else +#ifndef WIN64 #define _WINSOCKAPI_ #endif #include From b05ffaef7ffa8ef67a57ed1f97c63920448a406f Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 28 Jan 2011 22:29:30 -0500 Subject: [PATCH 3/3] fix resultmap for cross-compile --- src/test/regress/resultmap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/regress/resultmap b/src/test/regress/resultmap index 7bfcee29b4..d02d221d56 100644 --- a/src/test/regress/resultmap +++ b/src/test/regress/resultmap @@ -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