This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Thu, 28 May 2015 15:37:06 -0700 (PDT)
- Subject: [COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation.
- Authentication-results: sourceware.org; auth=none
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; \
} \