OSDN Git Service

new alpha linux locking from Travis Melhiser <melhiser@viper.co.union.nc.us>
authorBruce Momjian <bruce@momjian.us>
Fri, 7 Nov 1997 21:35:41 +0000 (21:35 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 7 Nov 1997 21:35:41 +0000 (21:35 +0000)
src/include/storage/s_lock.h

index 1722d33..5892e8a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.11 1997/10/30 05:24:19 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.12 1997/11/07 21:35:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
  *                             ;
  *             }
  *
- *             In addition to modifying this file you will need to modify
- *             the appropriate ...src/include/port/...h file to define
- *             HAS_TEST_AND_SET for the appropriate circumstances.
- *
  *             If this is not done, POSTGRES will default to using System V
  *             semaphores (and take a large performance hit -- around 40% of
  *             its time on a DS5000/240 is spent in semop(3)...).
@@ -233,31 +229,6 @@ tas_dummy()
 #endif                                                 /* sun3 */
 
 /*
- *     M68000 ports under NetBSD.
- *
- *     This version should also work on a sun3, but I can't test it.
- *     Conversely the sun3 version should work under NetBSD/m68k, but
- *     it doesn't.
- */
-#if defined(__NetBSD__) && defined(__m68k__)
-
-static void S_LOCK(char *lock)
-{
-       asm("
-                       movel   a6@(8),a0
-       LOOP:
-                       tas             a0@
-                       bmi             LOOP
-       ");
-}
-
-#define S_UNLOCK(lock)         (*(lock) = 0)
-
-#define S_INIT_LOCK(lock)      S_UNLOCK(lock)
-
-#endif /* M68000 && NetBSD */
-
-/*
  * sparc machines
  */
 
@@ -342,29 +313,28 @@ tas_dummy()
 
 #if defined(__alpha__) && defined(linux)
 
-#define        S_LOCK(lock)    do \
-                                               { \
-                                                       slock_t         _res; \
-                                                       do \
-                                                       { \
-                                                               __asm__("    ldq   $0, %0            \n\
-                                                            bne   $0, already_set   \n\
-                                                            ldq_l $0, %0            \n\
-                                                            bne   $0, already_set   \n\
-                                                            or    $31, 1, $0        \n\
-                                                            stq_c $0, %0            \n\
-                                                            beq   $0, stqc_fail     \n\
-                                       success:     bis   $31, $31, %1      \n\
-                                                            mb                      \n\
-                                                            jmp   $31, end          \n\
-                                       stqc_fail:   or    $31, 1, $0        \n\
-                                       already_set: bis   $0, $0, %1        \n\
-                                       end:         nop      ": "=m"(*lock), "=r"(_res): :"0"); \
-                                                       } while (_res != 0); \
-                                               } while (0)
+#define        S_LOCK(lock)    do { \
+                       slock_t         _res; \
+                       do { \
+               __asm__("    ldq   $0, %0              \n\
+                            bne   $0, already_set%=   \n\
+                            ldq_l $0, %0              \n\
+                            bne   $0, already_set%=   \n\
+                            or    $31, 1, $0          \n\
+                            stq_c $0, %0              \n\
+                            beq   $0, stqc_fail%=     \n\
+               success%=:                             \n\
+                            bis   $31, $31, %1        \n\
+                            mb                        \n\
+                            jmp   $31, end%=          \n\
+               stqc_fail%=:   or    $31, 1, $0        \n\
+               already_set%=: bis   $0, $0, %1        \n\
+               end%=:       nop      ": "=m"(*lock), "=r"(_res): :"0"); \
+                       } while (_res != 0); \
+               } while (0)
 
                                                
-#define        S_UNLOCK(lock)  (__asm__("mb"), *(lock) = 0)
+#define        S_UNLOCK(lock)  ({ __asm__("mb \n"); *(lock) = 0; })
 
 #define        S_INIT_LOCK(lock)       S_UNLOCK(lock)