public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: Freddie Chopin <freddie_chopin@op.pl>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] Change time_t to 64-bit by default
Date: Thu, 07 Sep 2017 16:32:00 -0000	[thread overview]
Message-ID: <649743792.32997.1504800209582.JavaMail.zimbra@embedded-brains.de> (raw)
In-Reply-To: <1504794469.1677.0.camel@op.pl>


----- Freddie Chopin <freddie_chopin@op.pl> schrieb:
> On Thu, 2017-09-07 at 15:00 +0200, Sebastian Huber wrote:
> > The casts in Newlib gmtime_r() look pretty useless. I will send a
> > patch 
> > with:
> > 
> > diff --git a/newlib/libc/time/gmtime_r.c
> > b/newlib/libc/time/gmtime_r.c
> > index 81c7c94b1..6475df3ba 100644
> > --- a/newlib/libc/time/gmtime_r.c
> > +++ b/newlib/libc/time/gmtime_r.c
> > @@ -56,8 +56,8 @@ _DEFUN (gmtime_r, (tim_p, res),
> >     unsigned erayear, yearday, month, day;
> >     unsigned long eraday;
> > 
> > -  days = ((long)lcltime) / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
> > -  rem = ((long)lcltime) % SECSPERDAY;
> > +  days = lcltime / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
> > +  rem = lcltime % SECSPERDAY;
> >     if (rem < 0)
> >       {
> >         rem += SECSPERDAY;
> 
> You should also replace "long days, rem;" with "time_t days, rem;".

2147483647 days are roughly 5879489 years. This should be enough for most applications.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine gesch&auml;ftliche Mitteilung im Sinne des EHUG.

  reply	other threads:[~2017-09-07 16:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 12:34 Sebastian Huber
2017-09-07 13:00 ` Corinna Vinschen
2017-09-07 13:10   ` Sebastian Huber
2017-09-07 14:17     ` Corinna Vinschen
2017-09-07 16:03     ` Freddie Chopin
2017-09-07 16:32       ` Sebastian Huber [this message]
2017-09-07 18:47         ` Freddie Chopin
2017-09-07 20:59         ` Brian Inglis
2017-09-07 21:37           ` Brian Inglis
2017-09-07 21:58             ` Freddie Chopin
2017-09-08  5:40               ` Brian Inglis
2017-09-08  8:19                 ` Freddie Chopin
2017-09-08 14:46                   ` Corinna Vinschen
2017-09-08 15:00                     ` Brian Inglis
2017-09-08 16:34                       ` Corinna Vinschen
2017-09-10  4:04                         ` Brian Inglis
2017-09-11 15:17                           ` Time Fixes Diff (was: Change time_t to 64-bit by default) Brian Inglis
2017-09-11 18:53                             ` Time Fixes Diff Craig Howland
2017-09-12  5:34                               ` Brian Inglis
2017-09-12 20:19                                 ` Sebastian Huber

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=649743792.32997.1504800209582.JavaMail.zimbra@embedded-brains.de \
    --to=sebastian.huber@embedded-brains.de \
    --cc=freddie_chopin@op.pl \
    --cc=newlib@sourceware.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).