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

Commit4b407f6

Browse files
committed
Changes for MinGW/WIN32:
o allow configure to see include/port/win32 include files o add matching Win32 accept() prototype o allow pg_id to compile with native Win32 API o fix invalide mbvalidate() function calls (existing bug) o allow /scripts to compile with native Win32 API o add win32.c to Win32 compiles (already in *.mak files)
1 parent7703e55 commit4b407f6

File tree

11 files changed

+121
-42
lines changed

11 files changed

+121
-42
lines changed

‎config/ac_func_accept_argtypes.m4

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/config/ac_func_accept_argtypes.m4,v 1.4 2002/03/29 17:32:53petere Exp $
1+
# $Header: /cvsroot/pgsql/config/ac_func_accept_argtypes.m4,v 1.5 2003/09/07 03:43:53momjian Exp $
22
# This comes from the official Autoconf macro archive at
33
# <http://research.cys.de/autoconf-archive/>
44
# (I removed the $ before the Id CVS keyword below.)
@@ -7,9 +7,10 @@
77
dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
88
dnl
99
dnl Checks the data types of the three arguments to accept(). Results are
10-
dnl placed into the symbols ACCEPT_TYPE_ARG[123],consistent with the
11-
dnl following example:
10+
dnl placed into the symbolsACCEPT_TYPE_RETURN andACCEPT_TYPE_ARG[123],
11+
dnlconsistent with thefollowing example:
1212
dnl
13+
dnl #define ACCEPT_TYPE_RETURN int
1314
dnl #define ACCEPT_TYPE_ARG1 int
1415
dnl #define ACCEPT_TYPE_ARG2 struct sockaddr *
1516
dnl #define ACCEPT_TYPE_ARG3 socklen_t
@@ -36,24 +37,29 @@ dnl
3637
# Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t'
3738
# which is *not* 'socklen_t *'). If we detect that, then we assume
3839
# 'int' as the result, because that ought to work best.
40+
#
41+
# On Win32, accept() returns 'unsigned int PASCAL'
3942

4043
AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
4144
[AC_MSG_CHECKING([types of arguments for accept()])
42-
AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
43-
[AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
44-
[AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
45-
[for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
46-
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
47-
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
48-
AC_TRY_COMPILE(
45+
AC_CACHE_VAL(ac_cv_func_accept_return,dnl
46+
[AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
47+
[AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
48+
[AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
49+
[for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
50+
for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
51+
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
52+
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
53+
AC_TRY_COMPILE(
4954
[#ifdef HAVE_SYS_TYPES_H
5055
#include <sys/types.h>
5156
#endif
5257
#ifdef HAVE_SYS_SOCKET_H
5358
#include <sys/socket.h>
5459
#endif
55-
extern int accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
56-
[],[ac_not_found=no; break 3],[ac_not_found=yes])
60+
extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
61+
[],[ac_not_found=no; break 4],[ac_not_found=yes])
62+
done
5763
done
5864
done
5965
done
@@ -63,10 +69,13 @@ extern int accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func
6369
if test "$ac_cv_func_accept_arg3" = "void"; then
6470
ac_cv_func_accept_arg3=int
6571
fi
72+
])dnl AC_CACHE_VAL
6673
])dnl AC_CACHE_VAL
6774
])dnl AC_CACHE_VAL
6875
])dnl AC_CACHE_VAL
69-
AC_MSG_RESULT([$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
76+
AC_MSG_RESULT([$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
77+
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_RETURN,$ac_cv_func_accept_return,
78+
[Define to the return type of 'accept'])
7079
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1,$ac_cv_func_accept_arg1,
7180
[Define to the type of arg 1 of 'accept'])
7281
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2,$ac_cv_func_accept_arg2,

‎configure

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,12 @@ fi
23702370
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
23712371
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
23722372

2373+
# We already have this in Makefile.win32, but configure needs it too
2374+
if test "$PORTNAME" = "win32"
2375+
then
2376+
CPPFLAGS="$CPPFLAGS -Isrc/include/port/win32"
2377+
fi
2378+
23732379
# Check if the compiler still works with the template settings
23742380
echo "$as_me:$LINENO: checking whether the C compiler still works" >&5
23752381
echo $ECHO_N "checking whether the C compiler still works... $ECHO_C" >&6
@@ -10810,19 +10816,23 @@ _ACEOF
1081010816
fi
1081110817
echo "$as_me:$LINENO: checking types of arguments for accept()" >&5
1081210818
echo $ECHO_N "checking types of arguments for accept()... $ECHO_C" >&6
10813-
if test "${ac_cv_func_accept_arg1+set}" = set; then
10819+
if test "${ac_cv_func_accept_return+set}" = set; then
1081410820
echo $ECHO_N "(cached) $ECHO_C" >&6
1081510821
else
10816-
if test "${ac_cv_func_accept_arg2+set}" = set; then
10822+
if test "${ac_cv_func_accept_arg1+set}" = set; then
1081710823
echo $ECHO_N "(cached) $ECHO_C" >&6
1081810824
else
10819-
if test "${ac_cv_func_accept_arg3+set}" = set; then
10825+
if test "${ac_cv_func_accept_arg2+set}" = set; then
1082010826
echo $ECHO_N "(cached) $ECHO_C" >&6
1082110827
else
10822-
for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
10823-
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
10824-
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
10825-
cat >conftest.$ac_ext <<_ACEOF
10828+
if test "${ac_cv_func_accept_arg3+set}" = set; then
10829+
echo $ECHO_N "(cached) $ECHO_C" >&6
10830+
else
10831+
for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
10832+
for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
10833+
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
10834+
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
10835+
cat >conftest.$ac_ext <<_ACEOF
1082610836
#line $LINENO "configure"
1082710837
#include "confdefs.h"
1082810838
#ifdef HAVE_SYS_TYPES_H
@@ -10831,7 +10841,7 @@ else
1083110841
#ifdef HAVE_SYS_SOCKET_H
1083210842
#include <sys/socket.h>
1083310843
#endif
10834-
externint accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);
10844+
extern$ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);
1083510845
#ifdef F77_DUMMY_MAIN
1083610846
# ifdef __cplusplus
1083710847
extern "C"
@@ -10858,13 +10868,14 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1085810868
ac_status=$?
1085910869
echo "$as_me:$LINENO: \$? = $ac_status" >&5
1086010870
(exit $ac_status); }; }; then
10861-
ac_not_found=no; break3
10871+
ac_not_found=no; break4
1086210872
else
1086310873
echo "$as_me: failed program was:" >&5
1086410874
cat conftest.$ac_ext >&5
1086510875
ac_not_found=yes
1086610876
fi
1086710877
rm -f conftest.$ac_objext conftest.$ac_ext
10878+
done
1086810879
done
1086910880
done
1087010881
done
@@ -10882,8 +10893,15 @@ fi
1088210893
fi
1088310894

