summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Ogden <bernie.ogden@linaro.org>2014-08-11 15:26:48 +0100
committerWill Newton <will.newton@linaro.org>2014-08-12 12:57:27 +0100
commit4e75751cbbd47242946f817111066f511dbba739 (patch)
tree5d9b2b351ff0621f8090b7b4116ca17ce9d3a52c
parentbb2ce416563a61bb065f92e022dfd231097d90b6 (diff)
Check value of futex before updating in __lll_timedlock
2014-08-12 Bernard Ogden <bernie.ogden@linaro.org> [BZ #16892] * sysdeps/nptl/lowlevellock.h (__lll_timedlock): Use atomic_compare_and_exchange_bool_acq rather than atomic_exchange_acq.
-rw-r--r--ChangeLog6
-rw-r--r--sysdeps/nptl/lowlevellock.h5
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c73d092a20..a1285a8087 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-12 Bernard Ogden <bernie.ogden@linaro.org>
+
+ [BZ #16892]
+ * sysdeps/nptl/lowlevellock.h (__lll_timedlock): Use
+ atomic_compare_and_exchange_bool_acq rather than atomic_exchange_acq.
+
2014-08-12 Sean Anderson <seanga2@gmail.com>
* malloc/malloc.c: Fix typo in comment.
diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
index 548a9c842b..28f4ba3978 100644
--- a/sysdeps/nptl/lowlevellock.h
+++ b/sysdeps/nptl/lowlevellock.h
@@ -88,12 +88,15 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *,
extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
int private) attribute_hidden;
+/* Take futex if it is untaken.
+ Otherwise block until either we get the futex or abstime runs out. */
#define __lll_timedlock(futex, abstime, private) \
({ \
int *__futex = (futex); \
int __val = 0; \
\
- if (__glibc_unlikely (atomic_exchange_acq (__futex, 1))) \
+ if (__glibc_unlikely \
+ (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
__val = __lll_timedlock_wait (__futex, abstime, private); \
__val; \
})