diff --git a/src/backend/port/aix/Makefile.inc b/src/backend/port/aix/Makefile.inc
index 6954174c7d2fb5323b76f4a5027303a4dd644150..f79c4894f64a291a53f9ae7a0bd49901ee6c7a8c 100644
--- a/src/backend/port/aix/Makefile.inc
+++ b/src/backend/port/aix/Makefile.inc
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/port/aix/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/backend/port/aix/Attic/Makefile.inc,v 1.2 1996/07/22 22:59:27 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -26,9 +26,11 @@ HEADERS+= dlfcn.h machine.h port-protos.h
 
 SUBSRCS+= dlfcn.c 
 
+MKLDEXPORT=$(POSTGRESDIR)/src/backend/port/aix/mkldexport.sh
+
 ${PROG}.exp: ${PROG}.noexp
 	mv -f $(objdir)/${PROG}.noexp $(objdir)/${PROG}
-	$(CURDIR)/port/aix/mkldexport.sh $(objdir)/${PROG} ${BINDIR} > $(objdir)/${PROG}.exp
+	$(MKLDEXPORT) $(objdir)/${PROG} ${BINDIR} > $(objdir)/${PROG}.exp
 	mv -f $(objdir)/${PROG} $(objdir)/${PROG}.noexp
 
 ${PROG}.noexp: ${OBJS}
diff --git a/src/backend/port/i386_solaris/Makefile.inc b/src/backend/port/i386_solaris/Makefile.inc
index 927010d611923c85c13caedc7f362133c73558f8..afaf4c903b07513704c5d7c6bb6d80efaefb6757 100644
--- a/src/backend/port/i386_solaris/Makefile.inc
+++ b/src/backend/port/i386_solaris/Makefile.inc
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/Makefile.inc,v 1.1 1996/07/20 08:34:32 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/Makefile.inc,v 1.2 1996/07/22 22:59:34 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,6 +15,6 @@ CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNEED_RUSAGE -DNO_EMPTY_STMTS
 
 LDADD+= -ll -ldl
 
-SUBSRCS+= port.c
+SUBSRCS+= port.c tas.s
 
 HEADERS+= machine.h port-protos.h rusagestub.h
diff --git a/src/backend/storage/buf_internals.h b/src/backend/storage/buf_internals.h
index 84583867fafdd6dfe19b74d985bedc35c3e527d4..90e9c384874d2abdcff2e779d6856456a0b2db4d 100644
--- a/src/backend/storage/buf_internals.h
+++ b/src/backend/storage/buf_internals.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: buf_internals.h,v 1.1.1.1 1996/07/09 06:21:52 scrappy Exp $
+ * $Id: buf_internals.h,v 1.2 1996/07/22 22:59:42 scrappy Exp $
  *
  * NOTE
  *	If BUFFERPAGE0 is defined, then 0 will be used as a
@@ -135,18 +135,41 @@ struct sbufdesc {
      * It eats up more shared memory, of course, but we're (allegedly)
      * going to make some of these types bigger soon anyway... -pma 1/2/93
      */
+
+/* NO spinlock */
+
 #if defined(PORTNAME_ultrix4)
     char		sb_pad[60];	/* no slock_t */
 #endif /* mips */
-#if defined(PORTNAME_sparc) || defined(PORTNAME_sparc_solaris) || defined(PORTNAME_irix5)
-    char		sb_pad[56];	/* has slock_t */
-#endif /* sparc || irix5 */
-#if defined(PORTNAME_hpux)
-    char		sb_pad[44];	/* has slock_t */
-#endif /* alpha */
+
+/* HAS_TEST_AND_SET -- platform dependent size */
+
+#if defined(PORTNAME_aix)
+    char		sb_pad[44];	/* typedef unsigned int slock_t; */
+#endif /* aix */
 #if defined(PORTNAME_alpha)
-    char		sb_pad[40];	/* has slock_t */
+    char		sb_pad[40];	/* typedef msemaphore slock_t; */
 #endif /* alpha */
+#if defined(PORTNAME_hpux)
+    char		sb_pad[44];	/* typedef struct { int sem[4]; } slock_t; */
+#endif /* hpux */
+#if defined(PORTNAME_irix5)
+    char		sb_pad[44];	/* typedef abilock_t slock_t; */
+#endif /* irix5 */
+#if defined(PORTNAME_next)
+    char		sb_pad[56];	/* typedef struct mutex slock_t; */
+#endif /* next */
+
+/* HAS_TEST_AND_SET -- default 1 byte spinlock */
+
+#if defined(PORTNAME_BSD44_derived) || \
+    defined(PORTNAME_bsdi) || \
+    defined(PORTNAME_i86pc_solaris) || \
+    defined(PORTNAME_linux) || \
+    defined(PORTNAME_sparc) || \
+    defined(PORTNAME_sparc_solaris)
+    char		sb_pad[56];	/* has slock_t */
+#endif /* 1 byte slock_t */
 };
 
 /*
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 8f1bafef4d5e5a5cf27285173d61c2073cd63db1..9adb9985c9a5592267343b2a1923676c8374e3ff 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *    $Id: fd.c,v 1.3 1996/07/18 04:59:42 scrappy Exp $
+ *    $Id: fd.c,v 1.4 1996/07/22 22:59:50 scrappy Exp $
  *
  * NOTES:
  *
@@ -62,11 +62,12 @@
 #define NOFILE NOFILE_IN_U
 #endif /* PORTNAME_sparc */
 
