diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index aaa9647551aaa6c84a2991aab9a382e746b68339..4bd7581a38f458f15802cb03774479e5de08ec5b 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.48 2004/08/29 05:06:43 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.49 2004/09/09 00:59:31 momjian Exp $
  *
  *	  Since the server static private key ($DataDir/server.key)
  *	  will normally be stored unencrypted so that the database
@@ -659,7 +659,7 @@ initialize_SSL(void)
 		 * think of a reasonable check to apply on Windows.  (See also the
 		 * data directory permission check in postmaster.c)
 		 */
-#if !defined(__CYGWIN__) && !defined(WIN32)
+#if !defined(WIN32) && !defined(__CYGWIN__)
 		if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IRWXG | S_IRWXO)) ||
 			buf.st_uid != getuid())
 			ereport(FATAL,
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 52dc12f0ee81c9a3dbdff37d5bc08a30eb96f29f..c329c12d25d8f4545f9a734b43998c212103cddb 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.424 2004/08/29 05:06:46 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.425 2004/09/09 00:59:33 momjian Exp $
  *
  * NOTES
  *
@@ -976,7 +976,7 @@ checkDataDir(const char *checkdir)
 	 * be proper support for Unix-y file permissions.  Need to think of a
 	 * reasonable check to apply on Windows.
 	 */
-#if !defined(__CYGWIN__) && !defined(WIN32)
+#if !defined(WIN32) && !defined(__CYGWIN__)
 	if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
 		ereport(FATAL,
 				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
diff --git a/src/include/c.h b/src/include/c.h
index 7c3e856834ac3ac5dfdbfcb1cc45e4bb9969dae6..3f517a0fbe974be016ec4ac94c10948f7f741794 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/c.h,v 1.168 2004/08/29 05:06:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.169 2004/09/09 00:59:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -68,7 +68,7 @@
 #include <sys/types.h>
 
 #include <errno.h>
-#if defined(__CYGWIN__) || defined(WIN32)
+#if defined(WIN32) || defined(__CYGWIN__)
 #include <fcntl.h>				/* ensure O_BINARY is available */
 #endif
 #ifdef HAVE_SUPPORTDEFS_H
@@ -680,7 +680,7 @@ typedef NameData *Name;
  *	literal control-Z.	The other affect is that we see CRLF, but
  *	that is OK because we can already handle those cleanly.
  */
-#if defined(__CYGWIN__) || defined(WIN32)
+#if defined(WIN32) || defined(__CYGWIN__)
 #define PG_BINARY	O_BINARY
 #define PG_BINARY_R "rb"
 #define PG_BINARY_W "wb"
diff --git a/src/include/port.h b/src/include/port.h
index 5c554ccf3a4e789dbc50eb4e1c392b5b942ae480..b5de0d2d149804db9ce75ff35c347ed14e4b2d38 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.59 2004/09/09 00:24:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.60 2004/09/09 00:59:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -181,7 +181,7 @@ extern int	win32_open(const char *, int,...);
 #endif
 
 /* Global variable holding time zone information. */
-#if !defined(__CYGWIN__)
+#ifndef __CYGWIN__
 #define TIMEZONE_GLOBAL timezone
 #define TZNAME_GLOBAL tzname
 #else
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index b33d264555a761d449eca3651db06fe1092b90dd..d957463223874099010b16c803af7d9868514915 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.31 2004/08/31 11:29:56 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.32 2004/09/09 00:59:44 momjian Exp $ */
 
 /* undefine and redefine after #include */
 #undef mkdir
@@ -19,7 +19,7 @@
 #define USES_WINSOCK
 
 /* defines for dynamic linking on Win32 platform */
-#if defined(__CYGWIN__) || defined(__MINGW32__)
+#if defined(__MINGW32__) || defined(__CYGWIN__)
 
 #if __GNUC__ && ! defined (__declspec)
 #error You need egcs 1.1 or newer for compiling!
diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h
index 8d58d3dfd36591c0b4a580aee18f344db0e0462f..aaf97d0ecf34dc72e27226afcfd75e6aa2c06980 100644
--- a/src/interfaces/ecpg/include/sqlca.h
+++ b/src/interfaces/ecpg/include/sqlca.h
@@ -2,7 +2,7 @@
 #define POSTGRES_SQLCA_H
 
 #ifndef DLLIMPORT
-#if defined(__CYGWIN__) || defined(WIN32)
+#if  defined(WIN32) || defined(__CYGWIN__)
 #define DLLIMPORT __declspec (dllimport)
 #else
 #define DLLIMPORT
diff --git a/src/port/dirmod.c b/src/port/dirmod.c
index e7d0ef23c3fb67763d895d85bf28c1653da676b2..cda2bb1a08d061ff2d50c539a64b743b0a0e6c81 100644
--- a/src/port/dirmod.c
+++ b/src/port/dirmod.c
@@ -10,7 +10,7 @@
  *	Win32 (NT, Win2k, XP).	replace() doesn't work on Win95/98/Me.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.22 2004/08/29 05:07:02 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.23 2004/09/09 00:59:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,14 +66,14 @@ pgrename(const char *from, const char *to)
 {
 	int			loops = 0;
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__)
 	while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
 #endif
 #ifdef __CYGWIN__
 		while (rename(from, to) < 0)
 #endif
 		{
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__)
 			if (GetLastError() != ERROR_ACCESS_DENIED)
 #endif
 #ifdef __CYGWIN__