summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2015-05-28 15:35:45 -0700
committerRoland McGrath <roland@hack.frob.com>2015-05-28 15:35:45 -0700
commitf21754707cf42f18523aafdaad88b8ef3c317e37 (patch)
treee77e75fe1a37201f1e7674136e3c7bfab3581c54
parent58007e9e68913290b1f4f73afc1055f779a8ed5d (diff)
downloadglibc-f21754707cf42f18523aafdaad88b8ef3c317e37.tar.gz
glibc-f21754707cf42f18523aafdaad88b8ef3c317e37.tar.xz
glibc-f21754707cf42f18523aafdaad88b8ef3c317e37.zip
NaCl: Fix lll_futex_timed_wait timeout calculation.
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/nacl/lowlevellock-futex.h24
2 files changed, 17 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index b68eab55c5..37dc47b206 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-28  Roland McGrath  <roland@hack.frob.com>
+
+	* sysdeps/nacl/lowlevellock-futex.h (lll_futex_timed_wait):
+	Add TIMEOUT to current time, don't subtract it.
+
 2015-05-28  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #18422]
diff --git a/sysdeps/nacl/lowlevellock-futex.h b/sysdeps/nacl/lowlevellock-futex.h
index 8d888a2e72..b614ac8183 100644
--- a/sysdeps/nacl/lowlevellock-futex.h
+++ b/sysdeps/nacl/lowlevellock-futex.h
@@ -40,26 +40,26 @@
 /* Wait until a lll_futex_wake call on FUTEXP, or TIMEOUT elapses.  */
 #define lll_futex_timed_wait(futexp, val, timeout, private)             \
   ({                                                                    \
-    /* This timeout is relative, but the IRT call wants it absolute.  */ \
+    /* This timeout is relative, but the IRT call wants it absolute.  */\
     const struct timespec *_to = (timeout);                             \
     struct timespec _ts;                                                \
     int _err = 0;                                                       \
     if (_to != NULL                                                     \
-        && __glibc_likely ((_err = __nacl_irt_clock.clock_gettime	\
-                            (CLOCK_REALTIME, &_ts)) == 0))		\
+	&& __glibc_likely ((_err = __nacl_irt_clock.clock_gettime	\
+			    (CLOCK_REALTIME, &_ts)) == 0))		\
       {                                                                 \
-        _ts.tv_sec -= _to->tv_sec;                                      \
-        _ts.tv_nsec -= _to->tv_nsec;                                    \
-        while (_ts.tv_nsec < 0)                                         \
-          {                                                             \
-            _ts.tv_nsec += 1000000000;                                  \
-            --_ts.tv_sec;                                               \
-          }                                                             \
-        _to = &_ts;                                                     \
+	_ts.tv_sec += _to->tv_sec;                                      \
+	_ts.tv_nsec += _to->tv_nsec;                                    \
+	while (_ts.tv_nsec >= 1000000000)                               \
+	  {                                                             \
+	    _ts.tv_nsec -= 1000000000;                                  \
+	    ++_ts.tv_sec;                                               \
+	  }                                                             \
+	_to = &_ts;                                                     \
       }                                                                 \
     if (_err == 0)                                                      \
       _err = __nacl_irt_futex.futex_wait_abs				\
-        ((volatile int *) (futexp), val, _to);                          \
+	((volatile int *) (futexp), val, _to);                          \
     -_err;                                                              \
   })