-#ifdef PORTNAME_sparc_solaris
+#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i386_solaris)
 #include <sys/user.h>
 #undef NOFILE
 #define NOFILE 64
-#endif /* PORTNAME_sparc_solaris */
+#endif /* PORTNAME_sparc_solaris || PORTNAME_i386_solaris */
+
 /*
  * Problem: Postgres does a system(ld...) to do dynamic loading.  This
  * will open several extra files in addition to those used by
diff --git a/src/backend/storage/ipc.h b/src/backend/storage/ipc.h
index 36cb3c8f626f9baa1f67eaea15f816be2bfc50cc..174e672e3d9d7e92ac9426a2f169076f32010421 100644
--- a/src/backend/storage/ipc.h
+++ b/src/backend/storage/ipc.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: ipc.h,v 1.2 1996/07/20 08:35:24 scrappy Exp $
+ * $Id: ipc.h,v 1.3 1996/07/22 22:59:43 scrappy Exp $
  *
  * NOTES
  *    This file is very architecture-specific.  This stuff should actually
@@ -30,30 +30,22 @@
  * atomic test-and-set instruction).  However, we have only written
  * spinlock code for the architectures listed.
  */
-#if (defined(PORTNAME_aix) || \
+#if defined(PORTNAME_aix) || \
     defined(PORTNAME_alpha) || \
+    defined(PORTNAME_BSD44_derived) || \
+    defined(PORTNAME_bsdi) || \
     defined(PORTNAME_hpux) || \
+    defined(PORTNAME_i386_solaris) || \
     defined(PORTNAME_irix5) || \
+    defined(PORTNAME_linux) || \
     defined(PORTNAME_next) || \
     defined(PORTNAME_sparc) || \
-    defined(PORTNAME_sparc_solaris) || \
-    (defined(__i386__) && defined(__GNUC__))) && \
-    !defined(PORTNAME_i386_solaris)
+    defined(PORTNAME_sparc_solaris)
 #define HAS_TEST_AND_SET
 #endif
 
 #if defined(HAS_TEST_AND_SET)
 
-#if defined(PORTNAME_next)
-/*
- * Use Mach mutex routines since these are, in effect, test-and-set
- * spinlocks.
- */
-#undef NEVER	/* definition in cthreads.h conflicts with parse.h */
-#include <mach/cthreads.h>
-
-typedef struct mutex	slock_t;
-#else /* next */
 #if defined(PORTNAME_aix)
 /*
  * The AIX C library has the cs(3) builtin for compare-and-set that 
@@ -61,10 +53,12 @@ typedef struct mutex	slock_t;
  */
 typedef unsigned int	slock_t;
 #else /* aix */
+
 #if defined(PORTNAME_alpha)
 #include <sys/mman.h>
 typedef msemaphore	slock_t;
 #else /* alpha */
+
 #if defined(PORTNAME_hpux)
 /*
  * The PA-RISC "semaphore" for the LDWCX instruction is 4 bytes aligned
@@ -72,29 +66,45 @@ typedef msemaphore	slock_t;
  */
 typedef struct { int sem[4]; } slock_t;
 #else /* hpux */
+
 #if defined(PORTNAME_irix5)
 #include <abi_mutex.h>
 typedef abilock_t	slock_t;
 #else /* irix5 */
