public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation.
@ 2015-05-29  2:59 Roland McGrath
  0 siblings, 0 replies; only message in thread
From: Roland McGrath @ 2015-05-29  2:59 UTC (permalink / raw)
  To: GNU C. Library

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;                                                     \
       }                                                                 \

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-28 22:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29  2:59 [COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).