diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c
index d4290476c831ee6ce5fa8f6be3c16184accae6e0..cd69a078ad345aaca6fc3cc245bda1850b2fadd7 100644
--- a/src/backend/libpq/ip.c
+++ b/src/backend/libpq/ip.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.13 2003/06/12 08:02:53 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.14 2003/06/12 08:11:07 momjian Exp $
  *
  * This file and the IPV6 implementation were initially provided by
  * Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -20,8 +20,6 @@
 /* This is intended to be used in both frontend and backend, so use c.h */
 #include "c.h"
 
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
-
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -35,8 +33,6 @@
 #include <arpa/inet.h>
 #include <sys/file.h>
 
-#endif
-
 #include "libpq/ip.h"
 
 
diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c
index 33082dc6984f035ac94c43c8f071a4dea4c77dc4..3410d8012a478063ff9fb8fce1857ae3a4c1ec46 100644
--- a/src/backend/utils/mb/encnames.c
+++ b/src/backend/utils/mb/encnames.c
@@ -2,7 +2,7 @@
  * Encoding names and routines for work with it. All
  * in this file is shared bedween FE and BE.
  *
- * $Id: encnames.c,v 1.14 2003/06/12 08:02:53 momjian Exp $
+ * $Id: encnames.c,v 1.15 2003/06/12 08:11:07 momjian Exp $
  */
 #ifdef FRONTEND
 #include "postgres_fe.h"
@@ -13,9 +13,7 @@
 #include "utils/builtins.h"
 #endif
 
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <unistd.h>
-#endif
 
 #include "mb/pg_wchar.h"
 #include <ctype.h>
diff --git a/src/include/c.h b/src/include/c.h
index 979ca5885b19961c4ddf406f8041dd315d0d2b13..d17827775fa82d6d9afb428b722e884e5c41e569 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.148 2003/06/12 08:02:56 momjian Exp $
+ * $Id: c.h,v 1.149 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -73,7 +73,7 @@
 #include <SupportDefs.h>
 #endif
 
-#if defined(WIN32) && !defined(_MSC_VER) && !defined(__BORLANDC__)
+#ifdef WIN32
 /* We have to redefine some system functions after they are included above */
 #include "pg_config_os.h"
 #endif
diff --git a/src/include/getaddrinfo.h b/src/include/getaddrinfo.h
index ce329a9024494a99293e227256c5d34e88d5a09b..2afec4d5cafaf97734966bcad9430f698e257fe9 100644
--- a/src/include/getaddrinfo.h
+++ b/src/include/getaddrinfo.h
@@ -16,17 +16,15 @@
  *
  * Copyright (c) 2003, PostgreSQL Global Development Group
  *
- * $Id: getaddrinfo.h,v 1.4 2003/06/12 08:02:56 momjian Exp $
+ * $Id: getaddrinfo.h,v 1.5 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef GETADDRINFO_H
 #define GETADDRINFO_H
 
-#if !defined(WIN32) || (!defined(_MSC_VER) && !defined(__BORLANDC__))
 #include <sys/socket.h>
 #include <netdb.h>
-#endif
 
 
 #ifndef HAVE_STRUCT_ADDRINFO
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 7835ef8d9fff6455b7b3ce605c84c9fc22226acb..aaeecf5957bc316915c7b1fb1e9a2542929f79b7 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -21,10 +21,6 @@
 #define HAVE_ATEXIT
 #define HAVE_MEMMOVE
 
-#ifdef __BORLANDC__
-#define HAVE_RANDOM
-#endif
-
 /* use _snprintf instead of snprintf */
 #define	HAVE_DECL_SNPRINTF 1
 #define snprintf	_snprintf
diff --git a/src/include/port.h b/src/include/port.h
index 93d012218348c825f4055ddbccc104aa6464add4..2fd6de606c113e6e73c282e571069b911041688d 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: port.h,v 1.4 2003/06/12 08:02:56 momjian Exp $
+ * $Id: port.h,v 1.5 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,10 +76,8 @@ extern double rint(double x);
 #endif
 
 #ifndef HAVE_INET_ATON
