summaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h20
1 files changed, 6 insertions, 14 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
index 47174700d0..b30659fe90 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
@@ -127,10 +127,8 @@ static inline void
__attribute__ ((always_inline))
__lll_mutex_lock (int *futex)
{
- int val = atomic_exchange_and_add (futex, 1);
-
- if (__builtin_expect (val != 0, 0))
- __lll_lock_wait (futex, val);
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ __lll_lock_wait (futex);
}
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
@@ -139,13 +137,8 @@ static inline void
__attribute__ ((always_inline))
__lll_mutex_cond_lock (int *futex)
{
- int val = atomic_exchange_and_add (futex, 2);
-
- if (__builtin_expect (val != 0, 0))
- /* Note, the val + 1 is kind of ugly here. __lll_lock_wait will add
- 1 again. But we added 2 to the futex value so this is the right
- value which will be passed to the kernel. */
- __lll_lock_wait (futex, val + 1);
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex);
}
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
@@ -158,11 +151,10 @@ static inline int
__attribute__ ((always_inline))
__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
{
- int val = atomic_exchange_and_add (futex, 1);
int result = 0;
- if (__builtin_expect (val != 0, 0))
- result = __lll_timedlock_wait (futex, val, abstime);
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime);
return result;
}