Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12c9423

Browse files
committed
Allow Win32 to compile under MinGW. Major changes are:
Win32 port is now called 'win32' rather than 'win' add -lwsock32 on Win32 make gethostname() be only used when kerberos4 is enabled use /port/getopt.c new /port/opendir.c routines disable GUC unix_socket_group on Win32 convert some keywords.c symbols to KEYWORD_P to prevent conflict create new FCNTL_NONBLOCK macro to turn off socket blocking create new /include/port.h file that has /port prototypes, move out of c.h new /include/port/win32_include dir to hold missing include files work around ERROR being defined in Win32 includes
1 parent2c05560 commit12c9423

File tree

39 files changed

+486
-358
lines changed

39 files changed

+486
-358
lines changed

‎configure

Lines changed: 142 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ case $host_os in
13931393
hpux*) template=hpux ;;
13941394
irix*) template=irix5 ;;
13951395
linux*) template=linux ;;
1396-
mingw*) template=win ;;
1396+
mingw*) template=win32 ;;
13971397
netbsd*) template=netbsd ;;
13981398
nextstep*) template=nextstep ;;
13991399
openbsd*) template=openbsd ;;
@@ -2808,7 +2808,6 @@ echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
28082808
done
28092809
IFS=$ac_save_IFS
28102810
2811-
28122811
#
28132812
# Tcl/Tk
28142813
#
@@ -5236,6 +5235,65 @@ _ACEOF
52365235
52375236
fi
52385237
5238+
5239+
echo"$as_me:$LINENO: checking for main in -lwsock32">&5
5240+
echo$ECHO_N"checking for main in -lwsock32...$ECHO_C">&6
5241+
iftest"${ac_cv_lib_wsock32_main+set}" =set;then
5242+
echo$ECHO_N"(cached)$ECHO_C">&6
5243+
else
5244+
ac_check_lib_save_LIBS=$LIBS
5245+
LIBS="-lwsock32$LIBS"
5246+
cat>conftest.$ac_ext<<_ACEOF
5247+
#line$LINENO "configure"
5248+
#include "confdefs.h"
5249+
5250+
5251+
#ifdef F77_DUMMY_MAIN
5252+
# ifdef __cplusplus
5253+
extern "C"
5254+
# endif
5255+
int F77_DUMMY_MAIN() { return 1; }
5256+
#endif
5257+
int
5258+
main ()
5259+
{
5260+
main ();
5261+
;
5262+
return 0;
5263+
}
5264+
_ACEOF
5265+
rm -f conftest.$ac_objext conftest$ac_exeext
5266+
if { (evalecho"$as_me:$LINENO:\"$ac_link\"")>&5
5267+
(eval$ac_link)2>&5
5268+
ac_status=$?
5269+
echo"$as_me:$LINENO:\$? =$ac_status">&5
5270+
(exit$ac_status); }&&
5271+
{ ac_try='test -s conftest$ac_exeext'
5272+
{ (evalecho"$as_me:$LINENO:\"$ac_try\"")>&5
5273+
(eval$ac_try)2>&5
5274+
ac_status=$?
5275+
echo"$as_me:$LINENO:\$? =$ac_status">&5
5276+
(exit$ac_status); }; };then
5277+
ac_cv_lib_wsock32_main=yes
5278+
else
5279+
echo"$as_me: failed program was:">&5
5280+
cat conftest.$ac_ext>&5
5281+
ac_cv_lib_wsock32_main=no
5282+
fi
5283+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
5284+
LIBS=$ac_check_lib_save_LIBS
5285+
fi
5286+
echo"$as_me:$LINENO: result:$ac_cv_lib_wsock32_main">&5
5287+
echo"${ECHO_T}$ac_cv_lib_wsock32_main">&6
5288+
iftest$ac_cv_lib_wsock32_main = yes;then
5289+
cat>>confdefs.h<<_ACEOF
5290+
#define HAVE_LIBWSOCK32 1
5291+
_ACEOF
5292+
5293+
LIBS="-lwsock32$LIBS"
5294+
5295+
fi
5296+
52395297
echo"$as_me:$LINENO: checking for library containing getopt_long">&5
52405298
echo$ECHO_N"checking for library containing getopt_long...$ECHO_C">&6
52415299
iftest"${ac_cv_search_getopt_long+set}" =set;then
@@ -6072,6 +6130,85 @@ echo "$as_me: error: library 'krb' is required for Kerberos 4" >&2;}
60726130
{ (exit 1);exit 1; }; }
60736131
fi
60746132
6133+
6134+
forac_funcin gethostname
6135+
do
6136+
as_ac_var=`echo"ac_cv_func_$ac_func"|$as_tr_sh`
6137+
echo"$as_me:$LINENO: checking for$ac_func">&5
6138+
echo$ECHO_N"checking for$ac_func...$ECHO_C">&6
6139+
ifeval"test\"\${$as_ac_var+set}\" = set";then
6140+
echo$ECHO_N"(cached)$ECHO_C">&6
6141+
else
6142+
cat>conftest.$ac_ext<<_ACEOF
6143+
#line$LINENO "configure"
6144+
#include "confdefs.h"
6145+
/* System header to define __stub macros and hopefully few prototypes,
6146+
which can conflict with char$ac_func (); below. */
6147+
#include <assert.h>
6148+
/* Override any gcc2 internal prototype to avoid an error. */
6149+
#ifdef __cplusplus
6150+
extern "C"
6151+
#endif
6152+
/* We use char because int might match the return type of a gcc2
6153+
builtin and then its argument prototype would still apply. */
6154+
char$ac_func ();
6155+
char (*f) ();
6156+
6157+
#ifdef F77_DUMMY_MAIN
6158+
# ifdef __cplusplus
6159+
extern "C"
6160+
# endif
6161+
int F77_DUMMY_MAIN() { return 1; }
6162+
#endif
6163+
int
6164+
main ()
6165+
{
6166+
/* The GNU C library defines this for functions which it implements
6167+
to always fail with ENOSYS. Some functions are actually named
6168+
something starting with __ and the normal name is an alias. */
6169+
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
6170+
choke me
6171+
#else
6172+
f =$ac_func;
6173+
#endif
6174+
6175+
;
6176+
return 0;
6177+
}
6178+
_ACEOF
6179+
rm -f conftest.$ac_objext conftest$ac_exeext
6180+
if { (evalecho"$as_me:$LINENO:\"$ac_link\"")>&5
6181+
(eval$ac_link)2>&5
6182+
ac_status=$?
6183+
echo"$as_me:$LINENO:\$? =$ac_status">&5
6184+
(exit$ac_status); }&&
6185+
{ ac_try='test -s conftest$ac_exeext'
6186+
{ (evalecho"$as_me:$LINENO:\"$ac_try\"")>&5
6187+
(eval$ac_try)2>&5
6188+
ac_status=$?
6189+
echo"$as_me:$LINENO:\$? =$ac_status">&5
6190+
(exit$ac_status); }; };then
6191+
eval"$as_ac_var=yes"
6192+
else
6193+
echo"$as_me: failed program was:">&5
6194+
cat conftest.$ac_ext>&5
6195+
eval"$as_ac_var=no"
6196+
fi
6197+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
6198+
fi
6199+
echo"$as_me:$LINENO: result:`evalecho'${'$as_ac_var'}'`">&5
6200+
echo"${ECHO_T}`evalecho'${'$as_ac_var'}'`">&6
6201+
iftest`evalecho'${'$as_ac_var'}'` = yes;then
6202+
cat>>confdefs.h<<_ACEOF
6203+
#define`echo"HAVE_$ac_func"|$as_tr_cpp` 1
6204+
_ACEOF
6205+
6206+
else
6207+
LIBOBJS="$LIBOBJS$ac_func.$ac_objext"
6208+
fi
6209+
done
6210+
6211+
60756212
fi
60766213
60776214
iftest"$with_krb5" = yes;then
@@ -11080,7 +11217,7 @@ fi
1108011217
1108111218
1108211219
11083-
forac_funcin crypt fseekogethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
11220+
forac_funcin crypt fseekogetopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
1108411221
do
1108511222
as_ac_var=`echo"ac_cv_func_$ac_func"|$as_tr_sh`
1108611223
echo"$as_me:$LINENO: checking for$ac_func">&5
@@ -11258,9 +11395,8 @@ LIBOBJS="$LIBOBJS qsort.$ac_objext" ;;
1125811395
esac
1125911396
1126011397
# Win32 can't to rename or unlink on an open file
11261-
case$host_osin win32*)
11262-
LIBOBJS="$LIBOBJS dirmod.$ac_objext"
11263-
LIBOBJS="$LIBOBJS opendir.$ac_objext" ;;
11398+
case$host_osin win32*|mingw*)
11399+
LIBOBJS="$LIBOBJS dirmod.$ac_objext" ;;
1126411400
esac
1126511401
1126611402
iftest"$with_readline" = yes;then