-#if !defined(WIN32) || (!defined(_MSC_VER) && !defined(__BORLANDC__))
 # include <netinet/in.h>
 # include <arpa/inet.h>
-#endif
 extern int inet_aton(const char *cp, struct in_addr * addr);
 #endif
 
diff --git a/src/interfaces/libpq/bcc32.mak b/src/interfaces/libpq/bcc32.mak
index 74567d008a2329eca51536e7ab10206645a2f315..985143ac875c2c8e96d4a693fb79a325ed421a5e 100644
--- a/src/interfaces/libpq/bcc32.mak
+++ b/src/interfaces/libpq/bcc32.mak
@@ -4,7 +4,7 @@
 #        and a Win32 dynamic library libpq.dll with import library libpqdll.lib
 
 # Borland C++ base install directory goes here
-# BCB=d:\Borland\Bcc55
+BCB=d:\Borland\Bcc55
 
 !MESSAGE Building the Win32 DLL and Static Library...
 !MESSAGE
@@ -63,13 +63,8 @@ LIB32=tlib.exe
 LIB32_FLAGS= 
 LIB32_OBJS= \
 	"$(OUTDIR)\win32.obj" \
-	"$(INTDIR)\getaddrinfo.obj" \
-	"$(INTDIR)\inet_aton.obj" \
-	"$(INTDIR)\crypt.obj" \
-	"$(INTDIR)\path.obj" \
 	"$(INTDIR)\dllist.obj" \
 	"$(INTDIR)\md5.obj" \
-	"$(INTDIR)\ip.obj" \
 	"$(INTDIR)\fe-auth.obj" \
 	"$(INTDIR)\fe-connect.obj" \
 	"$(INTDIR)\fe-exec.obj" \
@@ -82,7 +77,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\encnames.obj"
 
 RSC=brcc32.exe
-RSC_PROJ=-l 0x409 -i$(BCB)\include -fo"$(INTDIR)\libpq.res"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 LINK32=ilink32.exe
 LINK32_FLAGS = -Gn -L$(BCB)\lib;$(INTDIR); -x -Tpd -v
@@ -91,20 +86,15 @@ LINK32_OBJS= "$(INTDIR)\libpqdll.obj"
 # ---------------------------------------------------------------------------
 
 .path.obj = $(INTDIR)
-.path.c = .;..\..\port;..\..\backend\libpq;..\..\backend\lib;..\..\backend\utils\mb
+.path.c = .;..\..\backend\libpq;..\..\backend\lib;..\..\backend\utils\mb
 
 # ---------------------------------------------------------------------------
 
 ALL: "$(OUTDIR)" "$(OUTDIR)\blibpq.dll" "$(OUTDIR)\blibpq.lib"
 
 CLEAN :
-	-@erase "$(INTDIR)\getaddrinfo.obj"
-	-@erase "$(INTDIR)\inet_aton.obj"
-	-@erase "$(INTDIR)\crypt.obj"
-	-@erase "$(INTDIR)\path.obj"
 	-@erase "$(INTDIR)\dllist.obj"
 	-@erase "$(INTDIR)\md5.obj"
-	-@erase "$(INTDIR)\ip.obj"
 	-@erase "$(INTDIR)\fe-auth.obj"
 	-@erase "$(INTDIR)\fe-connect.obj"
 	-@erase "$(INTDIR)\fe-exec.obj"
@@ -135,7 +125,7 @@ CLEAN :
 	"$(OUTDIR)\blibpq.lib" import32.lib cw32mti.lib, +
 	blibpqdll.def,"$(INTDIR)\libpq.res"
 !
-	implib -w "$(OUTDIR)\blibpqdll.lib" blibpqdll.def $@
+	implib -a "$(OUTDIR)\blibpqdll.lib" blibpqdll.def $@
 
 "$(INTDIR)\libpq.res" : "$(INTDIR)" libpq.rc
     $(RSC) $(RSC_PROJ) libpq.rc
