about summary refs log tree commit diff
path: root/sysdeps/nptl
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 /sysdeps/nptl
parentbb2ce416563a61bb065f92e022dfd231097d90b6 (diff)
downloadglibc-4e75751cbbd47242946f817111066f511dbba739.tar.gz
glibc-4e75751cbbd47242946f817111066f511dbba739.tar.xz
glibc-4e75751cbbd47242946f817111066f511dbba739.zip
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.
Diffstat (limited to 'sysdeps/nptl')
-rw-r--r--sysdeps/nptl/lowlevellock.h5
1 files changed, 4 insertions, 1 deletions
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;                                                      \
   })