all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 11825@debbugs.gnu.org
Subject: bug#11825: 24.1.50; float-time no longer accepts negative time values
Date: Sun, 08 Jul 2012 16:03:39 -0700	[thread overview]
Message-ID: <4FFA11CB.8000502@cs.ucla.edu> (raw)
In-Reply-To: <m2liiu4og0.fsf@igel.home>

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))






  reply	other threads:[~2012-07-08 23:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30 16:08 bug#11825: 24.1.50; float-time no longer accepts negative time values Eli Zaretskii
2012-07-03 22:56 ` Glenn Morris
2012-07-07  2:11 ` Paul Eggert
2012-07-07  6:57   ` Eli Zaretskii
2012-07-07 20:30     ` Paul Eggert
2012-07-08  2:57       ` Eli Zaretskii
2012-07-08  7:26         ` Paul Eggert
2012-07-08  9:00           ` Andreas Schwab
2012-07-08 23:03             ` Paul Eggert [this message]
2012-07-08 23:37               ` Juanma Barranquero
2012-07-09  0:21                 ` Paul Eggert
2012-07-09  0:57                   ` Juanma Barranquero
2012-07-09  2:56               ` Eli Zaretskii
2012-07-09  3:33                 ` Paul Eggert
2012-07-08 15:32           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FFA11CB.8000502@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=11825@debbugs.gnu.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.