|
66 | 66 | * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
67 | 67 | * Portions Copyright (c) 1994, Regents of the University of California
|
68 | 68 | *
|
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 $ |
70 | 70 | *
|
71 | 71 | *-------------------------------------------------------------------------
|
72 | 72 | */
|
@@ -568,6 +568,36 @@ typedef int slock_t;
|
568 | 568 | #endif/* __m32r__ */
|
569 | 569 |
|
570 | 570 |
|
| 571 | +#if defined(__sh__)/* Renesas' SuperH */ |
| 572 | +#defineHAS_TEST_AND_SET |
| 573 | + |
| 574 | +typedefunsignedcharslock_t; |
| 575 | + |
| 576 | +#defineTAS(lock) tas(lock) |
| 577 | + |
| 578 | +static __inline__int |
| 579 | +tas(volatileslock_t*lock) |
| 580 | +{ |
| 581 | +registerint_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 | + |
571 | 601 | /* These live in s_lock.c, but only for gcc */
|
572 | 602 |
|
573 | 603 |
|
|