> > I'll re-check that with the ppc architecture guy here.
authorBruce Momjian
Sun, 10 Nov 2002 00:33:43 +0000 (00:33 +0000)
committerBruce Momjian
Sun, 10 Nov 2002 00:33:43 +0000 (00:33 +0000)
>
> ... he is now about to write an inlined version that can go into
> s_lock.h . I'll send the new patch later on...

OK, here it comes:

An inlined version of tas(), that works for both, powerpc and
powerpc64. The patch is against 7.3b5 and passes the test suite on
both architectures.

Reinhard Max

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

index 0d30203a5f3d1deed222e4fbcb1d887c09042c0b..f767863b2a2970d6ddd8ebdcb3f125d197a5c0b7 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.9 2002/09/21 00:14:05 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.10 2002/11/10 00:33:43 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -144,31 +144,6 @@ success:                       \n\
 }
 #endif   /* __APPLE__ && __ppc__ */
 
-#if defined(__powerpc__)
-/* Note: need a nice gcc constrained asm version so it can be inlined */
-static void
-tas_dummy()
-{
-   __asm__     __volatile__(
-                                        "\
-.global tas                    \n\
-tas:                           \n\
-           lwarx   5,0,3       \n\
-           cmpwi   5,0         \n\
-           bne     fail        \n\
-           addi    5,5,1       \n\
-           stwcx.  5,0,3       \n\
-           beq     success     \n\
-fail:      li      3,1         \n\
-           blr                 \n\
-success:                       \n\
-           isync               \n\
-           li      3,0         \n\
-           blr                 \n\
-");
-}
-#endif   /* __powerpc__ */
-
 #if defined(__mips__) && !defined(__sgi)
 static void
 tas_dummy()
index d4da17da45cb08d939992086b786037e9b1926ca..283799c14d6eb147fd57997fe0a894ec9c9f3ac4 100644 (file)
@@ -14,6 +14,11 @@ typedef unsigned char slock_t;
 
 #define HAS_TEST_AND_SET
 
+#elif defined(__powerpc64__)
+typedef unsigned long slock_t;
+
+#define HAS_TEST_AND_SET
+
 #elif defined(__powerpc__)
 typedef unsigned int slock_t;
 
index 1174b13694ec001ba60aab15e4799f79517edb50..16457507a512a8cdc28e31e759d62c31ad468c27 100644 (file)
@@ -63,7 +63,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *   $Id: s_lock.h,v 1.101 2002/09/21 00:14:05 tgl Exp $
+ *   $Id: s_lock.h,v 1.102 2002/11/10 00:33:43 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -194,6 +194,35 @@ tas(volatile slock_t *lock)
 
 #endif  /* __sparc__ */
 
+#if defined(__powerpc__) || defined(__powerpc64__)
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+   slock_t _t;
+   int _res;
+
+   __asm__ __volatile__(
+"  lwarx   %0,0,%3     \n"
+"  cmpwi   %0,0        \n"
+"  bne     1f      \n"
+"  addi    %0,%0,1     \n"
+"  stwcx.  %0,0,%3     \n"
+"  isync           \n"
+"  beq     2f          \n"
+"1:    li      %2,1        \n"
+"  b   3f      \n"
+"2:                \n"
+"  li      %2,0        \n"
+"3:                \n"
+
+:  "=&r" (_t), "=m" (lock), "=r" (_res)
+:  "r" (lock)
+:  "cc", "memory"
+   );
+   return _res;
+}
+#endif
+
 
 #if defined(__mc68000__) && defined(__linux__)
 #define TAS(lock) tas(lock)