From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#11825: 24.1.50; float-time no longer accepts negative time values Date: Sun, 08 Jul 2012 16:03:39 -0700 Organization: UCLA Computer Science Department Message-ID: <4FFA11CB.8000502@cs.ucla.edu> References: <4FF79ADD.8080601@cs.ucla.edu> <83r4so12ja.fsf@gnu.org> <4FF89C4C.6060503@cs.ucla.edu> <83wr2fklhs.fsf@gnu.org> <4FF93637.6060304@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1341788641 19025 80.91.229.3 (8 Jul 2012 23:04:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jul 2012 23:04:01 +0000 (UTC) Cc: 11825@debbugs.gnu.org To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 09 01:04:00 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1So0WF-0003e3-PW for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Jul 2012 01:03:59 +0200 Original-Received: from localhost ([::1]:59097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1So0WE-00087R-Ra for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Jul 2012 19:03:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1So0W9-00087M-Oc for bug-gnu-emacs@gnu.org; Sun, 08 Jul 2012 19:03:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1So0W7-000298-JP for bug-gnu-emacs@gnu.org; Sun, 08 Jul 2012 19:03:53 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1So0W7-00028y-GZ for bug-gnu-emacs@gnu.org; Sun, 08 Jul 2012 19:03:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1So0b8-0005nf-B9 for bug-gnu-emacs@gnu.org; Sun, 08 Jul 2012 19:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Jul 2012 23:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11825 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11825-submit@debbugs.gnu.org id=B11825.134178893322280 (code B ref 11825); Sun, 08 Jul 2012 23:09:02 +0000 Original-Received: (at 11825) by debbugs.gnu.org; 8 Jul 2012 23:08:53 +0000 Original-Received: from localhost ([127.0.0.1]:57108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1So0ay-0005nI-51 for submit@debbugs.gnu.org; Sun, 08 Jul 2012 19:08:52 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:58955) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1So0at-0005n8-SI for 11825@debbugs.gnu.org; Sun, 08 Jul 2012 19:08:49 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 24AC3A60007; Sun, 8 Jul 2012 16:03:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S6QEglxhjyYh; Sun, 8 Jul 2012 16:03:34 -0700 (PDT) Original-Received: from [192.168.1.4] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9C9E5A60001; Sun, 8 Jul 2012 16:03:34 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:61733 Archived-At: On 07/08/2012 02:00 AM, Andreas Schwab wrote: > A difference between two timestamps is always signed. No, not if A is an absolute time, and B is a (nonnegative) offset. The result is an absolute time, and is unsigned if A was unsigned. For example: EMACS_GET_TIME (t); EMACS_SUB_TIME (old, t, EMACS_TIME_FROM_DOUBLE (delay)); This is a common way that EMACS_SUB_TIME is used in Emacs. On 07/08/2012 08:32 AM, Eli Zaretskii wrote:> E.g., to express something like > > T1 = T2 + T3 - T4 > > instead of a simple > > t1 = timespec_add (t2, timespec_sub (t3, t4)); That doesn't suffice even if struct timespec uses a signed time_t -- if overflow occurred in the timespec_sub, the result might be incorrect. There is no simple solution here that does not involve complicating the API. Luckily, Emacs never needs to compute expressions like the above, so the problem doesn't need to be addressed right now. > this should be prominently explained in systime.h. OK, sure, I pushed this: --- src/systime.h 2012-07-07 01:57:42 +0000 +++ src/systime.h 2012-07-08 22:57:42 +0000 @@ -80,7 +80,8 @@ #define EMACS_GET_TIME(time) gettime (&(time)) /* Put into DEST the result of adding SRC1 to SRC2, or of subtracting - SRC2 from SRC1. On overflow, store an extremal value. */ + SRC2 from SRC1. On overflow, store an extremal value: ergo, if + time_t is unsigned, return 0 if the true answer would be negative. */ #define EMACS_ADD_TIME(dest, src1, src2) ((dest) = timespec_add (src1, src2)) #define EMACS_SUB_TIME(dest, src1, src2) ((dest) = timespec_sub (src1, src2))