mktime loop
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue May 14 13:39:00 GMT 2013
On May 13 18:57, Corinna Vinschen wrote:
> On May 13 18:41, Denis Excoffier wrote:
> > On 2013-05-13 17:49, Corinna Vinschen wrote:
> > > Erm... hang on. Is that really a problem? 2147483647 is 0x7fffffff,
> > > which is the maximum you get with a 4 byte time_t (== signed long)
> > > anyway. If you switch the date to 2038-01-20, the value will be
> > > negative, and therefore outside the scope of the 4 byte time_t. So this
> > > is a hard restriction of using 4 byte time_t.
> > >
> > > The solution is:
> > >
> > > - Either somebody changes 32 bit Cygwin to 8 byte time_t while keeping
> > > all the 4 byte time_t APIs intact to maintain compatibility with
> > > existing binaries(*),
> > >
> > > - or, you switch to a 64 bit Windows and use 64 bit Cygwin ;)
> > >
> > I understand.
> >
> > I suppose you will however be willing to provide us a means to workaround
> > the "autoconf mktime usability test failing" (see for example in
> > gawk-4.1.0 where all the tm fields are set to 128). Now, instead of only
> > failing (i presume), it hangs. Sorry, this specific point should have been
> > noticed in my original post.
> >
> > Or do we have to patch every impacted ./configure?
>
> Good point. I guess the right thing to do here is for mktime to
> return -1 instead of hanging. I look into that.
Looks like this is a result of gcc optimization settings. The upstream
code computing time_t <-> struct tm conversions requires integer
overflow to be fully defined, but gcc's -O2 option sets
-fstrict-overflow which results in all kinds of agressive integer
optimizations which disabled utilizing integer overflows for serious
purposes. I fixed that by setting the -fwrapv option when building the
affected localtime.cc file (thanks to Kai Tietz for pointing this out).
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list