A quick try at un-breaking the Cygwin build. Whether it needs the
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Apr 2008 00:00:08 +0000 (00:00 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Apr 2008 00:00:08 +0000 (00:00 +0000)
pgwin32_safestat remains to be determined, but in any case the current
code is not tolerable.

src/include/port.h
src/port/dirmod.c

index 652726c213ac0665290fbf4bb5c8df4ff44c8db6..a05c7c66d8f78aedd7373c27591db020d1a35708 100644 (file)
@@ -274,9 +274,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.
  */
 extern int     pgwin32_open(const char *, int,...);
@@ -290,19 +304,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);
index 7198ca50f455a78aff3f6e352647e4d96c154f05..743672d194346e7bfe2365f16d983f8c04a16398 100644 (file)
@@ -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