about summary refs log tree commit diff
path: root/db2
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-08-30 21:51:29 +0000
committerUlrich Drepper <drepper@redhat.com>1999-08-30 21:51:29 +0000
commit9a93ac006df5199c4dc03710043d1d77396ff29e (patch)
tree8c244c606079be26347cec0a310693c3f829e530 /db2
parent0742e50134bfc3db08895c020a940a62e5036cfb (diff)
downloadglibc-9a93ac006df5199c4dc03710043d1d77396ff29e.tar.gz
glibc-9a93ac006df5199c4dc03710043d1d77396ff29e.tar.xz
glibc-9a93ac006df5199c4dc03710043d1d77396ff29e.zip
Update.
	* db2/db_int.h: Change tsl_t type to u_int32_t.
	* db2/mutex/mutex.c: Allow Alpha mutex definitions.
	* db2/mutex/alpha.h: New file.
	* db2/mutex/sparc.gcc: Fix store code for v9.  Simplify clear code.
	* sysdeps/alpha/Makefile [db2]: Set CFLAGS of mutex.c to make spinlocks
	known.
	Patches by Richard Henderson.
Diffstat (limited to 'db2')
-rw-r--r--db2/db_int.h2
-rw-r--r--db2/mutex/alpha.h26
-rw-r--r--db2/mutex/mutex.c4
-rw-r--r--db2/mutex/sparc.gcc14
4 files changed, 37 insertions, 9 deletions
diff --git a/db2/db_int.h b/db2/db_int.h
index 4c2e794153..228c7ab4f2 100644
--- a/db2/db_int.h
+++ b/db2/db_int.h
@@ -138,7 +138,7 @@ typedef struct __fn {
 /*******************************************************
  * Mutex support.
  *******************************************************/
-typedef unsigned char tsl_t;
+typedef u_int32_t tsl_t;
 
 /*
  * !!!
diff --git a/db2/mutex/alpha.h b/db2/mutex/alpha.h
new file mode 100644
index 0000000000..ad3afc4544
--- /dev/null
+++ b/db2/mutex/alpha.h
@@ -0,0 +1,26 @@
+/* For alpha, 0 is clear, 1 is set.  */
+
+#ifdef __GNUC__
+#define	TSL_SET(tsl) ({							\
+	register tsl_t *__l = (tsl);					\
+	int __r;							\
+	asm volatile(							\
+		"1:	ldl_l	%0,%1\n"				\
+		"	blbs	%0,2f\n"				\
+		"	mov	1,%0\n"					\
+		"	stl_c	%0,%1\n"				\
+		"	bne	%0,1b\n"				\
+		"	mb\n"						\
+		"2:"							\
+		: "=&r"(__r), "=m"(*__l) : "m"(*__l) : "memory");	\
+	__r;								\
+})
+#endif
+
+#ifdef __DECC
+#include <alpha/builtins.h>
+#define TSL_SET(tsl) (__LOCK_LONG_RETRY((tsl), 1) != 0)
+#endif
+
+#define	TSL_UNSET(tsl)	(*(tsl) = 0)
+#define	TSL_INIT(tsl)	TSL_UNSET(tsl)
diff --git a/db2/mutex/mutex.c b/db2/mutex/mutex.c
index acc6aa07c9..2fac14cf3d 100644
--- a/db2/mutex/mutex.c
+++ b/db2/mutex/mutex.c
@@ -110,6 +110,10 @@ static const char sccsid[] = "@(#)mutex.c	10.52 (Sleepycat) 11/8/98";
 #include "x86.gcc"
 #endif
 
+#ifdef HAVE_ASSEM_ALPHA
+#include "alpha.h"
+#endif
+
 #ifdef WIN16
 /* Win16 spinlocks are simple because we cannot possibly be preempted. */
 #define	TSL_INIT(tsl)
diff --git a/db2/mutex/sparc.gcc b/db2/mutex/sparc.gcc
index 8445a0629b..9e3239b0b0 100644
--- a/db2/mutex/sparc.gcc
+++ b/db2/mutex/sparc.gcc
@@ -13,21 +13,19 @@
  * For gcc/sparc, 0 is clear, 1 is set.
  */
 
-#if defined(__sparcv9__)
-Does the following code need membar instructions for V9 processors?
-#endif
+/* The stbar is needed for v8, and is implemented as membar #sync on v9,
+   so is functional there as well.  For v7, stbar may generate an illegal
+   instruction and we have no way to tell what we're running on.  Some
+   operating systems notice and skip this instruction in the fault handler.  */
 
 #define	TSL_SET(tsl) ({							\
 	register tsl_t *__l = (tsl);					\
 	register tsl_t __r;						\
 	__asm__ volatile						\
-	    ("ldstub [%1],%0"						\
+	    ("ldstub [%1],%0; stbar"					\
 	    : "=r"( __r) : "r" (__l));					\
 	!__r;								\
 })
 
-#define	TSL_UNSET(tsl) ({						\
-         register tsl_t *__l = (tsl);					\
-        __asm__ volatile ("stb %%g0,[%0]" : : "r" (__l));		\
-})
+#define	TSL_UNSET(tsl)	((tsl) = 0)
 #define	TSL_INIT(tsl)	TSL_UNSET(tsl)