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 2013d
details: https://anonhg.NetBSD.org/src/rev/66ce728acc30
branches: trunk
changeset: 788658:66ce728acc30
user: christos <christos%NetBSD.org@localhost>
date: Wed Jul 17 20:13:04 2013 +0000
description:
welcome to 2013d
diffstat:
lib/libc/time/Makefile | 61 +++++++--
lib/libc/time/Theory | 27 ++--
lib/libc/time/difftime.c | 23 +--
lib/libc/time/localtime.c | 231 +++++++++++++++++++++++---------------
lib/libc/time/private.h | 120 +++++++++++++++++++-
lib/libc/time/scheck.c | 33 +++--
lib/libc/time/strftime.c | 13 +-
lib/libc/time/tz-art.htm | 8 +-
lib/libc/time/tz-link.htm | 43 ++++--
lib/libc/time/tzfile.h | 4 +-
lib/libc/time/zdump.8 | 24 +++-
lib/libc/time/zdump.c | 275 ++++++++++++++++++++++++++++-----------------
lib/libc/time/zic.c | 210 +++++++++++++++++++---------------
13 files changed, 697 insertions(+), 375 deletions(-)
diffs (truncated from 2370 to 300 lines):
diff -r c00ba8ec3500 -r 66ce728acc30 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile Wed Jul 17 19:52:15 2013 +0000
+++ b/lib/libc/time/Makefile Wed Jul 17 20:13:04 2013 +0000
@@ -6,7 +6,7 @@
PACKAGE= tzcode
# Version numbers of the code and data distributions.
-VERSION= 2013c
+VERSION= 2013d
# Email address for bug reports.
BUGEMAIL= tz%iana.org@localhost
@@ -53,6 +53,9 @@
TZDIR= $(TOPDIR)/etc/zoneinfo
+# Types to try, as an alternative to time_t. int64_t should be first.
+TIME_T_ALTERNATIVES= int64_t int32_t uint32_t uint64_t
+
# The "tzselect", "zic", and "zdump" commands get installed in. . .
ETCDIR= $(TOPDIR)/etc
@@ -98,9 +101,11 @@
# Add the following to the end of the "CFLAGS=" line as needed.
# -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
# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
# ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
+# -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h"
# -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
# -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
# -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
@@ -109,23 +114,24 @@
# -DHAVE_SYMLINK=0 if your system lacks the symlink function
# -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
-# -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
# -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
-# -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
-# DST transitions if the time zone files cannot be accessed
+# -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
+# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
+# if you do not want run time warnings about formats that may cause
+# year 2000 grief
+# -DTIME_T_FLOATING=1 if your time_t (or time_tz) is floating point
+# -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
# -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
# -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
# the default is system-supplied, typically "/usr/lib/locale"
-# $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
-# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
-# if you do not want run time warnings about formats that may cause
-# year 2000 grief
+# -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
# -DNO_ERROR_IN_DST_GAP=1
# if you want mktime() not to return an error in the DST gap.
# -DZIC_MAX_ABBR_LEN_WO_WARN=3
# (or some other number) to set the maximum time zone abbreviation length
# that zic will accept without a warning (the default is 6)
+# $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
-Wall -Wextra \
-Wbad-function-cast -Wcast-align -Wcast-qual \
@@ -191,10 +197,6 @@
# These functions may well disappear in future releases of the time
# conversion package.
#
-# If you want Source Code Control System ID's left out of object modules, add
-# -DNOID
-# to the end of the "CFLAGS=" line.
-#
# If you'll never want to handle solar-time-based time zones, add
# -DNOSOLAR
# to the end of the "CFLAGS=" line
@@ -431,9 +433,10 @@
check_web: $(WEB_PAGES)
$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
-clean:
+clean_misc:
rm -f core *.o *.out \
date tzselect version.h zdump zic yearistype
+clean: clean_misc
rm -f -r tzpublic
maintainer-clean: clean
@@ -444,7 +447,8 @@
names:
@echo $(ENCHILADA)
-public: check check_public set-timestamps tarballs signatures
+public: check check_public check_time_t_alternatives \
+ set-timestamps tarballs signatures
# Set the time stamps to those of the git repository, if available,
# and if the files have not changed since then.
@@ -475,6 +479,35 @@
$(zic) -v -d tzpublic $(TDATA)
rm -f -r tzpublic
+# Check that the code works under various alternative
+# implementations of time_t.
+check_time_t_alternatives:
+ mkdir tzpublic
+ zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone.tab` && \
+ for type in $(TIME_T_ALTERNATIVES); do \
+ mkdir tzpublic/$$type && \
+ make clean_misc && \
+ make TOPDIR=`pwd`/tzpublic/$$type \
+ CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
+ install && \
+ diff -qr tzpublic/int64_t/etc/zoneinfo tzpublic/$$type/etc/zoneinfo && \
+ case $$type in \
+ int32_t) range=-2147483648,2147483647;; \
+ uint32_t) range=0,4294967296;; \
+ int64_t) continue;; \
+ *u*) range=0,10000000000;; \
+ *) range=-10000000000,10000000000;; \
+ esac && \
+ echo checking $$type zones ... && \
+ tzpublic/int64_t/etc/zdump -V -t $$range $$zones \
+ >tzpublic/int64_t.out && \
+ tzpublic/$$type/etc/zdump -V -t $$range $$zones \
+ >tzpublic/$$type.out && \
+ diff -u tzpublic/int64_t.out tzpublic/$$type.out \
+ || exit; \
+ done
+ rm -f -r tzpublic
+
tarballs: tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
tzcode$(VERSION).tar.gz: $(COMMON) $(DOCS) $(SOURCES) $(MISC)
diff -r c00ba8ec3500 -r 66ce728acc30 lib/libc/time/Theory
--- a/lib/libc/time/Theory Wed Jul 17 19:52:15 2013 +0000
+++ b/lib/libc/time/Theory Wed Jul 17 20:13:04 2013 +0000
@@ -264,12 +264,12 @@
TZ strings. A file name component must not exceed 14
characters or start with `-'. E.g., prefer `Brunei'
to `Bandar_Seri_Begawan'.
- Include at least one location per time zone rule set per country.
- One such location is enough. Use ISO 3166 (see the file
- iso3166.tab) to help decide whether something is a country.
- However, uninhabited ISO 3166 regions like Bouvet Island
+ Do not use names that differ only in case. Although the reference
+ implementation is case-sensitive, some other implementations
+ are not, and they would mishandle names differing only in case.
+ Uninhabited regions like the North Pole and Bouvet Island
do not need locations, since local time is not defined there.
- If all the clocks in a country's region have agreed since 1970,
+ If all the clocks in a region have agreed since 1970,
don't bother to include more than one location
even if subregions' clocks disagreed before 1970.
Otherwise these tables would become annoyingly large.
@@ -283,7 +283,7 @@
Use mainstream English spelling, e.g. prefer `Rome' to `Roma', and
prefer `Athens' to the true name (which uses Greek letters).
The POSIX file name restrictions encourage this rule.
- Use the most populous among locations in a country's time zone,
+ Use the most populous among locations in a zone,
e.g. prefer `Shanghai' to `Beijing'. Among locations with
similar populations, pick the best-known location,
e.g. prefer `Rome' to `Milan'.
@@ -302,10 +302,11 @@
Milan's population has grown to be somewhat greater
than Rome's.
If a name is changed, put its old spelling in the `backward' file.
+ This means old spellings will continue to work.
The file `zone.tab' lists the geographical locations used to name
time zone rule files. It is intended to be an exhaustive list
-of canonical names for geographic regions.
+of names for geographic regions as described above.
Older versions of this package used a different naming scheme,
and these older names are still supported.
@@ -359,14 +360,13 @@
If this is not available or is a phrase mentioning the country
(e.g. ``Cape Verde Time''), then:
- When a country has a single or principal time zone region,
+ When a country is identified with a single or principal zone,
append `T' to the country's ISO code, e.g. `CVT' for
Cape Verde Time. For summer time append `ST';
for double summer time append `DST'; etc.
- When a country has multiple time zones, take the first three
- letters of an English place name identifying each zone
- and then append `T', `ST', etc. as before;
- e.g. `VLAST' for VLAdivostok Summer Time.
+ Otherwise, take the first three letters of an English place
+ name identifying each zone and append 'T', 'ST', etc.
+ as before; e.g. 'VLAST' for VLAdivostok Summer Time.
Use UTC (with time zone abbreviation "zzz") for locations while
uninhabited. The "zzz" mnemonic is that these locations are,
@@ -587,7 +587,8 @@
Michael Allison and Robert Schmunk,
"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock"
-<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2004-07-30).
+<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08).
Jia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times
+<http://articles.latimes.com/2004/jan/14/science/sci-marstime14>
(2004-01-14), pp A1, A20-A21.
diff -r c00ba8ec3500 -r 66ce728acc30 lib/libc/time/difftime.c
--- a/lib/libc/time/difftime.c Wed Jul 17 19:52:15 2013 +0000
+++ b/lib/libc/time/difftime.c Wed Jul 17 20:13:04 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: difftime.c,v 1.13 2012/10/26 23:23:23 christos Exp $ */
+/* $NetBSD: difftime.c,v 1.14 2013/07/17 20:13:04 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)difftime.c 8.1";
#else
-__RCSID("$NetBSD: difftime.c,v 1.13 2012/10/26 23:23:23 christos Exp $");
+__RCSID("$NetBSD: difftime.c,v 1.14 2013/07/17 20:13:04 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -18,13 +18,12 @@
#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
-double
+double ATTRIBUTE_CONST
difftime(const time_t time1, const time_t time0)
{
/*
** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
** (assuming that the larger type has more precision).
- ** This is the common real-world case circa 2004.
*/
/*CONSTCOND*/
if (sizeof (double) > sizeof (time_t))
@@ -44,8 +43,8 @@
** if the minuend is greater than or equal to the subtrahend.
*/
if (time1 >= time0)
- return time1 - time0;
- else return -((double) (time0 - time1));
+ return time1 - time0;
+ else return -(double) (time0 - time1);
}
/*
** time_t is integral and signed.
@@ -56,17 +55,17 @@
return time1 - time0;
/*
** time1 and time0 have opposite signs.
- ** Punt if unsigned long is too narrow.
+ ** Punt if uintmax_t is too narrow.
+ ** This suffers from double rounding; attempt to lessen that
+ ** by using long double temporaries.
*/
/* CONSTCOND */
- if (sizeof (unsigned long) < sizeof (time_t))
+ if (sizeof (uintmax_t) < sizeof (time_t))
return (double) time1 - (double) time0;
/*
** Stay calm...decent optimizers will eliminate the complexity below.
*/
if (time1 >= 0 /* && time0 < 0 */)
- return (unsigned long) time1 +
- (unsigned long) (-(time0 + 1)) + 1;
- return -(double) ((unsigned long) time0 +
- (unsigned long) (-(time1 + 1)) + 1);
+ return (uintmax_t) time1 + (uintmax_t) (-(time0 + 1)) + 1;
+ return -(double) ((uintmax_t) time0 + (uintmax_t) (-(time1 + 1)) + 1);
}
diff -r c00ba8ec3500 -r 66ce728acc30 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Wed Jul 17 19:52:15 2013 +0000
+++ b/lib/libc/time/localtime.c Wed Jul 17 20:13:04 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.73 2013/03/02 21:24:28 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.74 2013/07/17 20:13:04 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.73 2013/03/02 21:24:28 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.74 2013/07/17 20:13:04 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -97,7 +97,7 @@
#endif /* !defined TZDEFDST */
struct ttinfo { /* time type information */
- long tt_gmtoff; /* UTC offset in seconds */
+ int_fast32_t tt_gmtoff; /* UTC offset in seconds */
int tt_isdst; /* used to set tm_isdst */
Home |
Main Index |
Thread Index |
Old Index