Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/time welcome to 2014d; zic big bang fixes:



details:   https://anonhg.NetBSD.org/src/rev/241e0f3e7ed0
branches:  trunk
changeset: 329554:241e0f3e7ed0
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 28 19:13:27 2014 +0000

description:
welcome to 2014d; zic big bang fixes:
        some programs did not handle large negative time_t values well (gnome)

diffstat:

 lib/libc/time/Makefile    |   3 +-
 lib/libc/time/NEWS        |  18 +++++++++++++-
 lib/libc/time/tz-link.htm |   6 +++-
 lib/libc/time/zic.8       |   9 +++++-
 lib/libc/time/zic.c       |  59 +++++++++++++++++++++++++++++++++++-----------
 5 files changed, 76 insertions(+), 19 deletions(-)

diffs (228 lines):

diff -r 46bbc06f9164 -r 241e0f3e7ed0 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Wed May 28 17:09:18 2014 +0000
+++ b/lib/libc/time/Makefile    Wed May 28 19:13:27 2014 +0000
@@ -6,7 +6,7 @@
 PACKAGE=       tzcode
 
 # Version numbers of the code and data distributions.
-VERSION=       2014c
+VERSION=       2014d
 
 # Email address for bug reports.
 BUGEMAIL=      tz%iana.org@localhost
@@ -100,6 +100,7 @@
 LDLIBS=
 
 # Add the following to the end of the "CFLAGS=" line as needed.
+#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
 #  -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
 #  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
 #  -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS
diff -r 46bbc06f9164 -r 241e0f3e7ed0 lib/libc/time/NEWS
--- a/lib/libc/time/NEWS        Wed May 28 17:09:18 2014 +0000
+++ b/lib/libc/time/NEWS        Wed May 28 19:13:27 2014 +0000
@@ -1,11 +1,27 @@
 News for the tz database
 
 
+Release 2014d - 2014-05-27 21:34:40 -0700
+
+  Changes affecting code
+
+    zic no longer generates files containing time stamps before the Big Bang.
+    This works around GNOME bug 730332
+    <https://bugzilla.gnome.org/show_bug.cgi?id=730332>.
+    (Thanks to Leonardo Chiquitto for reporting the bug, and to
+    Arthur David Olson and James Cloos for suggesting improvements to the fix.)
+
+  Changes affecting documentation
+
+    tz-link.htm now mentions GNOME.
+
+
 Release 2014c - 2014-05-13 07:44:13 -0700
 
   Changes affecting near-future time stamps
 
-    Egypt observes DST starting May 15.  (Thanks to Ahmad El-Dardiry.)
+    Egypt observes DST starting 2014-05-15 at 24:00.
+    (Thanks to Ahmad El-Dardiry and Gunther Vermier.)
     Details have not been announced, except that DST will not be observed
     during Ramadan.  Guess that DST will stop during the same Ramadan dates as
     Morocco, and that Egypt's future spring and fall transitions will be the
diff -r 46bbc06f9164 -r 241e0f3e7ed0 lib/libc/time/tz-link.htm
--- a/lib/libc/time/tz-link.htm Wed May 28 17:09:18 2014 +0000
+++ b/lib/libc/time/tz-link.htm Wed May 28 19:13:27 2014 +0000
@@ -8,7 +8,7 @@
 <meta http-equiv="Content-type" content='text/html; charset="US-ASCII"'>
 <meta name="DC.Creator" content="Eggert, Paul">
 <meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2014-03-10">
+<meta name="DC.Date" content="2014-05-27">
 <meta name="DC.Description"
  content="Sources of information about time zones and daylight saving time">
 <meta name="DC.Identifier"
@@ -315,6 +315,10 @@
 <abbr>GNU</abbr> Lesser General Public License
 (<abbr title="Lesser General Public License">LGPL</abbr>)</a>,
 and is widely used in <abbr>GNU</abbr>/Linux systems.</li>
+<li><a href="http://www.gnome.org/";>GNOME</a>'s Glib has
+a <code><abbr>tz</abbr></code> binary file reader written in C that
+creates a <code>GTimeZone</code> object representing sets of UTC offsets.
+It is freely available under the <abbr>LGPL</abbr>.</li>
 <li><a href="http://bmsi.com/java/#TZ";>ZoneInfo.java</a>
 is a <code><abbr>tz</abbr></code> binary file reader written in Java.
 It is freely available under the <abbr>LGPL</abbr>.</li>
diff -r 46bbc06f9164 -r 241e0f3e7ed0 lib/libc/time/zic.8
--- a/lib/libc/time/zic.8       Wed May 28 17:09:18 2014 +0000
+++ b/lib/libc/time/zic.8       Wed May 28 19:13:27 2014 +0000
@@ -1,5 +1,5 @@
-.\"    $NetBSD: zic.8,v 1.21 2013/09/20 19:06:54 christos Exp $
-.Dd September 20, 2013
+.\"    $NetBSD: zic.8,v 1.22 2014/05/28 19:13:27 christos Exp $
+.Dd May 28, 2014
 .Dt ZIC 8
 .Os
 .Sh NAME
@@ -438,6 +438,11 @@
 To get separate transitions
 use multiple zone continuation lines
 specifying transition instants using universal time.