1088410895
fi
10885-
echo "$as_me:$LINENO: result: $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&5
10886-
echo "${ECHO_T}$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&6
10896+
10897+
fi
10898+
echo "$as_me:$LINENO: result: $ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&5
10899+
echo "${ECHO_T}$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&6
10900+
10901+
cat >>confdefs.h <<_ACEOF
10902+
#define ACCEPT_TYPE_RETURN $ac_cv_func_accept_return
10903+
_ACEOF
10904+
1088710905

1088810906
cat >>confdefs.h <<_ACEOF
1088910907
#define ACCEPT_TYPE_ARG1 $ac_cv_func_accept_arg1

‎configure.in

Lines changed: 7 additions & 1 deletion
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.284 2003/09/07 03:36:02 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.285 2003/09/07 03:43:52 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -238,6 +238,12 @@ if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
238238
fi
239239
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
240240

241+
# We already have this in Makefile.win32, but configure needs it too
242+
if test "$PORTNAME" = "win32"
243+
then
244+
CPPFLAGS="$CPPFLAGS -Isrc/include/port/win32"
245+
fi
246+
241247
# Check if the compiler still works with the template settings
242248
AC_MSG_CHECKING([whether the C compiler still works])
243249
AC_TRY_LINK([], [return 0;],

‎src/bin/pg_id/pg_id.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.23 2003/09/06 01:41:56 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.24 2003/09/07 03:43:53 momjian Exp $
1010
*/
1111
#include"postgres_fe.h"
1212

@@ -28,10 +28,19 @@ main(int argc, char *argv[])
2828
use_real_uid_flag=0,
2929
limit_user_info=0;
3030
constchar*username=NULL;
31-
31+
externintoptind;
32+
#ifndefWIN32
3233
structpasswd*pw;
34+
#else
35+
structpasswd_win32
36+
{
37+
intpw_uid;
38+
charpw_name[128];
39+
}pass_win32;
40+
structpasswd_win32*pw=&pass_win32;
3341

34-
externintoptind;
42+
pw->pw_uid=1;
43+
#endif
3544

3645
while ((c=getopt(argc,argv,"nru"))!=-1)
3746
{
@@ -47,13 +56,24 @@ main(int argc, char *argv[])
4756
limit_user_info=1;
4857
break;
4958
default:
59+
#ifndefWIN32
5060
fprintf(stderr,"Usage: %s [-n] [-r] [-u] [username]\n",argv[0]);
61+
#else
62+
fprintf(stderr,"Usage: %s [-n] [-r] [-u]\n",argv[0]);
63+
#endif
5164
exit(1);
5265
}
5366
}
5467