diff --git a/src/interfaces/libpq/blibpqdll.def b/src/interfaces/libpq/blibpqdll.def
index 8445a29b1b40b317cfed691a8fd44ad26a9aa1e0..77a996bfe595e9c4b15bb75fe5220be697736f06 100644
--- a/src/interfaces/libpq/blibpqdll.def
+++ b/src/interfaces/libpq/blibpqdll.def
@@ -96,7 +96,7 @@ EXPORTS
     _pg_encoding_to_char     @ 92
     _pg_utf_mblen            @ 93
     _PQunescapeBytea         @ 94
-    _PQfreemem               @ 95
+    _PQfreeMem               @ 95
 
 ; Aliases for MS compatible names
     PQconnectdb             = _PQconnectdb            
@@ -193,5 +193,5 @@ EXPORTS
     pg_encoding_to_char     = _pg_encoding_to_char    
     pg_utf_mblen            = _pg_utf_mblen           
     PQunescapeBytea         = _PQunescapeBytea        
-    PQfreemem               = _PQfreemem              
+    PQfreeMem               = _PQfreeMem              
 
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 49fbbb8c29b06ea4532d2daaf4b7e0e35d029e36..04ca6cb925902c30cf04e2124f60f1190a9a6686 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.245 2003/06/12 08:02:57 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.246 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -49,10 +49,6 @@
 #include "libpq/ip.h"
 #include "mb/pg_wchar.h"
 
-/* For FNCTL_NONBLOCK */
-#if defined(WIN32) || defined(__BEOS__)
-long ioctlsocket_ret;
-#endif
 
 #define PGPASSFILE ".pgpass"
 
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 03f16ac437b1c87494c5a537cbc6266b8de7ac18..0b59e6f5d5c85cca04bd22e900402358127d66cb 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -23,7 +23,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.93 2003/06/12 08:02:57 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.94 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,11 +33,8 @@
 #include <errno.h>
 #include <signal.h>
 #include <time.h>
-
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#endif
 
 #ifdef WIN32
 #include "win32.h"
diff --git a/src/interfaces/libpq/libpqdll.def b/src/interfaces/libpq/libpqdll.def
index f8432fc713acee9080dbb0760bf75367ea1ccc72..e48959f0866bb1cf09f2888d955c902e081f237f 100644
--- a/src/interfaces/libpq/libpqdll.def
+++ b/src/interfaces/libpq/libpqdll.def
@@ -96,5 +96,5 @@ EXPORTS
     pg_encoding_to_char     @ 92
     pg_utf_mblen            @ 93
     PQunescapeBytea         @ 94
-    PQfreemem               @ 95
+    PQfreeMem               @ 95
 
diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak
index 9c198f1c9f4c851713e9af4fc6092d74160b663e..5563c9e9a3b0a9784ad151575744f433ab11e453 100644
--- a/src/interfaces/libpq/win32.mak
+++ b/src/interfaces/libpq/win32.mak
@@ -36,13 +36,8 @@ OutDir=.\Release
 ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll" 
 
 CLEAN :
-	-@erase "$(INTDIR)\getaddrinfo.obj"
-	-@erase "$(INTDIR)\inet_aton.obj"
-      -@erase "$(INTDIR)\crypt.obj"
-	-@erase "$(INTDIR)\path.obj"
 	-@erase "$(INTDIR)\dllist.obj"
 	-@erase "$(INTDIR)\md5.obj"
-	-@erase "$(INTDIR)\ip.obj"
 	-@erase "$(INTDIR)\fe-auth.obj"
 	-@erase "$(INTDIR)\fe-connect.obj"
 	-@erase "$(INTDIR)\fe-exec.obj"
@@ -77,13 +72,8 @@ LIB32=link.exe -lib
 LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib" 
 LIB32_OBJS= \
 	"$(OUTDIR)\win32.obj" \
-	"$(INTDIR)\getaddrinfo.obj" \
-	"$(INTDIR)\inet_aton.obj" \
-      "$(INTDIR)\crypt.obj" \
-	"$(INTDIR)\path.obj" \
 	"$(INTDIR)\dllist.obj" \
 	"$(INTDIR)\md5.obj" \
