From patchwork Thu May 28 22:37:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 6973 Received: (qmail 124495 invoked by alias); 28 May 2015 22:37:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 124476 invoked by uid 89); 28 May 2015 22:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] NaCl: Fix lll_futex_timed_wait timeout calculation. Message-Id: <20150528223706.D41FC2C3B00@topped-with-meat.com> Date: Thu, 28 May 2015 15:37:06 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=xPPz-1S54ozgx-sv9vQA:9 a=CjuIK1q_8ugA:10 Arithmetic is hard. Let's go shopping. Thanks, Roland 2015-05-28 Roland McGrath * 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; \ } \