Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4d4953f

Browse files
committed
Make Win32 tests to match existing Cygwin tests, where appropriate.
1 parent cb7fb3c commit 4d4953f

File tree

10 files changed

+109
-42
lines changed

10 files changed

+109
-42
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.112 2003/02/21 00:06:22 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.113 2003/04/18 01:03:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1507,7 +1507,7 @@ InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
15071507
* overwrite an existing logfile. However, there shouldn't be one, so
15081508
* rename() is an acceptable substitute except for the truly paranoid.
15091509
*/
1510-
#if !defined(__BEOS__) && !defined(N_PLAT_NLM) && !defined(__CYGWIN__)
1510+
#if HAVE_WORKING_LINK
15111511
if (link(tmppath, path) < 0)
15121512
elog(PANIC, "link from %s to %s (initialization of log file %u, segment %u) failed: %m",
15131513
tmppath, path, log, seg);

src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.311 2003/04/17 22:26:01 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.312 2003/04/18 01:03:42 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -299,9 +299,7 @@ checkDataDir(const char *checkdir)
299299
char path[MAXPGPATH];
300300
FILE *fp;
301301

302-
#ifndef __CYGWIN__
303302
struct stat stat_buf;
304-
#endif
305303

306304
if (checkdir == NULL)
307305
{
@@ -314,15 +312,6 @@ checkDataDir(const char *checkdir)
314312
ExitPostmaster(2);
315313
}
316314

317-
/*
318-
* Check if the directory has group or world access. If so, reject.
319-
*
320-
* XXX temporarily suppress check when on Windows, because there may not
321-
* be proper support for Unix-y file permissions. Need to think of a
322-
* reasonable check to apply on Windows.
323-
*/
324-
#ifndef __CYGWIN__
325-
326315
if (stat(checkdir, &stat_buf) == -1)
327316
{
328317
if (errno == ENOENT)
@@ -332,10 +321,18 @@ checkDataDir(const char *checkdir)
332321
checkdir);
333322
}
334323

324+
/*
325+
* Check if the directory has group or world access. If so, reject.
326+
*
327+
* XXX temporarily suppress check when on Windows, because there may not
328+
* be proper support for Unix-y file permissions. Need to think of a
329+
* reasonable check to apply on Windows.
330+
*/
331+
#if !defined(__CYGWIN__) && !defined(WIN32)
335332
if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
336333
elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
337334
checkdir);
338-
#endif /* !__CYGWIN__ */
335+
#endif
339336

340337
/* Look for PG_VERSION before looking for pg_control */
341338
ValidatePgVersion(checkdir);

src/include/c.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.137 2003/04/06 22:45:23 petere Exp $
15+
* $Id: c.h,v 1.138 2003/04/18 01:03:42 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -51,7 +51,7 @@
5151
*/
5252

5353
#include "pg_config.h"
54-
#include "pg_config_manual.h"
54+
#include "pg_config_manual.h" /* must be after pg_config.h */
5555
#include "pg_config_os.h"
5656
#include "postgres_ext.h"
5757

@@ -65,10 +65,8 @@
6565
#endif
6666
#include <sys/types.h>
6767

68-
#ifdef __CYGWIN__
6968
#include <errno.h>
7069
#include <sys/fcntl.h> /* ensure O_BINARY is available */
71-
#endif
7270
#ifdef HAVE_SUPPORTDEFS_H
7371
#include <SupportDefs.h>
7472
#endif
@@ -321,6 +319,14 @@ typedef unsigned long int uint64;
321319
#define HAVE_INT64_TIMESTAMP
322320
#endif
323321

322+
/* Global variable holding time zone information. */
323+
#ifndef HAVE_UNDERSCORE_TIMEZONE
324+
#define TIMEZONE_GLOBAL timezone
325+
#else
326+
#define TIMEZONE_GLOBAL _timezone
327+
#define tzname _tzname /* should be in time.h? */
328+
#endif
329+
324330
/* sig_atomic_t is required by ANSI C, but may be missing on old platforms */
325331
#ifndef HAVE_SIG_ATOMIC_T
326332
typedef int sig_atomic_t;
@@ -680,7 +686,7 @@ typedef NameData *Name;
680686
* ----------------------------------------------------------------
681687
*/
682688

683-
#ifdef __CYGWIN__
689+
#if defined(__CYGWIN__) || defined(WIN32)
684690
#define PG_BINARY O_BINARY
685691
#define PG_BINARY_R "rb"
686692
#define PG_BINARY_W "wb"

src/include/pg_config_manual.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* for developers. If you edit any of these, be sure to do a *full*
77
* rebuild (and an initdb if noted).
88
*
9-
* $Id: pg_config_manual.h,v 1.1 2003/04/06 22:45:23 petere Exp $
9+
* $Id: pg_config_manual.h,v 1.2 2003/04/18 01:03:42 momjian Exp $
1010
*------------------------------------------------------------------------
1111
*/
1212

@@ -134,6 +134,22 @@
134134
# define HAVE_UNIX_SOCKETS 1
135135
#endif
136136

