[COMMITTED] NaCl: Fix lll_futex_timed_wait timeout calculation.
Commit Message
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.
@@ -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; \
} \