Skip to content

Commit fadcb01

Browse files
committed
TAS code originally written for s390 (32-bit) does not work for s390x
(64-bit). Fix it. Per report from Permaine Cheung.
1 parent ed24f28 commit fadcb01

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/include/storage/s_lock.h

Lines changed: 29 additions & 2 deletions
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.102 2002/11/10 00:33:43 momjian Exp $
66+
* $Id: s_lock.h,v 1.103 2002/11/22 01:13:16 tgl Exp $
6767
*
6868
*-------------------------------------------------------------------------
6969
*/
@@ -150,7 +150,8 @@ tas(volatile slock_t *lock)
150150

151151
#endif /* __arm__ */
152152

153-
#if defined(__s390__) || defined(__s390x__)
153+
154+
#if defined(__s390__) && !defined(__s390x__)
154155
/*
155156
* S/390 Linux
156157
*/
@@ -176,6 +177,32 @@ tas(volatile slock_t *lock)
176177

177178
#endif /* __s390__ */
178179

180+
#if defined(__s390x__)
181+
/*
182+
* S/390x Linux (64-bit zSeries)
183+
*/
184+
#define TAS(lock) tas(lock)
185+
186+
static __inline__ int
187+
tas(volatile slock_t *lock)
188+
{
189+
int _res;
190+
191+
__asm__ __volatile__(
192+
" la 1,1 \n"
193+
" lg 2,%2 \n"
194+
" slr 0,0 \n"
195+
" cs 0,1,0(2) \n"
196+
" lr %1,0 \n"
197+
: "=m"(lock), "=d"(_res)
198+
: "m"(lock)
199+
: "0", "1", "2");
200+
201+
return (_res);
202+
}
203+
204+
#endif /* __s390x__ */
205+
179206

180207
#if defined(__sparc__)
181208
#define TAS(lock) tas(lock)

0 commit comments

Comments
 (0)