Skip to content

Commit 91812df

Browse files
committed
Enable building with the Mingw64 compiler.
This can be used to build 64 bit Windows binaries, not only on 64 bit Windows but on supported cross-compiling hosts including 32 bit Windows, Cygwin, Darwin and Linux.
1 parent 9688c4e commit 91812df

File tree

8 files changed

+32
-8
lines changed

8 files changed

+32
-8
lines changed

config/ac_func_accept_argtypes.m4

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ dnl
3838
# 'int' as the result, because that ought to work best.
3939
#
4040
# On Win32, accept() returns 'unsigned int PASCAL'
41+
# Win64 uses SOCKET for return and arg1
4142

4243
AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
4344
[AC_MSG_CHECKING([types of arguments for accept()])
4445
AC_CACHE_VAL(ac_cv_func_accept_return,dnl
4546
[AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
4647
[AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
4748
[AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
48-
[for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
49-
for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
49+
[for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET'; do
50+
for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
5051
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
5152
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
5253
AC_TRY_COMPILE(

configure

+2-2
Original file line numberDiff line numberDiff line change
@@ -18696,8 +18696,8 @@ else
1869618696
if test "${ac_cv_func_accept_arg3+set}" = set; then
1869718697
$as_echo_n "(cached) " >&6
1869818698
else
18699-
for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
18700-
for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
18699+
for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET'; do
18700+
for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
1870118701
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1870218702
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
1870318703
cat >conftest.$ac_ext <<_ACEOF

src/include/c.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#endif
5959
#include "postgres_ext.h"
6060

61-
#if _MSC_VER >= 1400
61+
#if _MSC_VER >= 1400 || defined(WIN64)
6262
#define errcode __msvc_errcode
6363
#include <crtdefs.h>
6464
#undef errcode

src/include/port.h

+4
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,12 @@ extern FILE *pgwin32_fopen(const char *, const char *);
325325
#define fopen(a,b) pgwin32_fopen(a,b)
326326
#endif
327327

328+
#ifndef popen
328329
#define popen(a,b) _popen(a,b)
330+
#endif
331+
#ifndef pclose
329332
#define pclose(a) _pclose(a)
333+
#endif
330334

331335
/* New versions of MingW have gettimeofday, old mingw and msvc don't */
332336
#ifndef HAVE_GETTIMEOFDAY

src/include/port/win32.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
#define WIN32_ONLY_COMPILER
55
#endif
66

7+
/*
8+
* Make sure _WIN32_WINNT has the minumum required value.
9+
* Leave a higher value in place.
10+
*/
11+
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
12+
#undefine _WIN32_WINNT
13+
#endif
14+
#ifndef _WIN32_WINNT
715
#define _WIN32_WINNT 0x0501
16+
#endif
817
/*
918
* Always build with SSPI support. Keep it as a #define in case
1019
* we want a switch to disable it sometime in the future.
@@ -17,10 +26,17 @@
1726
#undef mkdir
1827

1928
#undef ERROR
29+
30+
/*
31+
* The Mingw64 headers choke if this is already defined - they
32+
* define it themselves.
33+
*/
34+
#if !defined(WIN64) || defined(WIN32_ONLY_COMPILER)
2035
#define _WINSOCKAPI_
21-
#include <windows.h>
36+
#endif
2237
#include <winsock2.h>
2338
#include <ws2tcpip.h>
39+
#include <windows.h>
2440
#undef small
2541
#include <process.h>
2642
#include <signal.h>

src/include/port/win32/sys/socket.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
#include <winsock2.h>
1515
#include <ws2tcpip.h>
16+
#include <windows.h>
1617

1718
#undef ERROR
1819
#undef small

src/port/getaddrinfo.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ gai_strerror(int errcode)
329329
return "Not enough memory";
330330
#endif
331331
#ifdef EAI_NODATA
332-
#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the
333-
* same value */
332+
#if !defined(WIN64) && !defined(WIN32_ONLY_COMPILER) /* MSVC/WIN64 duplicate */
334333
case EAI_NODATA:
335334
return "No host data of that type was found";
336335
#endif

src/test/regress/resultmap

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
float4:out:i.86-pc-mingw32=float4-exp-three-digits.out
2+
float4:out:x86_64-w64-mingw32=float4-exp-three-digits.out
23
float4:out:i.86-pc-win32vc=float4-exp-three-digits.out
34
float8:out:i.86-.*-freebsd=float8-small-is-zero.out
45
float8:out:i.86-.*-openbsd=float8-small-is-zero.out
56
float8:out:i.86-.*-netbsd=float8-small-is-zero.out
67
float8:out:m68k-.*-netbsd=float8-small-is-zero.out
78
float8:out:i.86-pc-mingw32=float8-exp-three-digits-win32.out
9+
float8:out:x86_64-w64-mingw32=float8-exp-three-digits-win32.out
810
float8:out:i.86-pc-win32vc=float8-exp-three-digits-win32.out
911
float8:out:i.86-pc-cygwin=float8-small-is-zero.out
1012
int8:out:i.86-pc-mingw32=int8-exp-three-digits.out
13+
int8:out:x86_64-w64-mingw32=int8-exp-three-digits.out
1114
int8:out:i.86-pc-win32vc=int8-exp-three-digits.out

0 commit comments

Comments
 (0)