+
+#if defined(PORTNAME_next)
+/*
+ * Use Mach mutex routines since these are, in effect, test-and-set
+ * spinlocks.
+ */
+#undef NEVER	/* definition in cthreads.h conflicts with parse.h */
+#include <mach/cthreads.h>
+typedef struct mutex	slock_t;
+#else /* next */
+
 /*
  * On all other architectures spinlocks are a single byte.
  */
 typedef unsigned char   slock_t;
+
+#endif /* next */
 #endif /* irix5 */
 #endif /* hpux */
 #endif /* alpha */
 #endif /* aix */
-#endif /* next */
 
 extern void S_LOCK(slock_t *lock);
 extern void S_UNLOCK(slock_t *lock);
 extern void S_INIT_LOCK(slock_t *lock);
 
-#if defined(PORTNAME_hpux) || defined(PORTNAME_alpha) || defined(PORTNAME_irix5) || defined(PORTNAME_next)
+#if defined(PORTNAME_alpha) || \
+    defined(PORTNAME_hpux) || \
+    defined(PORTNAME_irix5) || \
+    defined(PORTNAME_next)
 extern int S_LOCK_FREE(slock_t *lock);
-#else /* PORTNAME_hpux */
+#else
 #define S_LOCK_FREE(lock)	((*lock) == 0)
-#endif /* PORTNAME_hpux */
+#endif
 
 #endif /* HAS_TEST_AND_SET */
 
@@ -108,9 +118,10 @@ extern int S_LOCK_FREE(slock_t *lock);
     defined(PORTNAME_aix) || \
     defined(PORTNAME_alpha) || \
     defined(PORTNAME_hpux) || \
+    defined(PORTNAME_i386_solaris) || \
     defined(PORTNAME_sparc_solaris) || \
-    defined(WIN32) || \
-    defined(PORTNAME_ultrix4)
+    defined(PORTNAME_ultrix4) || \
+    defined(WIN32)
 union semun {
     int val;
     struct semid_ds *buf;
diff --git a/src/backend/storage/ipc/s_lock.c b/src/backend/storage/ipc/s_lock.c
index 260120dfcc22f0a3082a5bf4c213c066062b3188..df8aa514e48ba7f76159df216dfd4bab02c8b4ec 100644
--- a/src/backend/storage/ipc/s_lock.c
+++ b/src/backend/storage/ipc/s_lock.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.3 1996/07/16 07:13:16 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.4 1996/07/22 23:00:03 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,8 +70,7 @@ S_INIT_LOCK(slock_t *lock)
 int
  S_LOCK_FREE(slock_t *lock)
 {
- 	/* For Mach, we have to delve inside the entrails of `struct  
-mutex'.  Ick! */
+/* For Mach, we have to delve inside the entrails of `struct mutex'.  Ick! */
  	return (lock->lock == 0);
 }
 
@@ -159,9 +158,10 @@ S_LOCK_FREE(slock_t *lock)
  * Solaris 2
  */
 
-#if defined(PORTNAME_sparc_solaris)
+#if defined(PORTNAME_i386_solaris) || \
+    defined(PORTNAME_sparc_solaris)
 
-/* defined in port/.../tas.s */
+/* for xxxxx_solaris, this is defined in port/.../tas.s */
 extern int tas(slock_t *lock);
 
 void
@@ -183,7 +183,7 @@ S_INIT_LOCK(slock_t *lock)
     S_UNLOCK(lock);
 }
 
-#endif /* PORTNAME_sparc_solaris */
+#endif /* PORTNAME_i86pc_solaris || PORTNAME_sparc_solaris */
 
 /*
  * AIX (POWER)
@@ -266,7 +266,7 @@ S_LOCK_FREE(slock_t *lock)
  * sun3
  */
  
-#if (defined(sun) && ! defined(sparc))
+#if (defined(sun3) && ! defined(sparc))
 
 void    
 S_LOCK(slock_t *lock)
@@ -381,8 +381,10 @@ S_INIT_LOCK(unsigned char *addr)
  * Linux and friends
  */
 
-#if defined(PORTNAME_linux) || defined(PORTNAME_BSD44_derived) ||  defined(PORTNAME_bsdi) || defined(PORTNAME_bsdi_2_1)
-
+#if defined(PORTNAME_BSD44_derived) || \
+    defined(PORTNAME_bsdi) || \
+    defined(PORTNAME_bsdi_2_1) || \
+    defined(PORTNAME_linux)
 
 int
 tas(slock_t *m)
@@ -411,7 +413,7 @@ S_INIT_LOCK(slock_t *lock)
     S_UNLOCK(lock);
 }
 