-	"$(INTDIR)\ip.obj" \
 	"$(INTDIR)\fe-auth.obj" \
 	"$(INTDIR)\fe-connect.obj" \
 	"$(INTDIR)\fe-exec.obj" \
@@ -122,25 +112,6 @@ LINK32_OBJS= \
   $(LINK32_FLAGS) $(LINK32_OBJS)
 <<
 
-"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
-    $(CPP) @<<
-    $(CPP_PROJ) ..\..\port\getaddrinfo.c
-<<
-
-"$(OUTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
-    $(CPP) @<<
-    $(CPP_PROJ) ..\..\port\inet_aton.c
-<<
-
-"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c
-    $(CPP) @<<
-    $(CPP_PROJ) ..\..\port\crypt.c
-<<
-
-"$(OUTDIR)\path.obj" : ..\..\port\path.c
-    $(CPP) @<<
-    $(CPP_PROJ) ..\..\port\path.c
-<<
 
 "$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
     $(CPP) @<<
@@ -153,10 +124,6 @@ LINK32_OBJS= \
     $(CPP_PROJ) ..\..\backend\libpq\md5.c
 <<
 
-"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
-    $(CPP) @<<
-    $(CPP_PROJ) ..\..\backend\libpq\ip.c
-<<
 
 "$(INTDIR)\wchar.obj" : ..\..\backend\utils\mb\wchar.c
     $(CPP) @<<
diff --git a/src/port/crypt.c b/src/port/crypt.c
index 893e227fcf55dff85fc555171fe27fe1d2f35909..dd3e7ecb2a224ffa19b2dc19cdc33c5f8e3ce640 100644
--- a/src/port/crypt.c
+++ b/src/port/crypt.c
@@ -50,12 +50,8 @@ __RCSID("$NetBSD: crypt.c,v 1.18 2001/03/01 14:37:35 wiz Exp $");
 #include <sys/types.h>
 #include <limits.h>
 #include <stdlib.h>
-
-#ifdef WIN32
-#include <windows.h>
-#else
 #include <unistd.h>
-#endif
+#include <windows.h>
 
 static int des_setkey(const char *key);
 static int des_cipher(const char *in, char *out, long salt, int num_iter);
diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c
index 3ceaa3e52b70b9ec11c687236266b494a8f0154c..f585457e7af1813f5fc2e964eb84418d119434c1 100644
--- a/src/port/getaddrinfo.c
+++ b/src/port/getaddrinfo.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/port/getaddrinfo.c,v 1.5 2003/06/12 08:02:57 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/port/getaddrinfo.c,v 1.6 2003/06/12 08:11:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,7 +16,6 @@
 /* This is intended to be used in both frontend and backend, so use c.h */
 #include "c.h"
 
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
@@ -25,7 +24,6 @@
 #ifdef	HAVE_UNIX_SOCKETS
 #include <sys/un.h>
 #endif
-#endif
 
 #include "getaddrinfo.h"
 
diff --git a/src/port/inet_aton.c b/src/port/inet_aton.c
index 1f45e92f95d43cbb411a6f585f1cec8ebaef0da1..ded857c1fb7ab4e3b945401ef218fc27f5f878ed 100644
--- a/src/port/inet_aton.c
+++ b/src/port/inet_aton.c
@@ -1,4 +1,4 @@
-/* $Id: inet_aton.c,v 1.3 2003/06/12 08:02:57 momjian Exp $
+/* $Id: inet_aton.c,v 1.4 2003/06/12 08:11:07 momjian Exp $
  *
  *	This inet_aton() function was taken from the GNU C library and
  *	incorporated into Postgres for those systems which do not have this
@@ -44,10 +44,8 @@
 
 #include "c.h"
 
-#if !defined(WIN32) || (!defined(_MSC_VER) && !defined(__BORLANDC__))
 #include <netinet/in.h>
 #include <ctype.h>
-#endif
 
 /*
  * Check whether "cp" is a valid ascii representation