Skip to content

Commit aac3c30

Browse files
committed
Add s_lock support for SuperH architecture.
After a patch originally submitted by Nobuhiro Iwamatsu, but corrected (I think) to match our guidelines for safe use of asm fragments. This should be considered untested ...
1 parent cfbd2af commit aac3c30

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/include/storage/s_lock.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* Portions Copyright (c) 1996-2009, 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.166 2009/01/01 17:24:01 momjian Exp $
69+
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.167 2009/07/27 05:31:05 tgl Exp $
7070
*
7171
*-------------------------------------------------------------------------
7272
*/
@@ -568,6 +568,36 @@ typedef int slock_t;
568568
#endif /* __m32r__ */
569569

570570

571+
#if defined(__sh__) /* Renesas' SuperH */
572+
#define HAS_TEST_AND_SET
573+
574+
typedef unsigned char slock_t;
575+
576+
#define TAS(lock) tas(lock)
577+
578+
static __inline__ int
579+
tas(volatile slock_t *lock)
580+
{
581+
register int _res;
582+
583+
/*
584+
* This asm is coded as if %0 could be any register, but actually SuperH
585+
* restricts the target of xor-immediate to be R0. That's handled by
586+
* the "z" constraint on _res.
587+
*/
588+
__asm__ __volatile__(
589+
" tas.b @%2 \n"
590+
" movt %0 \n"
591+
" xor #1,%0 \n"
592+
: "=z"(_res), "+m"(*lock)
593+
: "r"(lock)
594+
: "memory", "t");
595+
return _res;
596+
}
597+
598+
#endif /* __sh__ */
599+
600+
571601
/* These live in s_lock.c, but only for gcc */
572602

573603

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