Skip to content

Commit 1a33436

Browse files
committed
Replace out-of-line tas() assembly code for MIPS with a properly
constrained GCC inline version. Thiemo Seufer, by way of Martin Pitt.
1 parent 2613b74 commit 1a33436

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

src/backend/storage/lmgr/s_lock.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.36 2005/07/30 03:07:40 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.37 2005/08/25 17:17:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -172,34 +172,6 @@ _success: \n\
172172
#endif /* __m68k__ */
173173

174174

175-
#if defined(__mips__) && !defined(__sgi)
176-
static void
177-
tas_dummy()
178-
{
179-
__asm__ __volatile__(
180-
"\
181-
.global tas \n\
182-
tas: \n\
183-
.frame $sp, 0, $31 \n\
184-
.set push \n\
185-
.set mips2 \n\
186-
ll $14, 0($4) \n\
187-
or $15, $14, 1 \n\
188-
sc $15, 0($4) \n\
189-
.set pop \n\
190-
beq $15, 0, fail\n\
191-
bne $14, 0, fail\n\
192-
li $2, 0 \n\
193-
.livereg 0x2000FF0E,0x00000FFF \n\
194-
j $31 \n\
195-
fail: \n\
196-
li $2, 1 \n\
197-
j $31 \n\
198-
");
199-
}
200-
#endif /* __mips__ && !__sgi */
201-
202-
203175
#else /* not __GNUC__ */
204176

205177
/*

src/include/storage/s_lock.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
6767
* Portions Copyright (c) 1994, Regents of the University of California
6868
*
69-
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.134 2005/03/10 21:41:01 momjian Exp $
69+
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.135 2005/08/25 17:17:10 tgl Exp $
7070
*
7171
*-------------------------------------------------------------------------
7272
*/
@@ -453,20 +453,48 @@ do \
453453
#endif /* __alpha || __alpha__ */
454454

455455

456-
/* These live in s_lock.c, but only for gcc */
456+
#if defined(__mips__) && !defined(__sgi)
457+
/* Note: on SGI we use the OS' mutex ABI, see below */
458+
#define HAS_TEST_AND_SET
457459

460+
typedef unsigned int slock_t;
458461

459-
#if defined(__m68k__)
460-
#define HAS_TEST_AND_SET
462+
#define TAS(lock) tas(lock)
461463

462-
typedef unsigned char slock_t;
463-
#endif
464+
static __inline__ int
465+
tas(volatile slock_t *lock)
466+
{
467+
register volatile slock_t *__l = lock;
468+
register int __r;
464469

470+
__asm__ __volatile__(
471+
" .set push \n"
472+
" .set mips2 \n"
473+
" .set noreorder \n"
474+
" .set nomacro \n"
475+
"1: ll %0, %1 \n"
476+
" bne %0, $0, 1f \n"
477+
" xori %0, 1 \n"
478+
" sc %0, %1 \n"
479+
" beq %0, $0, 1b \n"
480+
" sync \n"
481+
"1: .set pop "
482+
: "=&r" (__r), "+R" (*__l)
483+
:
484+
: "memory", "cc");
485+
return __r;
486+
}
465487

466-
#if defined(__mips__) && !defined(__sgi)
488+
#endif /* __mips__ && !__sgi */
489+
490+
491+
/* These live in s_lock.c, but only for gcc */
492+
493+
494+
#if defined(__m68k__)
467495
#define HAS_TEST_AND_SET
468496

469-
typedef unsigned int slock_t;
497+
typedef unsigned char slock_t;
470498
#endif
471499

472500

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy