delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/05/13/12:42:03

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; q=dns; s=default; b=cQpkkk6oADi9nrv/EKKz/qqiZfKW
oeJgT3U/EhwRTRQNz/HELUS4d0X2HIjpbwhucNgqAYg7uItzvmIrHkexdkqt1TSJ
u4sQEIiGmrsNE7mMw59ogVsoUvlQyFxFd07sRJBI75nKjqU/wFSVuXItH9376bkQ
iS8QdmGNx2C5pjs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; s=default; bh=+JXfIX4Bf9nxdz3tSJS5JDScaAE=; b=jB
f3IpoL1ut49yEpBFoMoix7mboyhRzmTjnesAi95GU8odunLuNCerW/j4ByKMuHjb
RFMkHXuOpGhYXpiNMASy3ZdFIQouuB5idmcxNvbUJuE67WgYb2kJnzYy5ypzTvNj
y2unYJHQvwrYN3sxKR7j4pQR8c5Q4++j2hwUg3Gfs=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE autolearn=ham version=3.3.1
Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\))
Subject: Re: mktime loop
From: Denis Excoffier <cygwin AT Denis-Excoffier DOT org>
In-Reply-To: <20130513154921.GF8890@calimero.vinschen.de>
Date: Mon, 13 May 2013 18:41:36 +0200
Message-Id: <27BBE8FE-303A-432D-94AA-AF834124D125@Denis-Excoffier.org>
References: <5244063b734b165baf34bdebaff0aca5 AT denis-excoffier DOT org> <20130513153651 DOT GD5045 AT calimero DOT vinschen DOT de> <20130513154921 DOT GF8890 AT calimero DOT vinschen DOT de>
To: cygwin AT cygwin DOT com

On 2013-05-13 17:49, Corinna Vinschen wrote:
> On May 13 17:36, Corinna Vinschen wrote:
>> On May 13 09:08, Denis Excoffier wrote:
>>> Hello,
>>> 
>>> The following program (see below) is working properly under plain
>>> 1.7.18. With all the snapshots afterwards (including
>>> the current one 20130508), it fails after day=19, looping forever
>>> (it seems). I use XP.
>>> 
>>> Regards,
>>> 
>>> Denis Excoffier.
>>> 
>>> % cat foo.c
>>> #include <stdio.h>
>>> #include <time.h>
>>> 
>>> int
>>> main ()
>>> {
>>>  int day;
>>>  // date --date='@2147483647' +%Y-%m-%d gives 2038-01-19
>>>  for ( day = 1 ; day <= 31 ; ++day ) {
>>>    struct tm tm;
>>>    time_t now;
>>>    tm.tm_year = 2038 - 1900;
>>>    tm.tm_mon = 1 - 1;
>>>    tm.tm_mday = day; // 19, 20
>>>    tm.tm_hour = 0;
>>>    tm.tm_min = 0;
>>>    tm.tm_sec = 0;
>>>    now = mktime (&tm);
>>>    fprintf (stderr, "day=%d\n", day);
>>>  };
>>>  return 0;
>>> }
>> 
>> Thanks for the testcase.  This looks like the new BSD code I added
>> lately assumes that the datatype time_t is 8 bytes, not 4 byte as on 32
>> bit Cygwin.  That's just a hunch I take from the fact that your testcase
>> works fine on 64 bit Cygwin and only hangs on 32 bit Cygwin.  Oh well.
>> I'll investigate further...
> 
> 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?

Regards,

Denis Excoffier.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019