137+
/*
138+
* Define this if your operating system supports link()
139+
*/
140+
#if !defined(__QNX__) && !defined(__BEOS__) && \
141+
!defined(__CYGWIN__) && !defined(WIN32)
142+
# define HAVE_WORKING_LINK 1
143+
#endif
144+
145+
/*
146+
* Define this if your operating system has _timezone rather than timezone
147+
*/
148+
#if defined(__CYGWIN__) || defined(WIN32)
149+
# define HAVE_INT_TIMEZONE /* has int _timezone */
150+
# define HAVE_UNDERSCORE_TIMEZONE 1
151+
#endif
152+
137153
/*
138154
* This is the default directory in which AF_UNIX socket files are
139155
* placed. Caution: changing this risks breaking your existing client

src/include/port/cygwin.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
/* $Header: /cvsroot/pgsql/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/include/port/cygwin.h,v 1.2 2003/04/18 01:03:42 momjian Exp $ */
2+
3+
#include <port/win32defs.h>
24

35
#define HAS_TEST_AND_SET
46
typedef unsigned char slock_t;
57

6-
#define tzname _tzname /* should be in time.h? */
7-
#define HAVE_INT_TIMEZONE /* has int _timezone */
8-
98
#include <cygwin/version.h>
109

1110
/*

src/include/port/win32.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.7 2003/04/18 01:03:42 momjian Exp $ */
2+
3+
#include <port/win32defs.h>
4+
15
#define USES_WINSOCK
26
#define NOFILE 100
37

@@ -27,3 +31,56 @@
2731
#define DLLIMPORT
2832

2933
#endif
34+
35+
/*
36+
* Supplement to <sys/types.h>.
37+
*/
38+
#define uid_t int
39+
#define gid_t int
40+
#define pid_t unsigned long
41+
#define ssize_t int
42+
#define mode_t int
43+
#define key_t long
44+
#define ushort unsigned short
45+
46+
/*
47+
* Supplement to <sys/stat.h>.
48+
*/
49+
#define lstat slat
50+
51+
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
52+
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
53+
54+
#define S_IRUSR _S_IREAD
55+
#define S_IWUSR _S_IWRITE
56+
#define S_IXUSR _S_IEXEC
57+
#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
58+
59+
/*
60+
* Supplement to <errno.h>.
61+
*/
62+
#include <errno.h>
63+
#undef EAGAIN
64+
#undef EINTR
65+
#define EINTR WSAEINTR
66+
#define EAGAIN WSAEWOULDBLOCK
67+
#define EMSGSIZE WSAEMSGSIZE
68+
#define EAFNOSUPPORT WSAEAFNOSUPPORT
69+
#define EWOULDBLOCK WSAEWOULDBLOCK
70+
#define ECONNRESET WSAECONNRESET
71+
#define EINPROGRESS WSAEINPROGRESS
72+
73+
/*
74+
* Supplement to <math.h>.
75+
*/
76+
#define isnan _isnan
77+
#define finite _finite
78+
extern double rint(double x);
79+
80+
/*
81+
* Supplement to <stdio.h>.
82+
*/
83+
#define snprintf _snprintf
84+
#define vsnprintf _vsnprintf
85+
86+

src/include/utils/datetime.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: datetime.h,v 1.37 2003/04/04 04:50:44 tgl Exp $
12+
* $Id: datetime.h,v 1.38 2003/04/18 01:03:42 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -216,13 +216,6 @@ do { \
216216
} while(0)
217217
#endif
218218

219-
/* Global variable holding time zone information. */
220-
#if defined(__CYGWIN__) || defined(N_PLAT_NLM)
221-
#define TIMEZONE_GLOBAL _timezone
222-
#else
223-
#define TIMEZONE_GLOBAL timezone
224-
#endif
225-
226219
/*
227220
* Date/time validation
228221
* Include check for leap year.

src/interfaces/ecpg/include/sqlca.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define POSTGRES_SQLCA_H
33

44
#ifndef DLLIMPORT
5-
#ifdef __CYGWIN__
5+
#if defined(__CYGWIN__) || defined(WIN32)
66
#define DLLIMPORT __declspec (dllimport)
77
#else
88
#define DLLIMPORT

src/interfaces/ecpg/pgtypeslib/dt.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ do { \
216216
#endif
217217

218218
/* Global variable holding time zone information. */
219-
#if defined(__CYGWIN__) || defined(N_PLAT_NLM)
220-
#define TIMEZONE_GLOBAL _timezone
221-
#else
219+
#if !defined(__CYGWIN__) && !defined(WIN32)
222220
#define TIMEZONE_GLOBAL timezone
221+
#else
222+
#define TIMEZONE_GLOBAL _timezone
223+
#define tzname _tzname /* should be in time.h? */
223224
#endif
224225

225226
/*

src/tools/entab/entab.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <stdlib.h>
1313
#include <string.h>
1414

15+
#include "../include/c.h"
16+
1517
#define NUL '\0'
1618

1719
#ifndef TRUE
@@ -94,11 +96,7 @@ char **argv;
9496
in_file = stdin;
9597
else
9698
{
97-
#ifndef __CYGWIN__
98-
if ((in_file = fopen(*argv, "r")) == NULL)
99-
#else
100-
if ((in_file = fopen(*argv, "rb")) == NULL)
101-
#endif
99+
if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
102100
halt("PERROR: Can not open file %s\n", argv[0]);
103101
argv++;
104102
}

0 commit comments

Comments
 (0)