diff options
author | Tom Lane | 2008-04-11 23:53:00 +0000 |
---|---|---|
committer | Tom Lane | 2008-04-11 23:53:00 +0000 |
commit | 94aa04d2e8b670581dbcba2547c7e9dea427600f (patch) | |
tree | 9dd2e7691e97b4fb168f700cd88d9e241803966e | |
parent | 3ecbfe3d478ef5ca08c2b31a47f8597a24060dcf (diff) |
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.
-rw-r--r-- | src/include/port.h | 29 | ||||
-rw-r--r-- | src/port/dirmod.c | 7 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/include/port.h b/src/include/port.h index f9a200f76f..6b57620a87 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -281,9 +281,23 @@ extern void copydir(char *fromdir, char *todir, bool recurse); 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__) -/* 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. */ #define O_DIRECT 0x80000000 @@ -298,19 +312,6 @@ extern FILE *pgwin32_fopen(const char *, const char *); #define popen(a,b) _popen(a,b) #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 */ extern long lrand48(void); extern void srand48(long seed); diff --git a/src/port/dirmod.c b/src/port/dirmod.c index 0a64cab0a2..b1e4c19bfd 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -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 * field when run. So we define our own version that uses the Win32 API * to update this field. */ -#undef stat int pgwin32_safestat(const char *path, struct stat *buf) { @@ -480,4 +482,5 @@ pgwin32_safestat(const char *path, struct stat *buf) return 0; } + #endif |