This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

db2 fixes


In our bug tracking database is a report about resoures not freed when
using platforms which don't have a native spinlock implementation.
This includes, among other platforms, Alpha.  For this reason the
Alpha maintainer wrote an appropriate set of definitions and now Alpha
has spinlocks in the db code as well.  But it needs some testing.  So,
those with Alpha, boxes please give the code below a try.  Also SPARC
users should test it since there was a little problem for v8 and v9
SPARC processors.

Please send feedback to this list.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: db_int.h
===================================================================
RCS file: /glibc/cvsfiles/libc/db2/db_int.h,v
retrieving revision 1.10
diff -u -r1.10 db_int.h
--- db_int.h	1999/06/16 14:27:59	1.10
+++ db_int.h	1999/08/30 21:26:15
@@ -138,7 +138,7 @@
 /*******************************************************
  * Mutex support.
  *******************************************************/
-typedef unsigned char tsl_t;
+typedef u_int32_t tsl_t;
 
 /*
  * !!!
Index: mutex/mutex.c
===================================================================
RCS file: /glibc/cvsfiles/libc/db2/mutex/mutex.c,v
retrieving revision 1.7
diff -u -r1.7 mutex.c
--- mutex.c	1999/06/13 11:24:41	1.7
+++ mutex.c	1999/08/30 21:26:16
@@ -110,6 +110,10 @@
 #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)
Index: mutex/sparc.gcc
===================================================================
RCS file: /glibc/cvsfiles/libc/db2/mutex/sparc.gcc,v
retrieving revision 1.1
diff -u -r1.1 sparc.gcc
--- sparc.gcc	1997/08/27 19:32:54	1.1
+++ sparc.gcc	1999/08/30 21:26:16
@@ -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)
Index: mutex/alpha.h
===================================================================
--- /dev/null	Tue May  5 13:32:27 1998
+++ mutex/alpha.h	Mon Aug 30 14:21:09 1999
@@ -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)
Index: sysdeps/alpha/Makefile
===================================================================
RCS file: /glibc/cvsfiles/libc/sysdeps/alpha/Makefile,v
retrieving revision 1.15
diff -u -r1.15 Makefile
--- Makefile	1998/06/27 09:50:41	1.15
+++ Makefile	1999/08/30 21:34:00
@@ -1,4 +1,4 @@
-# Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1993, 94, 95, 96, 97, 99 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -16,6 +16,10 @@
 # License along with the GNU C Library; see the file COPYING.LIB.  If not,
 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
+
+ifeq ($(subdir),db2)
+CPPFLAGS += -DHAVE_SPINLOCKS=1 -DHAVE_ASSEM_ALPHA=1
+endif
 
 ifeq ($(subdir),gmon)
 sysdep_routines += _mcount

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]