提交 0b7afedb 编写于 作者: T Tom Lane

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.
上级 56295419
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.116.2.2 2008/04/10 16:59:10 mha Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.116.2.3 2008/04/11 23:59:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -280,9 +280,23 @@ extern void copydir(char *fromdir, char *todir, bool recurse); ...@@ -280,9 +280,23 @@ extern void copydir(char *fromdir, char *todir, bool recurse);
extern bool rmtree(char *path, bool rmtopdir); extern bool rmtree(char *path, bool rmtopdir);
/*
* stat() is not guaranteed to set the st_size field on win32, so we
* redefine it to our own implementation that is.
*
* We must pull in sys/stat.h here so the system header definition
* goes in first, and we redefine that, and not the other way around.
*/
#if defined(WIN32) && !defined(__CYGWIN__)
#include <sys/stat.h>
extern int pgwin32_safestat(const char *path, struct stat *buf);
#define stat(a,b) pgwin32_safestat(a,b)
#endif
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)
/* open() and fopen() replacements to allow deletion of open files and /*
* open() and fopen() replacements to allow deletion of open files and
* passing of other special options. * passing of other special options.
*/ */
#define O_DIRECT 0x80000000 #define O_DIRECT 0x80000000
...@@ -297,19 +311,6 @@ extern FILE *pgwin32_fopen(const char *, const char *); ...@@ -297,19 +311,6 @@ extern FILE *pgwin32_fopen(const char *, const char *);
#define popen(a,b) _popen(a,b) #define popen(a,b) _popen(a,b)
#define pclose(a) _pclose(a) #define pclose(a) _pclose(a)
/*
* stat() is not guaranteed to set the st_size field on win32, so we
* redefine it to our own implementation that is.
*
* We must pull in sys/stat.h here so the system header definition
* goes in first, and we redefine that, and not the other way around.
*/
extern int pgwin32_safestat(const char *path, struct stat *buf);
#if !defined(FRONTEND) && !defined(_DIRMOD_C)
#include <sys/stat.h>
#define stat(a,b) pgwin32_safestat(a,b)
#endif
/* Missing rand functions */ /* Missing rand functions */
extern long lrand48(void); extern long lrand48(void);
extern void srand48(long seed); extern void srand48(long seed);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me. * Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.51.2.1 2008/04/10 16:59:10 mha Exp $ * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.51.2.2 2008/04/11 23:59:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -449,13 +449,15 @@ report_and_fail: ...@@ -449,13 +449,15 @@ report_and_fail:
} }
#ifdef WIN32 #if defined(WIN32) && !defined(__CYGWIN__)
#undef stat
/* /*
* The stat() function in win32 is not guaranteed to update the st_size * The stat() function in win32 is not guaranteed to update the st_size
* field when run. So we define our own version that uses the Win32 API * field when run. So we define our own version that uses the Win32 API
* to update this field. * to update this field.
*/ */
#undef stat
int int
pgwin32_safestat(const char *path, struct stat *buf) pgwin32_safestat(const char *path, struct stat *buf)
{ {
...@@ -480,4 +482,5 @@ pgwin32_safestat(const char *path, struct stat *buf) ...@@ -480,4 +482,5 @@ pgwin32_safestat(const char *path, struct stat *buf)
return 0; return 0;
} }
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册