‎configure.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.249 2003/05/10 04:03:37 momjian Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.250 2003/05/15 16:35:27 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -65,7 +65,7 @@ case $host_os in
6565
hpux*) template=hpux ;;
6666
irix*) template=irix5 ;;
6767
linux*) template=linux ;;
68-
mingw*) template=win ;;
68+
mingw*) template=win32 ;;
6969
netbsd*) template=netbsd ;;
7070
nextstep*) template=nextstep ;;
7171
openbsd*) template=openbsd ;;
@@ -319,7 +319,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
319319
done
320320
IFS=$ac_save_IFS
321321

322-
323322
#
324323
# Tcl/Tk
325324
#
@@ -607,6 +606,7 @@ AC_CHECK_LIB(BSD, main)
607606
AC_CHECK_LIB(gen, main)
608607
AC_CHECK_LIB(PW, main)
609608
AC_CHECK_LIB(resolv, main)
609+
AC_CHECK_LIB(wsock32, main)
610610
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
611611
# QNX:
612612
AC_CHECK_LIB(unix, main)
@@ -639,6 +639,7 @@ fi
639639
if test "$with_krb4" = yes ; then
640640
AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
641641
AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
642+
AC_REPLACE_FUNCS([gethostname])
642643
fi
643644

644645
if test "$with_krb5" = yes ; then
@@ -839,7 +840,7 @@ else
839840
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
840841
fi
841842

