Replace out-of-line tas() assembly code for MIPS with a properly
authorTom Lane
Thu, 25 Aug 2005 17:17:10 +0000 (17:17 +0000)
committerTom Lane
Thu, 25 Aug 2005 17:17:10 +0000 (17:17 +0000)
constrained GCC inline version.  Thiemo Seufer, by way of Martin Pitt.

src/backend/storage/lmgr/s_lock.c
src/include/storage/s_lock.h

index e12b683d98a5cf768e9bd36858647d89031241c0..f57dd9a439e7d4a3d526e3702331d003ffc7f9af 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.36 2005/07/30 03:07:40 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.37 2005/08/25 17:17:09 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -172,34 +172,6 @@ _success:                      \n\
 #endif   /* __m68k__ */
 
 
-#if defined(__mips__) && !defined(__sgi)
-static void
-tas_dummy()
-{
-   __asm__     __volatile__(
-                                        "\
-.global    tas                     \n\
-tas:                           \n\
-           .frame  $sp, 0, $31 \n\
-           .set push       \n\
-           .set mips2      \n\
-           ll      $14, 0($4)  \n\
-           or      $15, $14, 1 \n\
-           sc      $15, 0($4)  \n\
-           .set pop            \n\
-           beq     $15, 0, fail\n\
-           bne     $14, 0, fail\n\
-           li      $2, 0       \n\
-           .livereg 0x2000FF0E,0x00000FFF  \n\
-           j       $31         \n\
-fail:                          \n\
-           li      $2, 1       \n\
-           j       $31         \n\
-");
-}
-#endif   /* __mips__ && !__sgi */
-
-
 #else                          /* not __GNUC__ */
 
 /*
index 49bb9f64c210e4a5e06c567f95233442b90b57f6..579db815a4e0fedac887ca6f8315205d7c57ae97 100644 (file)
@@ -66,7 +66,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *   $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.134 2005/03/10 21:41:01 momjian Exp $
+ *   $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.135 2005/08/25 17:17:10 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -453,20 +453,48 @@ do \
 #endif /* __alpha || __alpha__ */
 
 
-/* These live in s_lock.c, but only for gcc */
+#if defined(__mips__) && !defined(__sgi)
+/* Note: on SGI we use the OS' mutex ABI, see below */
+#define HAS_TEST_AND_SET
 
+typedef unsigned int slock_t;
 
-#if defined(__m68k__)
-#define HAS_TEST_AND_SET
+#define TAS(lock) tas(lock)
 
-typedef unsigned char slock_t;
-#endif
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+   register volatile slock_t *__l = lock;
+   register int __r;
 
+   __asm__ __volatile__(
+       "       .set push           \n"
+       "       .set mips2          \n"
+       "       .set noreorder      \n"
+       "       .set nomacro        \n"
+       "1:     ll      %0, %1      \n"
+       "       bne     %0, $0, 1f  \n"
+       "        xori   %0, 1       \n"
+       "       sc      %0, %1      \n"
+       "       beq     %0, $0, 1b  \n"
+       "        sync               \n"
+       "1:     .set pop              "
+:      "=&r" (__r), "+R" (*__l)
+:
+:      "memory", "cc");
+   return __r;
+}
 
-#if defined(__mips__) && !defined(__sgi)
+#endif /* __mips__ && !__sgi */
+
+
+/* These live in s_lock.c, but only for gcc */
+
+
+#if defined(__m68k__)
 #define HAS_TEST_AND_SET
 
-typedef unsigned int slock_t;
+typedef unsigned char slock_t;
 #endif