-#endif /* PORTNAME_linux || PORTNAME_BSD44_derived || PORTNAME_bsdi || PORTNAME_bsdi_2_1 */
+#endif /* linux and friends */
 
 
 #endif /* HAS_TEST_AND_SET */
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 416b661f80b699e083af4549264e67d71ef81e03..5b7ebfede933b4a3ddaad3244deea5e4c6199d31 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.3 1996/07/15 19:22:12 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.4 1996/07/22 23:00:18 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -476,8 +476,8 @@ mdblindwrt(char *dbstr,
     if (write(fd, buffer, BLCKSZ) != BLCKSZ || (pg_fsync(fd) < 0))
 #else
     if (write(fd, buffer, BLCKSZ) != BLCKSZ || fsync(fd) < 0)
-	status = SM_FAIL;
 #endif
+	status = SM_FAIL;
 
     if (close(fd) < 0)
 	status = SM_FAIL;
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 7211bc192832048bdf493ec7a0624a8fb76d97ef..dfb2532bf32a310b8bce8846909102211340d64b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.3 1996/07/19 06:13:42 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.4 1996/07/22 23:00:26 scrappy Exp $
  *
  * NOTES
  *    this is the "main" module of the postgres backend and
@@ -701,12 +701,12 @@ her exceeded legal ranges or was a divide by zero");
 
 static void usage(char* progname)
 {
-    fprintf(stderr, 
-	    "Usage: %s [-B nbufs] [-d lvl] ] [-f plantype] \t[-m portno] [\t -o filename]\n",
-	    progname);
 #ifdef OPENLINK_PATCHES
     fprintf(stderr,"\t[-P portno] [-t tracetype] [-x opttype] [-bCEiLFNopQSs] [dbname]\n");
 #else
+    fprintf(stderr, 
+	    "Usage: %s [-B nbufs] [-d lvl] ] [-f plantype] \t[-m portno] [\t -o filename]\n",
+	    progname);
     fprintf(stderr,"\t[-P portno] [-t tracetype] [-x opttype] [-bCEiLNopQSs] [dbname]\n");
 #endif
     fprintf(stderr, "    b: consider bushy plan trees during optimization\n");
@@ -714,12 +714,12 @@ static void usage(char* progname)
     fprintf(stderr, "    C: supress version info\n");
     fprintf(stderr, "    d: set debug level\n");
     fprintf(stderr, "    E: echo query before execution\n");
-    fprintf(stderr, "    f: forbid plantype generation\n");
-    fprintf(stderr, "    i: don't execute the query, just show the plan tree\n");
-    fprintf(stderr, "    L: turn off locking\n");
 #ifdef OPENLINK_PATCHES
     fprintf(stderr, "    F: turn off fsync\n");
 #endif
+    fprintf(stderr, "    f: forbid plantype generation\n");
+    fprintf(stderr, "    i: don't execute the query, just show the plan tree\n");
+    fprintf(stderr, "    L: turn off locking\n");
     fprintf(stderr, "    m: set up a listening backend at portno to support multiple front-ends\n");
     fprintf(stderr, "    M: start as postmaster\n");
     fprintf(stderr, "    N: don't use newline as query delimiter\n");
@@ -867,6 +867,16 @@ PostgresMain(int argc, char *argv[])
 	    flagE = 1;
 	    break;
 	    
+#ifdef OPENLINK_PATCHES
+        case 'F':
+            /* --------------------
+             *  turn off fsync
+             * --------------------
+             */
+            fsyncOff = 1;
+            break;
+#endif
+
 	case 'f':
 	    /* -----------------
 	     *    f - forbid generation of certain plans
@@ -904,17 +914,7 @@ PostgresMain(int argc, char *argv[])
 	     */
 	    lockingOff = 1;
 	    break;
-
-#ifdef OPENLINK_PATCHES
-	case 'F':
-	    /* --------------------
-	     *  turn off fsync
-	     * --------------------
-	     */
-	    fsyncOff = 1;
-	    break;
-#endif
-
+	    
 	case 'm':
 	    /* start up a listening backend that can respond to 
 	       multiple front-ends.  (Note:  all the front-end connections
@@ -1223,7 +1223,7 @@ PostgresMain(int argc, char *argv[])
      */
     if (IsUnderPostmaster == false) {
 	puts("\nPOSTGRES backend interactive interface");
-	puts("$Revision: 1.3 $ $Date: 1996/07/19 06:13:42 $");
+	puts("$Revision: 1.4 $ $Date: 1996/07/22 23:00:26 $");
     }
     
     /* ----------------