842-
AC_REPLACE_FUNCS([crypt fseekogethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
843+
AC_REPLACE_FUNCS([crypt fseekogetopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
843844

844845
# system's version of getaddrinfo(), if any, may be used only if we found
845846
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
@@ -862,9 +863,8 @@ AC_LIBOBJ(qsort) ;;
862863
esac
863864

864865
# Win32 can't to rename or unlink on an open file
865-
case $host_os in win32*)
866-
AC_LIBOBJ(dirmod)
867-
AC_LIBOBJ(opendir) ;;
866+
case $host_os in win32*|mingw*)
867+
AC_LIBOBJ(dirmod) ;;
868868
esac
869869

870870
if test "$with_readline" = yes; then

‎doc/TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TODO list for PostgreSQL
22
========================
3-
Last updated:Wed Apr 2 17:44:34 EST 2003
3+
Last updated:Thu May 15 12:10:39 EDT 2003
44

55
Current maintainer:Bruce Momjian (pgman@candle.pha.pa.us)
66

‎src/backend/libpq/be-secure.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.31 2003/04/25 04:37:23 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.32 2003/05/15 16:35:28 momjian Exp $
1515
*
1616
* Since the server static private key ($DataDir/server.key)
1717
* will normally be stored unencrypted so that the database
@@ -85,16 +85,12 @@
8585
#include"libpq/libpq.h"
8686
#include"miscadmin.h"
8787

88-
#ifdefWIN32
89-
#include"win32.h"
90-
#else
9188
#include<sys/socket.h>
9289
#include<unistd.h>
9390
#include<netdb.h>
9491
#include<netinet/in.h>
9592
#ifdefHAVE_NETINET_TCP_H
9693
#include<netinet/tcp.h>
97-
#endif
9894
#include<arpa/inet.h>
9995
#endif
10096

‎src/backend/libpq/pqcomm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
33-
*$Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.152 2003/04/25 01:24:00 momjian Exp $
33+
*$Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.153 2003/05/15 16:35:28 momjian Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -357,6 +357,9 @@ Setup_AF_UNIX(void)
357357
Assert(Unix_socket_group);
358358
if (Unix_socket_group[0]!='\0')
359359
{
360+
#ifdefWIN32
361+
elog(FATAL,"Config value 'unix_socket_group' not supported on this platform");
362+
#else
360363
char*endptr;
361364
unsigned longintval;
362365
gid_tgid;
@@ -385,6 +388,7 @@ Setup_AF_UNIX(void)
385388
sock_path,strerror(errno));
386389
returnSTATUS_ERROR;
387390
}
391+
#endif
388392
}
389393

390394
if (chmod(sock_path,Unix_socket_permissions)==-1)

‎src/backend/main/main.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.56 2002/11/08 20:23:56 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.57 2003/05/15 16:35:28 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -159,13 +159,14 @@ main(int argc, char *argv[])
159159
strcmp(argv[1],"--version")==0||
160160
strcmp(argv[1],"-V")==0)))
161161
{
162+
#ifndefWIN32
163+
#ifndef__BEOS__
162164
/*
163165
* Make sure we are not running as root.
164166
*
165167
* BeOS currently runs everything as root :-(, so this check must be
166168
* temporarily disabled there...
167169
*/
168-
#ifndef__BEOS__
169170
if (geteuid()==0)
170171
{
171172
fprintf(stderr,gettext(
@@ -176,7 +177,7 @@ main(int argc, char *argv[])
176177
));
177178
exit(1);
178179
}
179-
#endif/* __BEOS__ */
180+
#endif/*!__BEOS__ */
180181

181182
/*
182183
* Also make sure that real and effective uids are the same.
@@ -193,6 +194,7 @@ main(int argc, char *argv[])
193194
argv[0]);
194195
exit(1);
195196
}
197+
#endif/* !WIN32 */
196198
}
197199

198200
/*
@@ -221,6 +223,7 @@ main(int argc, char *argv[])
221223
* specifying current userid as the "authenticated" Postgres user
222224
* name.
223225
*/
226+
#ifndefWIN32
224227
pw=getpwuid(geteuid());
225228
if (pw==NULL)
226229
{
@@ -230,6 +233,18 @@ main(int argc, char *argv[])
230233
}
231234
/* Allocate new memory because later getpwuid() calls can overwrite it */
232235
pw_name_persist=strdup(pw->pw_name);
236+
#else
237+
{
238+
longnamesize=256/* UNLEN */+1;
239+
240+
pw_name_persist=malloc(namesize);
241+
if (!GetUserName(pw_name_persist,&namesize))
242+
{
243+
fprintf(stderr,"%s: GetUserName failed\n",argv[0]);
244+
exit(1);
245+
}
246+
}
247+
#endif
233248

234249
exit(PostgresMain(argc,new_argv,pw_name_persist));
235250
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp