Skip to content

Commit 399a36a

Browse files
committed
Prepare code to be built by MSVC:
o remove many WIN32_CLIENT_ONLY defines o add WIN32_ONLY_COMPILER define o add 3rd argument to open() for portability o add include/port/win32_msvc directory for system includes Magnus Hagander
1 parent 877e296 commit 399a36a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1151
-217
lines changed

configure

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15064,6 +15064,14 @@ case $LIBOBJS in
1506415064
*) LIBOBJS="$LIBOBJS rand.$ac_objext" ;;
1506515065
esac
1506615066

15067+
case $LIBOBJS in
15068+
"win32error.$ac_objext" | \
15069+
*" win32error.$ac_objext" | \
15070+
"win32error.$ac_objext "* | \
15071+
*" win32error.$ac_objext "* ) ;;
15072+
*) LIBOBJS="$LIBOBJS win32error.$ac_objext" ;;
15073+
esac
15074+
1506715075

1506815076
cat >>confdefs.h <<\_ACEOF
1506915077
#define HAVE_SYMLINK 1

configure.in

Lines changed: 2 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 $PostgreSQL: pgsql/configure.in,v 1.465 2006/05/30 13:52:24 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.466 2006/06/07 22:24:43 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -994,6 +994,7 @@ AC_LIBOBJ(gettimeofday)
994994
AC_LIBOBJ(kill)
995995
AC_LIBOBJ(open)
996996
AC_LIBOBJ(rand)
997+
AC_LIBOBJ(win32error)
997998
AC_DEFINE([HAVE_SYMLINK], 1,
998999
[Define to 1 if you have the `symlink' function.])
9991000
fi

src/backend/libpq/ip.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.34 2006/03/05 15:58:27 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.35 2006/06/07 22:24:43 momjian Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -20,7 +20,6 @@
2020
/* This is intended to be used in both frontend and backend, so use c.h */
2121
#include "c.h"
2222

23-
#ifndef WIN32_CLIENT_ONLY
2423
#include <errno.h>
2524
#include <unistd.h>
2625
#include <sys/types.h>
@@ -33,7 +32,6 @@
3332
#endif
3433
#include <arpa/inet.h>
3534
#include <sys/file.h>
36-
#endif
3735

3836
#include "libpq/ip.h"
3937

src/backend/port/dynloader/win32.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.7 2005/10/15 02:49:23 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.8 2006/06/07 22:24:43 momjian Exp $ */
22

3-
#include <windows.h>
4-
#include <stdio.h>
3+
#include "postgres.h"
54

65
char *dlerror(void);
76
int dlclose(void *handle);

src/backend/port/win32/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for backend/port/win32
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.7 2006/04/29 20:52:56 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.8 2006/06/07 22:24:43 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/port/win32
1212
top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = shmem.o timer.o socket.o signal.o security.o error.o
15+
OBJS = shmem.o timer.o socket.o signal.o security.o
1616

1717
all: SUBSYS.o
1818

src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.484 2006/05/19 15:15:37 alvherre Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.485 2006/06/07 22:24:44 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -1121,7 +1121,7 @@ pmdaemonize(void)
11211121
ExitPostmaster(1);
11221122
}
11231123
#endif
1124-
i = open(NULL_DEV, O_RDWR);
1124+
i = open(NULL_DEV, O_RDWR, 0);
11251125
dup2(i, 0);
11261126
dup2(i, 1);
11271127
dup2(i, 2);

src/backend/postmaster/syslogger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.23 2006/03/05 15:58:36 momjian Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.24 2006/06/07 22:24:44 momjian Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -153,7 +153,7 @@ SysLoggerMain(int argc, char *argv[])
153153
*/
154154
if (redirection_done)
155155
{
156-
int fd = open(NULL_DEV, O_WRONLY);
156+
int fd = open(NULL_DEV, O_WRONLY, 0);
157157

158158
/*
159159
* The closes might look redundant, but they are not: we want to be

src/backend/utils/adt/float.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.124 2006/04/24 20:36:32 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.125 2006/06/07 22:24:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -80,6 +80,14 @@
8080
#define HAVE_FINITE 1
8181
#endif
8282

83+
/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0. NAN definition from
84+
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrfNotNumberNANItems.asp
85+
*/
86+
#if defined(WIN32) && !defined(NAN)
87+
static const uint32 nan[2] = {0xffffffff, 0x7fffffff};
88+
#define NAN (*(const double *) nan)
89+
#endif
90+
8391
/* not sure what the following should be, but better to make it over-sufficient */
8492
#define MAXFLOATWIDTH 64
8593
#define MAXDOUBLEWIDTH 128

src/backend/utils/fmgr/dfmgr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.85 2006/05/31 20:58:09 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.86 2006/06/07 22:24:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include "postgres.h"
1616

1717
#include <sys/stat.h>
1818

19+
#ifndef WIN32_ONLY_COMPILER
1920
#include "dynloader.h"
21+
#else
22+
#include "port/dynloader/win32.h"
23+
#endif
2024
#include "miscadmin.h"
2125
#include "utils/dynamic_loader.h"
2226

src/backend/utils/mb/encnames.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Encoding names and routines for work with it. All
33
* in this file is shared bedween FE and BE.
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.29 2006/02/18 16:15:22 petere Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.30 2006/06/07 22:24:44 momjian Exp $
66
*/
77
#ifdef FRONTEND
88
#include "postgres_fe.h"
@@ -13,9 +13,7 @@
1313
#include "utils/builtins.h"
1414
#endif
1515

16-
#ifndef WIN32_CLIENT_ONLY
1716
#include <unistd.h>
18-
#endif
1917

2018
#include "mb/pg_wchar.h"
2119
#include <ctype.h>

src/bin/initdb/initdb.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.116 2006/05/27 18:07:06 tgl Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.117 2006/06/07 22:24:44 momjian Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -2269,8 +2269,7 @@ setlocales(void)
22692269
}
22702270

22712271
#ifdef WIN32
2272-
/* MingW headers are incomplete */
2273-
typedef WINAPI BOOL (*__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
2272+
typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
22742273
#define DISABLE_MAX_PRIVILEGE 0x1
22752274

22762275
/*

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.28 2006/04/03 23:35:04 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.29 2006/06/07 22:24:44 momjian Exp $
1010
*/
1111
#include "postgres.h"
1212

@@ -104,7 +104,7 @@ main(int argc, char *argv[])
104104

105105
snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
106106

107-
if ((fd = open(ControlFilePath, O_RDONLY)) == -1)
107+
if ((fd = open(ControlFilePath, O_RDONLY, 0)) == -1)
108108
{
109109
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
110110
progname, ControlFilePath, strerror(errno));

src/bin/pg_ctl/pg_ctl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.67 2006/03/05 15:58:50 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.68 2006/06/07 22:24:44 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -1159,12 +1159,12 @@ pgwin32_doRunAsService(void)
11591159
* also load the couple of functions that *do* exist in minwg headers but not
11601160
* on NT4. That way, we don't break on NT4.
11611161
*/
1162-
typedef WINAPI BOOL (*__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
1163-
typedef WINAPI BOOL (*__IsProcessInJob)(HANDLE, HANDLE, PBOOL);
1164-
typedef WINAPI HANDLE (*__CreateJobObject)(LPSECURITY_ATTRIBUTES, LPCTSTR);
1165-
typedef WINAPI BOOL (*__SetInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
1166-
typedef WINAPI BOOL (*__AssignProcessToJobObject)(HANDLE, HANDLE);
1167-
typedef WINAPI BOOL (*__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
1162+
typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
1163+
typedef BOOL (WINAPI *__IsProcessInJob)(HANDLE, HANDLE, PBOOL);
1164+
typedef HANDLE (WINAPI *__CreateJobObject)(LPSECURITY_ATTRIBUTES, LPCTSTR);
1165+
typedef BOOL (WINAPI *__SetInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
1166+
typedef BOOL (WINAPI *__AssignProcessToJobObject)(HANDLE, HANDLE);
1167+
typedef BOOL (WINAPI *__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
11681168

11691169
/* Windows API define missing from MingW headers */
11701170
#define DISABLE_MAX_PRIVILEGE 0x1

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.131 2006/05/28 21:13:54 tgl Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.132 2006/06/07 22:24:44 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -28,9 +28,7 @@
2828

2929
#include <ctype.h>
3030

31-
#ifndef WIN32_CLIENT_ONLY
3231
#include <unistd.h>
33-
#endif
3432

3533
#ifdef WIN32
3634
#include <io.h>

src/bin/pg_dump/pg_backup_db.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.70 2006/03/03 23:38:29 tgl Exp $
8+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.71 2006/06/07 22:24:44 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -15,9 +15,7 @@
1515
#include "pg_backup_db.h"
1616
#include "dumputils.h"
1717

18-
#ifndef WIN32_CLIENT_ONLY
1918
#include <unistd.h>
20-
#endif
2119

2220
#include <ctype.h>
2321

src/bin/pg_dump/pg_backup_null.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.17 2006/02/12 06:11:50 momjian Exp $
20+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.18 2006/06/07 22:24:44 momjian Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
2424

2525
#include "pg_backup.h"
2626
#include "pg_backup_archiver.h"
2727

28-
#ifndef WIN32_CLIENT_ONLY
2928
#include <unistd.h> /* for dup */
30-
#endif
3129

3230
#include "libpq/libpq-fs.h"
3331

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.51 2006/05/22 11:21:54 petere Exp $
19+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.52 2006/06/07 22:24:44 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -27,10 +27,7 @@
2727

2828
#include <ctype.h>
2929
#include <limits.h>
30-
31-
#ifndef WIN32_CLIENT_ONLY
3230
#include <unistd.h>
33-
#endif
3431

3532
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
3633
static void _StartData(ArchiveHandle *AH, TocEntry *te);

src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.436 2006/05/28 21:13:54 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.437 2006/06/07 22:24:45 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -24,9 +24,7 @@
2424
*/
2525
#include "postgres.h"
2626

27-
#ifndef WIN32_CLIENT_ONLY
2827
#include <unistd.h>
29-
#endif
3028

3129
#include <ctype.h>
3230
#ifdef ENABLE_NLS

src/bin/pg_dump/pg_dumpall.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.78 2006/05/31 11:02:42 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.79 2006/06/07 22:24:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313

1414
#include "postgres_fe.h"
1515

1616
#include <time.h>
17-
18-
#ifndef WIN32_CLIENT_ONLY
1917
#include <unistd.h>
20-
#endif
2118

2219
#ifdef ENABLE_NLS
2320
#include <locale.h>

src/bin/pg_dump/pg_restore.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.77 2006/04/12 22:18:48 tgl Exp $
37+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.78 2006/06/07 22:24:45 momjian Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -53,9 +53,7 @@
5353
#include <termios.h>
5454
#endif
5555

56-
#ifndef WIN32_CLIENT_ONLY
5756
#include <unistd.h>
58-
#endif
5957

6058
#include "getopt_long.h"
6159

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy