Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/kern



On Mon, 11 Sep 2006, Perry E. Metzger wrote:
> Garrett D'Amore <gdamore%netbsd.org@localhost> 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)



Home | Main Index | Thread Index | Old Index