Update.
[glibc.git] / db2 / mutex / sparc.gcc
blob8445a0629b3a444e3663d1d0344539b58c58bad5
1 /*
2  * @(#)sparc.gcc        10.1 (Sleepycat) 4/12/97
3  *
4  * The ldstub instruction takes the location specified by its first argument
5  * (a register containing a memory address) and loads its contents into its
6  * second argument (a register) and atomically sets the contents the location
7  * specified by its first argument to a byte of 1s.  (The value in the second
8  * argument is never read, but only overwritten.)
9  *
10  * The membar instructions are needed to ensure that writes to the lock are
11  * correctly ordered with writes that occur later in the instruction stream.
12  *
13  * For gcc/sparc, 0 is clear, 1 is set.
14  */
16 #if defined(__sparcv9__)
17 Does the following code need membar instructions for V9 processors?
18 #endif
20 #define TSL_SET(tsl) ({                                                 \
21         register tsl_t *__l = (tsl);                                    \
22         register tsl_t __r;                                             \
23         __asm__ volatile                                                \
24             ("ldstub [%1],%0"                                           \
25             : "=r"( __r) : "r" (__l));                                  \
26         !__r;                                                           \
29 #define TSL_UNSET(tsl) ({                                               \
30          register tsl_t *__l = (tsl);                                   \
31         __asm__ volatile ("stb %%g0,[%0]" : : "r" (__l));               \
33 #define TSL_INIT(tsl)   TSL_UNSET(tsl)