On 27 Dec 2000 at 21:37 (-0500), Tom Lane wrote:
| Brent Verner <brent@rcfile.org> writes:
| > This is a revised patch that I sent earlier to allow building
| > pg-7.1 with gcc as well as DEC's cc. I've had good results with this
| > applied. Could some other Alpha users try this out. Even better, could
| > an Alpha asm guru look over the asm that I'm using (instead of the
| > original asm in the file).
|
| tas() is not supposed to contain a loop. It can succeed or fail, but
| it should not wait.
|
| The code now in s_lock.h does seem rather gratuitously obscure about
| the instructions it uses to load constants. I'd suggest
|
| static __inline__ int
| tas(volatile slock_t *lock)
| {
| register slock_t _res;
|
| __asm__(" ldq $0, %0 \n\
| bne $0, 2f \n\
| ldq_l $0, %0 \n\
| bne $0, 2f \n\
| mov 1, $0 \n\
| stq_c $0, %0 \n\
| beq $0, 2f \n\
| mov 0, %1 \n\
| mb \n\
| jmp $31, 3f \n\
| 2: mov 1, %1 \n\
| 3: nop ": "=m"(*lock), "=r"(_res): :"0");
|
| return (int) _res;
| }
another loop-free version of TAS that /seems/ to work as desired. WRT to your
seeing the shutdown lock failure, what are you doing to provoke this bug?,
because I have not seen it with either version of the TAS that I've used.
brent
#define TAS(lock) tas_dbv(lock)
#define S_UNLOCK(lock) do { __asm__("mb"); *(lock) = 0; } while (0)
static
__inline__
int
tas(volatile slock_t* __lock)
{ register slock_t __rv; register slock_t __temp;
__asm__ __volatile__ ( "1: ldq_l %0, %1 \n" /* load (and lock) __lock */ " and %0, 1,
%2 \n" /* if bit 1 is set, store 1 in __rv */ " bne %2, 2f \n" /* if __rv != 0, already locked.
leave */ " xor %0, 1, %0 \n" /* set bit 1 in slock_t */ " stq_c %0, %1 \n" /*
store__lock, only stores if we locked */ " mb \n" /* memory block (necessary?) */ "
2: nop \n" /* exit point */ : "=&r" (__temp), "=m" (*__lock),
"=&r"(__rv) : "m" (*__lock) );
return (int) __rv;
}