Comment 35 for bug 6942

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Fri, 20 Aug 2004 01:08:42 +0200
From: Thiemo Seufer <email address hidden>
To: Martin Helas <email address hidden>, <email address hidden>,
 Steve Langasek <email address hidden>
Subject: Patch for this bug

Hello All,

the appended patch adds mutex support for mips/mipsel (Regenerating the
config files of this build system is a PITA).

Steve, you tagged this bug as sarge-ignore, is this really still
relevant?

Thiemo

--- dbinc/mutex.h.old 2003-09-20 23:40:49.000000000 +0200
+++ dbinc/mutex.h 2004-08-19 21:26:16.000000000 +0200
@@ -487,6 +487,48 @@ typedef unsigned char tsl_t;
 #endif

 /*********************************************************************
+ * MIPS/gcc assembly.
+ *********************************************************************/
+#ifdef HAVE_MUTEX_MIPS_GCC_ASSEMBLY
+typedef u_int32_t tsl_t;
+
+#ifndef MUTEX_ALIGN
+#define MUTEX_ALIGN 4
+#endif
+
+#ifdef LOAD_ACTUAL_MUTEX_CODE
+/*
+ * For gcc/mips. Should return 0 if could not acquire the lock, 1 if
+ * lock was acquired properly.
+ */
+static inline int
+MUTEX_SET(tsl_t *tsl) {
+ register tsl_t *__l = tsl;
+ register tsl_t __r;
+ asm volatile(
+ " .set push \n"
+ " .set mips2 \n"
+ " .set noreorder \n"
+ "1: ll %0, %1 \n"
+ " bnez %0, 1f \n"
+ " nop \n"
+ " addu %0, 1 \n"
+ " sc %0, %1 \n"
+ " beqz %0, 1b \n"
+ " move %0, $0 \n"
+ " sync \n"
+ "1: .set pop \n"
+ : "=&r" (__r), "+m" (*__l)
+ : : "memory");
+ return __r ^ 1;
+}
+
+#define MUTEX_UNSET(tsl) (*(volatile tsl_t *)(tsl) = 0)
+#define MUTEX_INIT(tsl) MUTEX_UNSET(tsl)
+#endif
+#endif
+
+/*********************************************************************
  * HPPA/gcc assembly.
  *********************************************************************/
 #ifdef HAVE_MUTEX_HPPA_GCC_ASSEMBLY
--- dist/aclocal/mutex.ac.old 2003-06-16 16:54:39.000000000 +0200
+++ dist/aclocal/mutex.ac 2004-08-19 21:32:23.000000000 +0200
@@ -373,6 +373,17 @@ AC_TRY_COMPILE(,[
 ], [db_cv_mutex="ARM/gcc-assembly"])
 fi

+# MIPS/gcc: Linux
+if test "$db_cv_mutex" = no; then
+AC_TRY_COMPILE(,[
+#if defined(__mips__) && defined(__GNUC__)
+ exit(0);
+#else
+ FAIL TO COMPILE/LINK
+#endif
+], [db_cv_mutex="MIPS/gcc-assembly"])
+fi
+
 # PaRisc/gcc: HP/UX
 if test "$db_cv_mutex" = no; then
 AC_TRY_COMPILE(,[
@@ -499,6 +510,10 @@ ARM/gcc-assembly) ADDITIONAL_OBJS="mut_t
    AC_DEFINE(HAVE_MUTEX_ARM_GCC_ASSEMBLY)
    AH_TEMPLATE(HAVE_MUTEX_ARM_GCC_ASSEMBLY,
        [Define to 1 to use the GCC compiler and ARM assembly language mutexes.]);;
+MIPS/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS"
+ AC_DEFINE(HAVE_MUTEX_MIPS_GCC_ASSEMBLY)
+ AH_TEMPLATE(HAVE_MUTEX_MIPS_GCC_ASSEMBLY,
+ [Define to 1 to use the GCC compiler and MIPS assembly language mutexes.]);;
 HP/msem_init) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS"
    AC_DEFINE(HAVE_MUTEX_HPPA_MSEM_INIT)
    AH_TEMPLATE(HAVE_MUTEX_HPPA_MSEM_INIT,