Subject: Re: CVS commit: src/sys/kern
To: Alan Barrett <apb@cequrux.com>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: source-changes
Date: 09/12/2006 08:30:49
Thank you for the references. I've fixed our implementation so it only
accepts time_t <= 60. I put in a comment explaining that double leap
seconds were a mistake, while there.
The funny thing is, I think a big chunk of this conversation came about
because folks didn't realize that the test >= 62 allowed for times
0...61. Probably if I tested for > 61 some folks would have just nodded
and said "ah, the double leap second, right"... :-)
-- Garrett
Alan Barrett wrote:
> On Mon, 11 Sep 2006, Perry E. Metzger wrote:
>
>> Garrett D'Amore <gdamore@netbsd.org> writes:
>>
>>> Modified Files:
>>> src/sys/kern: kern_todr.c
>>>
>>> Log Message:
>>> Allow for leap seconds.
>>>
>> I would have thought 61 was sufficient. Is 62 really possible?
>>
>
> In reality, there will never be more than one leap second in a given
> minute.
>
> The C89 standard accidentally made allowance for two leap seconds,
> saying that the tm_sec field of struct tm could contain values in the
> range 0 to 61. This old thread from comp.stc.c discusses the issue:
> <http://groups.google.co.uk/group/comp.std.misc/browse_thread/thread/9ebfaed74bffb281/c9babd4663808f0f?lnk=gst&q=tm_sec+leap&rnum=9>
>
> That error seems to have spread to other APIs. For example, time.h in
> SUSv2 <http://www.opengroup.org/onlinepubs/007908799/xsh/time.h.html>
> allows for a double leap second.
>
> C99 fixes this, saying that tm_sec contains values in the range 0 to 60
> (ISO 9899:1999 section 7.23.1).
>
> --apb (Alan Barrett)
>
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191