From 1a33436224146fc1091a7eca2e87fde3c5463767 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 25 Aug 2005 17:17:10 +0000 Subject: Replace out-of-line tas() assembly code for MIPS with a properly constrained GCC inline version. Thiemo Seufer, by way of Martin Pitt. --- src/include/storage/s_lock.h | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'src/include') diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 49bb9f64c21..579db815a4e 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -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 -- cgit v1.2.3