From 64e7adb07b252ba4b6d6990bf6dad2105e072105 Mon Sep 17 00:00:00 2001
From: "Marc G. Fournier" <scrappy@hub.org>
Date: Fri, 13 Feb 1998 05:10:06 +0000
Subject: [PATCH] From: Tom I Helbekkmo <tih@Hamartun.Priv.NO>

Apart from this Makefile hack, all I've done is to make dynamically
loaded code modules fail properly (as was already done for __mips__,
although I think this is too loose: I believe NetBSD for the pmax can
do dynamic linking), and to add test-and-set lock handling.  As Bruce
suggested, this is done in a maximally efficient inlined way: I was
not aware that this code was so important, speed-wise.
---
 src/Makefile.global.in              |  7 ++++++-
 src/backend/parser/scan.c           |  4 ++--
 src/backend/port/dynloader/bsd.c    |  7 ++++---
 src/include/port/bsd.h              |  5 +++++
 src/include/storage/s_lock.h        | 14 +++++++++++++-
 src/interfaces/libpgtcl/Makefile.in | 12 +++++++-----
 src/interfaces/libpq/Makefile.in    | 12 +++++++-----
 7 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 452a5a0af89..39640b9193b 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.33 1998/01/27 03:24:51 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.34 1998/02/13 05:09:12 scrappy Exp $
 #
 # NOTES
 #    Essentially all Postgres make files include this file and use the 
@@ -48,6 +48,11 @@
 # compiling to a.out (which means you're using the dld dynamic loading 
 # library), set LINUX_ELF to null in Makefile.custom.
 LINUX_ELF= true
+#
+# Ignore BSD_SHLIB if you're not using one of the BSD ports.  But if you
+# are, and it's one that doesn't have shared libraries (NetBSD/vax is an
+# example of this), set BSD_SHLIB to null in Makefile.custom.
+BSD_SHLIB= true
 
 LIBPQDIR:= $(SRCDIR)/interfaces/libpq
 
diff --git a/src/backend/parser/scan.c b/src/backend/parser/scan.c
index 74f72609fcb..5480abd5551 100644
--- a/src/backend/parser/scan.c
+++ b/src/backend/parser/scan.c
@@ -1,7 +1,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.12 1998/02/11 03:56:08 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.13 1998/02/13 05:09:15 scrappy Exp $
  */
 
 #define FLEX_SCANNER
@@ -539,7 +539,7 @@ char *yytext;
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.12 1998/02/11 03:56:08 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.13 1998/02/13 05:09:15 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
diff --git a/src/backend/port/dynloader/bsd.c b/src/backend/port/dynloader/bsd.c
index b1c0c3d1d3c..8c9f680a812 100644
--- a/src/backend/port/dynloader/bsd.c
+++ b/src/backend/port/dynloader/bsd.c
@@ -61,7 +61,7 @@ BSD44_derived_dlerror(void)
 void	   *
 BSD44_derived_dlopen(const char *file, int num)
 {
-#ifdef __mips__
+#if defined(__mips__) || (defined(__NetBSD__) && defined(vax))
 	sprintf(error_message, "dlopen (%s) not supported", file);
 	return NULL;
 #else
@@ -78,7 +78,7 @@ BSD44_derived_dlopen(const char *file, int num)
 void	   *
 BSD44_derived_dlsym(void *handle, const char *name)
 {
-#ifdef __mips__
+#if defined(__mips__) || (defined(__NetBSD__) && defined(vax))
 	sprintf(error_message, "dlsym (%s) failed", name);
 	return NULL;
 #else
@@ -101,7 +101,8 @@ BSD44_derived_dlsym(void *handle, const char *name)
 void
 BSD44_derived_dlclose(void *handle)
 {
-#ifndef __mips__
+#if defined(__mips__) || (defined(__NetBSD__) && defined(vax))
+#else
 	dlclose(handle);
 #endif
 }
diff --git a/src/include/port/bsd.h b/src/include/port/bsd.h
index 12787118aea..f64ea094563 100644
--- a/src/include/port/bsd.h
+++ b/src/include/port/bsd.h
@@ -10,6 +10,11 @@
 #define HAS_TEST_AND_SET
 #endif
 
+#if defined(vax)
+#define NEED_VAX_TAS_ASM
+#define HAS_TEST_AND_SET
+#endif
+
 #if defined(ns32k)
 #define NEED_NS32k_TAS_ASM
 #define HAS_TEST_AND_SET
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 68f93a1a045..455329dce0d 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.24 1998/02/05 03:31:01 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.25 1998/02/13 05:09:50 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -287,6 +287,18 @@ tas_dummy()
 
 #endif							/* NEED_SPARC_TAS_ASM */
 
+/*
+ * VAXen -- even multiprocessor ones
+ */
+
+#if defined(NEED_VAX_TAS_ASM)
+
+#define S_LOCK(addr)		__asm__("1: bbssi $0,(%0),1b": :"r"(addr))
+#define S_UNLOCK(addr)		(*(addr) = 0)
+#define S_INIT_LOCK(addr)	(*(addr) = 0)
+
+#endif							/* NEED_VAX_TAS_ASM */
+
 /*
  * i386 based things
  */
diff --git a/src/interfaces/libpgtcl/Makefile.in b/src/interfaces/libpgtcl/Makefile.in
index 0552736518b..0905a8a7227 100644
--- a/src/interfaces/libpgtcl/Makefile.in
+++ b/src/interfaces/libpgtcl/Makefile.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.2 1998/01/17 23:33:32 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.3 1998/02/13 05:09:57 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -42,10 +42,12 @@ ifeq ($(PORTNAME), linux)
 endif
 
 ifeq ($(PORTNAME), bsd)
-  install-shlib-dep	:= install-shlib
-  shlib			:= libpgtcl.so.1.0
-  LDFLAGS_SL		= -x -Bshareable -Bforcearchive
-  CFLAGS		+= $(CFLAGS_SL)
+  ifdef BSD_SHLIB
+    install-shlib-dep	:= install-shlib
+    shlib		:= libpgtcl.so.1.0
+    LDFLAGS_SL		= -x -Bshareable -Bforcearchive
+    CFLAGS		+= $(CFLAGS_SL)
+  endif
 endif
 
 ifeq ($(PORTNAME), i386_solaris)
diff --git a/src/interfaces/libpq/Makefile.in b/src/interfaces/libpq/Makefile.in
index 5f9c26d2db6..6eeca467fea 100644
--- a/src/interfaces/libpq/Makefile.in
+++ b/src/interfaces/libpq/Makefile.in
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.5 1998/01/26 01:42:24 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.6 1998/02/13 05:10:06 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -43,10 +43,12 @@ ifeq ($(PORTNAME), linux)
   endif
 endif
 ifeq ($(PORTNAME), bsd)
-  install-shlib-dep := install-shlib
-  shlib := libpq.so.$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL = -x -Bshareable -Bforcearchive
-  CFLAGS += $(CFLAGS_SL)
+  ifdef BSD_SHLIB
+    install-shlib-dep := install-shlib
+    shlib := libpq.so.$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+    LDFLAGS_SL = -x -Bshareable -Bforcearchive
+    CFLAGS += $(CFLAGS_SL)
+  endif
 endif
 ifeq ($(PORTNAME), i386_solaris)
   install-shlib-dep := install-shlib
-- 
GitLab