From 056f707c8618062023a79fdbc6ec19ac482c63dd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 19 Jul 2000 06:24:30 +0000 Subject: Update. * spinlock.h (__pthread_alt_trylock): Fix code used if no compare&swap is available. --- linuxthreads/ChangeLog | 3 +++ linuxthreads/spinlock.h | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'linuxthreads') diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 1351c25495..f14cf0d4a5 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,5 +1,8 @@ 2000-07-18 Ulrich Drepper + * 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. diff --git a/linuxthreads/spinlock.h b/linuxthreads/spinlock.h index 17efd183cd..703b72d65e 100644 --- a/linuxthreads/spinlock.h +++ b/linuxthreads/spinlock.h @@ -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 -- cgit v1.2.3-70-g09d2