From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 11825@debbugs.gnu.org
Subject: bug#11825: 24.1.50; float-time no longer accepts negative time values
Date: Sun, 08 Jul 2012 18:32:50 +0300 [thread overview]
Message-ID: <83pq86l13x.fsf@gnu.org> (raw)
In-Reply-To: <4FF93637.6060304@cs.ucla.edu>
> Date: Sun, 08 Jul 2012 00:26:47 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 11825@debbugs.gnu.org
>
> On 07/07/2012 07:57 PM, Eli Zaretskii wrote:
> > are you saying that a time difference can
> > never be negative on such platforms?
>
> Yes, that's right.
>
> > What about the case tv_sec = 0
> > in both time values and tv_nsec difference is negative?
>
> In that case, timespec_sub returns the
> minimum possible time value, namely zero,
> since time_t is unsigned.
??? Really??? Then using these facilities safely and portably will be
extremely inconvenient. E.g., to express something like
T1 = T2 + T3 - T4
instead of a simple
t1 = timespec_add (t2, timespec_sub (t3, t4));
one would need something like
if (timespec_cmp (t3, t4) < 0)
{
struct timespec tem1 = timespec_sub (t4, t3);
if (timespec_cmp (t2, tem1) < 0)
/* error -- no way to express negative time */
else
t1 = timespec_sub (t2, tem1);
}
else
t1 = timespec_add (t2, timespec_sub (t3, t4);
Am I missing something?
If I'm right, and if there's no way to get better facilities, then at
the very least this should be prominently explained in systime.h.
Right now, this comment, for example:
/* Put into DEST the result of adding SRC1 to SRC2, or of subtracting
SRC2 from SRC1. On overflow, store an extremal value. */
doesn't come anywhere close to a hint that "an extremal value" could
mean zero when SRC1 < SRC2. It's very easy to write buggy code
without a clear understanding of this fact, and never find those bugs
in testing, if the system happens to use a signed type for time_t.
prev parent reply other threads:[~2012-07-08 15:32 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
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 [this message]
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=83pq86l13x.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=11825@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
/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.