This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation.


Arithmetic is hard.  Let's go shopping.


Thanks,
Roland


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.

diff --git a/sysdeps/nacl/lowlevellock-futex.h b/sysdeps/nacl/lowlevellock-futex.h
index 8d888a2..b614ac8 100644
--- a/sysdeps/nacl/lowlevellock-futex.h
+++ b/sysdeps/nacl/lowlevellock-futex.h
@@ -48,12 +48,12 @@
 	&& __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_sec += _to->tv_sec;                                      \
+	_ts.tv_nsec += _to->tv_nsec;                                    \
+	while (_ts.tv_nsec >= 1000000000)                               \
 	  {                                                             \
-            _ts.tv_nsec += 1000000000;                                  \
-            --_ts.tv_sec;                                               \
+	    _ts.tv_nsec -= 1000000000;                                  \
+	    ++_ts.tv_sec;                                               \
 	  }                                                             \
 	_to = &_ts;                                                     \
       }                                                                 \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]