+.Pp
+Time stamps well before the Big Bang are silently omitted from the output.
+This works around bugs in software that mishandles large negative time stamps.
+Call it sour grapes, but pre-Big-Bang time stamps are physically suspect anyway.
+The pre-Big-Bang cutoff time is approximate and may change in future versions.
 .Sh FILES
 .Pa /usr/share/zoneinfo
 - standard directory used for created files
diff -r 46bbc06f9164 -r 241e0f3e7ed0 lib/libc/time/zic.c
--- a/lib/libc/time/zic.c       Wed May 28 17:09:18 2014 +0000
+++ b/lib/libc/time/zic.c       Wed May 28 19:13:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zic.c,v 1.45 2014/05/13 16:33:56 christos Exp $        */
+/*     $NetBSD: zic.c,v 1.46 2014/05/28 19:13:27 christos Exp $        */
 /*
 ** This file is in the public domain, so clarified as of
 ** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.45 2014/05/13 16:33:56 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.46 2014/05/28 19:13:27 christos Exp $");
 #endif /* !defined lint */
 
 #include "version.h"
@@ -737,6 +737,36 @@
 static const zic_t min_time = (zic_t) -1 << (TIME_T_BITS_IN_FILE - 1);
 static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1));
 
+/* Estimated time of the Big Bang, in seconds since the POSIX epoch.
+   rounded downward to the negation of a power of two that is
+   comfortably outside the error bounds.
+
+   zic does not output time stamps before this, partly because they
+   are physically suspect, and partly because GNOME mishandles them; see
+   GNOME bug 730332 <https://bugzilla.gnome.org/show_bug.cgi?id=730332>.
+
+   For the time of the Big Bang, see:
+
+   Ade PAR, Aghanim N, Armitage-Caplan C et al.  Planck 2013 results.
+   I. Overview of products and scientific results.
+   arXiv:1303.5062 2013-03-20 20:10:01 UTC
+   <http://arxiv.org/pdf/1303.5062v1> [PDF]
+
+   Page 36, Table 9, row Age/Gyr, column Planck+WP+highL+BAO 68% limits
+   gives the value 13.798 plus-or-minus 0.037 billion years.
+   Multiplying this by 1000000000 and then by 31557600 (the number of
+   seconds in an astronomical year) gives a value that is comfortably
+   less than 2**59, so BIG_BANG is - 2**59.
+
+   BIG_BANG is approximate, and may change in future versions.
+   Please do not rely on its exact value.  */
+
+#ifndef BIG_BANG
+#define BIG_BANG (- (1LL << 59))
+#endif
+
+static const zic_t big_bang_time = BIG_BANG;
+
 static int
 itsdir(const char *const name)
 {
@@ -1188,10 +1218,6 @@
                        return;
        }
        dayoff = oadd(dayoff, day - 1);
-       if (dayoff < 0 && !TYPE_SIGNED(zic_t)) {
-               error(_("time before zero"));
-               return;
-       }
        if (dayoff < min_time / SECSPERDAY) {
                error(_("time too small"));
                return;
@@ -1200,7 +1226,7 @@
                error(_("time too large"));
                return;
        }
-       t = (zic_t) dayoff * SECSPERDAY;
+       t = dayoff * SECSPERDAY;
        tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
        cp = fields[LP_CORR];
        {
@@ -1229,7 +1255,12 @@
                                ));
                        return;
                }
-               leapadd(tadd(t, tod), positive, lp->l_value, count);
+               t = tadd(t, tod);
+               if (t < big_bang_time) {
+                       error(_("leap second precedes Big Bang"));
+                       return;
+               }
+               leapadd(t, positive, lp->l_value, count);
        }
 }
 
@@ -1489,7 +1520,7 @@
 
                toi = 0;
                fromi = 0;
-               while (fromi < timecnt && attypes[fromi].at < min_time)
+               while (fromi < timecnt && attypes[fromi].at < big_bang_time)
                        ++fromi;
                for ( ; fromi < timecnt; ++fromi) {
                        if (toi > 1 && ((attypes[fromi].at +
@@ -2184,9 +2215,9 @@
                */
                stdoff = 0;
                zp = &zpfirst[i];
-               usestart = i > 0 && (zp - 1)->z_untiltime > min_time;
+               usestart = i > 0 && (zp - 1)->z_untiltime > big_bang_time;
                useuntil = i < (zonecount - 1);
-               if (useuntil && zp->z_untiltime <= min_time)
+               if (useuntil && zp->z_untiltime <= big_bang_time)
                        continue;
                gmtoff = zp->z_gmtoff;
                eat(zp->z_filename, zp->z_linenum);
@@ -2202,7 +2233,7 @@
                        if (usestart) {
                                addtt(starttime, type);
                                usestart = FALSE;
-                       } else  addtt(min_time, type);
+                       } else  addtt(big_bang_time, type);
                } else for (year = min_year; year <= max_year; ++year) {
                        if (useuntil && year > zp->z_untilrule.r_hiyear)
                                break;
@@ -2383,8 +2414,8 @@
 static void
 addtt(const zic_t starttime, int type)
 {
-       if (starttime <= min_time ||
-               (timecnt == 1 && attypes[0].at < min_time)) {
+       if (starttime <= big_bang_time ||
+               (timecnt == 1 && attypes[0].at < big_bang_time)) {
                gmtoffs[0] = gmtoffs[type];
                isdsts[0] = isdsts[type];
                ttisstds[0] = ttisstds[type];



Home | Main Index | Thread Index | Old Index