mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 03:10:05 +00:00
Update.
* spinlock.h (__pthread_alt_trylock): Fix code used if no compare&swap is available.
This commit is contained in:
parent
a48297fdf3
commit
056f707c86
@ -1,5 +1,8 @@
|
||||
2000-07-18 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* spinlock.h (__pthread_alt_trylock): Fix code used if no
|
||||
compare&swap is available.
|
||||
|
||||
* spinlock.h (__pthread_trylock): Use __compare_and_swap, not
|
||||
compare_and_swap.
|
||||
|
||||
|
@ -149,7 +149,19 @@ static inline int __pthread_alt_trylock (struct _pthread_fastlock * lock)
|
||||
#endif
|
||||
#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
|
||||
{
|
||||
return (testandset(&lock->__spinlock) ? EBUSY : 0);
|
||||
int res = EBUSY;
|
||||
|
||||
if (testandset(&lock->__spinlock) == 0)
|
||||
{
|
||||
if (lock->__status == 0)
|
||||
{
|
||||
lock->__status = 1;
|
||||
WRITE_MEMORY_BARRIER();
|
||||
res = 0;
|
||||
}
|
||||
lock->__spinlock = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user