5568
if (argc-optind >=1)
69+
#ifndefWIN32
5670
username=argv[optind];
71+
#else
72+
{
73+
fprintf(stderr,"%s: specifying a username is not supported on this platform\n",argv[0]);
74+
exit(1);
75+
}
76+
#endif
5777

5878
if (name_only_flag&& !limit_user_info)
5979
{
@@ -66,7 +86,7 @@ main(int argc, char *argv[])
6686
exit(1);
6787
}
6888

69-
89+
#ifndefWIN32
7090
if (username)
7191
{
7292
pw=getpwnam(username);
@@ -86,6 +106,15 @@ main(int argc, char *argv[])
86106
perror(argv[0]);
87107
exit(1);
88108
}
109+
#else
110+
if (!use_real_uid_flag)
111+
{
112+
fprintf(stderr,"%s: -r must be used on this platform\n",argv[0]);
113+
exit(1);
114+
}
115+
116+
GetUserName(pw->pw_name,sizeof(pw->pw_name)-1);
117+
#endif
89118

90119
if (!limit_user_info)
91120
printf("uid=%d(%s)\n", (int)pw->pw_uid,pw->pw_name);

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.12 2003/08/04 02:40:09 momjian Exp $
26+
* $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.13 2003/09/07 03:43:53 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -41,7 +41,6 @@
4141
#include"catalog/catversion.h"
4242
#include"catalog/pg_control.h"
4343

44-
4544
/******************** stuff copied from xlog.c ********************/
4645

4746
/* Increment an xlogid/segment pair */
@@ -81,6 +80,8 @@ static void KillExistingXLOG(void);
8180
staticvoidWriteEmptyXLOG(void);
8281
staticvoidusage(void);
8382

83+
externchar*optarg;
84+
8485

8586

8687
int

‎src/bin/psql/describe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.84 2003/08/09 01:21:54 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.85 2003/09/07 03:43:53 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -765,15 +765,15 @@ describeOneTableDetails(const char *schemaname,
765765
{
766766
/* Name */
767767
#ifdefWIN32
768-
cells[i*cols+0]=mbvalidate(PQgetvalue(res,i,0));
768+
cells[i*cols+0]=mbvalidate(PQgetvalue(res,i,0),myopt.encoding);
769769
#else
770770
cells[i*cols+0]=PQgetvalue(res,i,0);/* don't free this
771771
* afterwards */
772772
#endif
773773

774774
/* Type */
775775
#ifdefWIN32
776-
cells[i*cols+1]=mbvalidate(PQgetvalue(res,i,1));
776+
cells[i*cols+1]=mbvalidate(PQgetvalue(res,i,1),myopt.encoding);
777777
#else
778778
cells[i*cols+1]=PQgetvalue(res,i,1);/* don't free this
779779
* either */
@@ -797,7 +797,7 @@ describeOneTableDetails(const char *schemaname,
797797
}
798798

799799
#ifdefWIN32
800-
cells[i*cols+2]=xstrdup(mbvalidate(tmpbuf.data));
800+
cells[i*cols+2]=xstrdup(mbvalidate(tmpbuf.data,myopt.encoding));
801801
#else
802802
cells[i*cols+2]=xstrdup(tmpbuf.data);
803803
#endif
@@ -806,7 +806,7 @@ describeOneTableDetails(const char *schemaname,
806806
/* Description */
807807
if (verbose)
808808
#ifdefWIN32
809-
cells[i*cols+cols-1]=mbvalidate(PQgetvalue(res,i,5));
809+
cells[i*cols+cols-1]=mbvalidate(PQgetvalue(res,i,5),myopt.encoding);
810810
#else
811811
cells[i*cols+cols-1]=PQgetvalue(res,i,5);
812812
#endif

‎src/bin/psql/mbprint.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.10 2003/09/05 02:31:10 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.11 2003/09/07 03:43:54 momjian Exp $
77
*/
88

99
#include"postgres_fe.h"
10+
#ifndefPGSCRIPTS
11+
#include"settings.h"
12+
#endif
1013
#include"mbprint.h"
1114

1215
#include"mb/pg_wchar.h"
@@ -334,7 +337,7 @@ mbvalidate(unsigned char *pwcs, int encoding)
334337
returnmb_utf_validate(pwcs);
335338
else
336339
{
337-
#ifdefWIN32
340+
#if defined(WIN32)&& !defined(PGSCRIPTS)
338341
/*
339342
* translate characters to DOS console encoding, e.g. needed for
340343
* German umlauts

‎src/bin/scripts/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.22 2003/08/08 04:52:21 momjian Exp $
8+
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.23 2003/09/07 03:43:55 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
1515

1616
PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb
1717

18-
overrideCPPFLAGS := -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir)$(CPPFLAGS)
18+
overrideCPPFLAGS := -DPGSCRIPTS -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir)$(CPPFLAGS)
1919

2020
all: submake-libpq submake-backend$(PROGRAMS)
2121

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp