Skip to content

Commit ceb4f5e

Browse files
committed
> > I'll re-check that with the ppc architecture guy here.
> > ... 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
1 parent 50e726a commit ceb4f5e

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

src/backend/storage/lmgr/s_lock.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.9 2002/09/21 00:14:05 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.10 2002/11/10 00:33:43 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -144,31 +144,6 @@ success: \n\
144144
}
145145
#endif /* __APPLE__ && __ppc__ */
146146

147-
#if defined(__powerpc__)
148-
/* Note: need a nice gcc constrained asm version so it can be inlined */
149-
static void
150-
tas_dummy()
151-
{
152-
__asm__ __volatile__(
153-
"\
154-
.global tas \n\
155-
tas: \n\
156-
lwarx 5,0,3 \n\
157-
cmpwi 5,0 \n\
158-
bne fail \n\
159-
addi 5,5,1 \n\
160-
stwcx. 5,0,3 \n\
161-
beq success \n\
162-
fail: li 3,1 \n\
163-
blr \n\
164-
success: \n\
165-
isync \n\
166-
li 3,0 \n\
167-
blr \n\
168-
");
169-
}
170-
#endif /* __powerpc__ */
171-
172147
#if defined(__mips__) && !defined(__sgi)
173148
static void
174149
tas_dummy()

src/include/port/linux.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ typedef unsigned char slock_t;
1414

1515
#define HAS_TEST_AND_SET
1616

17+
#elif defined(__powerpc64__)
18+
typedef unsigned long slock_t;
19+
20+
#define HAS_TEST_AND_SET
21+
1722
#elif defined(__powerpc__)
1823
typedef unsigned int slock_t;
1924

src/include/storage/s_lock.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
6464
* Portions Copyright (c) 1994, Regents of the University of California
6565
*
66-
* $Id: s_lock.h,v 1.101 2002/09/21 00:14:05 tgl Exp $
66+
* $Id: s_lock.h,v 1.102 2002/11/10 00:33:43 momjian Exp $
6767
*
6868
*-------------------------------------------------------------------------
6969
*/
@@ -194,6 +194,35 @@ tas(volatile slock_t *lock)
194194

195195
#endif /* __sparc__ */
196196

197+
#if defined(__powerpc__) || defined(__powerpc64__)
198+
static __inline__ int
199+
tas(volatile slock_t *lock)
200+
{
201+
slock_t _t;
202+
int _res;
203+
204+
__asm__ __volatile__(
205+
" lwarx %0,0,%3 \n"
206+
" cmpwi %0,0 \n"
207+
" bne 1f \n"
208+
" addi %0,%0,1 \n"
209+
" stwcx. %0,0,%3 \n"
210+
" isync \n"
211+
" beq 2f \n"
212+
"1: li %2,1 \n"
213+
" b 3f \n"
214+
"2: \n"
215+
" li %2,0 \n"
216+
"3: \n"
217+
218+
: "=&r" (_t), "=m" (lock), "=r" (_res)
219+
: "r" (lock)
220+
: "cc", "memory"
221+
);
222+
return _res;
223+
}
224+
#endif
225+
197226

198227
#if defined(__mc68000__) && defined(__linux__)
199228
#define TAS(lock) tas(lock)

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