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

Commit 0083280

Browse files
committed
A quick try at un-breaking the Cygwin build. Whether it needs the
pgwin32_safestat remains to be determined, but in any case the current code is not tolerable.
1 parent 65c3d05 commit 0083280

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/include/port.h

+16-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.119 2008/04/10 16:58:51 mha Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.120 2008/04/11 23:53:00 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -281,9 +281,23 @@ extern void copydir(char *fromdir, char *todir, bool recurse);
281281

282282
extern bool rmtree(char *path, bool rmtopdir);
283283

284+
/*
285+
* stat() is not guaranteed to set the st_size field on win32, so we
286+
* redefine it to our own implementation that is.
287+
*
288+
* We must pull in sys/stat.h here so the system header definition
289+
* goes in first, and we redefine that, and not the other way around.
290+
*/
291+
#if defined(WIN32) && !defined(__CYGWIN__)
292+
#include <sys/stat.h>
293+
extern int pgwin32_safestat(const char *path, struct stat *buf);
294+
#define stat(a,b) pgwin32_safestat(a,b)
295+
#endif
296+
284297
#if defined(WIN32) && !defined(__CYGWIN__)
285298

286-
/* open() and fopen() replacements to allow deletion of open files and
299+
/*
300+
* open() and fopen() replacements to allow deletion of open files and
287301
* passing of other special options.
288302
*/
289303
#define O_DIRECT 0x80000000
@@ -298,19 +312,6 @@ extern FILE *pgwin32_fopen(const char *, const char *);
298312
#define popen(a,b) _popen(a,b)
299313
#define pclose(a) _pclose(a)
300314

301-
/*
302-
* stat() is not guaranteed to set the st_size field on win32, so we
303-
* redefine it to our own implementation that is.
304-
*
305-
* We must pull in sys/stat.h here so the system header definition
306-
* goes in first, and we redefine that, and not the other way around.
307-
*/
308-
extern int pgwin32_safestat(const char *path, struct stat *buf);
309-
#if !defined(FRONTEND) && !defined(_DIRMOD_C)
310-
#include <sys/stat.h>
311-
#define stat(a,b) pgwin32_safestat(a,b)
312-
#endif
313-
314315
/* Missing rand functions */
315316
extern long lrand48(void);
316317
extern void srand48(long seed);

src/port/dirmod.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.52 2008/04/10 16:58:51 mha Exp $
13+
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.53 2008/04/11 23:53:00 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -449,13 +449,15 @@ rmtree(char *path, bool rmtopdir)
449449
}
450450

451451

452-
#ifdef WIN32
452+
#if defined(WIN32) && !defined(__CYGWIN__)
453+
454+
#undef stat
455+
453456
/*
454457
* The stat() function in win32 is not guaranteed to update the st_size
455458
* field when run. So we define our own version that uses the Win32 API
456459
* to update this field.
457460
*/
458-
#undef stat
459461
int
460462
pgwin32_safestat(const char *path, struct stat *buf)
461463
{
@@ -480,4 +482,5 @@ pgwin32_safestat(const char *path, struct stat *buf)
480482

481483
return 0;
482484
}
485+
483486
#endif

0 commit comments

Comments
 (0)