History log of /bionic/libc/tzcode/private.h
Revision Date Author Comments
9fb22a3ec4ec5217fc29bb3ee3a0f1076098151f 08-Oct-2015 Elliott Hughes <enh@google.com> Sync with upstream tzcode (2015g).

This is quite a large patch because we haven't updated for some time,
but the good news is that upstream is now thread-safe so a lot of our
changes go away in this update and the remaining diff is a lot smaller.

(Note that our whitespace still doesn't match upstream. I use diff -wub
to compare. Upstream doesn't even really have a consistent style. New
code seems to be two spaces, old code tabs.)

From the intervening changelogs (eliding the changes that only affected
the tools, which we don't use):

2014a:
An uninitialized-storage bug in 'localtime' has been fixed.
(Thanks to Logan Chien.)

2014b:
'zic' and 'localtime' no longer reject locations needing four
transitions per year for the forseeable future. (Thanks to Andrew
Main (Zefram).)

2014c:
<None>

2014d:
<None>

2014e:
<None>

2014f:
'localtime', 'mktime', etc. now use much less stack space if
ALL_STATE is defined. (Thanks to Elliott Hughes for reporting the
problem.)

Some lint has been removed when using GCC_DEBUG_FLAGS with GCC
4.9.0.

2014g:
Unless NETBSD_INSPIRED is defined to 0, the tz library now
supplies functions for creating and using objects that represent
time zones. The new functions are tzalloc, tzfree, localtime_rz,
mktime_z, and (if STD_INSPIRED is also defined) posix2time_z and
time2posix_z. They are intended for performance: for example,
localtime_rz (unlike localtime_r) is trivially thread-safe without
locking. (Thanks to Christos Zoulas for proposing NetBSD-inspired
functions, and to Alan Barrett and Jonathan Lennox for helping to
debug the change.)

If THREAD_SAFE is defined to 1, the tz library is now thread-safe.
Although not needed for tz's own applications, which are single-threaded,
this supports POSIX better if the tz library is used in multithreaded apps.

Some crashes have been fixed when zdump or the tz library is given
invalid or outlandish input.

The tz library no longer mishandles leap seconds on platforms with
unsigned time_t in time zones that lack ordinary transitions after 1970.

The tz code now attempts to infer TM_GMTOFF and TM_ZONE if not
already defined, to make it easier to configure on common platforms.
Define NO_TM_GMTOFF and NO_TM_ZONE to suppress this.

Unless the new macro UNINIT_TRAP is defined to 1, the tz code now
assumes that reading uninitialized memory yields garbage values
but does not cause other problems such as traps.

If TM_GMTOFF is defined and UNINIT_TRAP is 0, mktime is now
more likely to guess right for ambiguous time stamps near
transitions where tm_isdst does not change.

If HAVE_STRFTIME_L is defined to 1, the tz library now defines
strftime_l for compatibility with recent versions of POSIX.
Only the C locale is supported, though. HAVE_STRFTIME_L defaults
to 1 on recent POSIX versions, and to 0 otherwise.

tzselect -c now uses a hybrid distance measure that works better
in Africa. (Thanks to Alan Barrett for noting the problem.)

The C source code now ports to NetBSD when GCC_DEBUG_FLAGS is used,
or when time_tz is defined.

When HAVE_UTMPX_H is set the 'date' command now builds on systems
whose <utmpx.h> file does not define WTMPX_FILE, and when setting
the date it updates the wtmpx file if _PATH_WTMPX is defined.
This affects GNU/Linux and similar systems.

For easier maintenance later, some C code has been simplified,
some lint has been removed, and the code has been tweaked so that
plain 'make' is more likely to work.

The C type 'bool' is now used for boolean values, instead of 'int'.

The long-obsolete LOCALE_HOME code has been removed.

The long-obsolete 'gtime' function has been removed.

2014h:
The tz library's localtime and mktime functions now set tzname to a value
appropriate for the requested time stamp, and zdump now uses this
on platforms not defining TM_ZONE, fixing a 2014g regression.
(Thanks to Tim Parenti for reporting the problem.)

The tz library no longer sets tzname if localtime or mktime fails.

An access to uninitalized data has been fixed.
(Thanks to Jörg Richter for reporting the problem.)

When THREAD_SAFE is defined, the code ports to the C11 memory model.
A memory leak has been fixed if ALL_STATE and THREAD_SAFE are defined
and two threads race to initialize data used by gmtime-like functions.
(Thanks to Andy Heninger for reporting the problems.)

2014i:
The time-related library functions now set errno on failure,
and some crashes in the new tzalloc-related library functions
have been fixed. (Thanks to Christos Zoulas for reporting
most of these problems and for suggesting fixes.)

If USG_COMPAT is defined and the requested time stamp is
standard time, the tz library's localtime and mktime functions
now set the extern variable timezone to a value appropriate
for that time stamp; and similarly for ALTZONE, daylight
saving time, and the altzone variable. This change is a
companion to the tzname change in 2014h, and is designed to
make timezone and altzone more compatible with tzname.

The tz library's functions now set errno to EOVERFLOW if they
fail because the result cannot be represented. ctime and
ctime_r now return NULL and set errno when a time stamp is out
of range, rather than having undefined behavior.

Some bugs associated with the new 2014g functions have been
fixed. This includes a bug that largely incapacitated the new
functions time2posix_z and posix2time_z. (Thanks to Christos
Zoulas.) It also includes some uses of uninitialized
variables after tzalloc. The new code uses the standard type
'ssize_t', which the Makefile now gives porting advice about.

2014j:
<None>

2015a:
tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.

2015b:
Fix integer overflow bug in reference 'mktime' implementation.
(Problem reported by Jörg Richter.)

Allow -Dtime_tz=time_t compilations, and allow -Dtime_tz=... libraries
to be used in the same executable as standard-library time_t functions.
(Problems reported by Bradley White.)

2015c:
<None>

2015d:
<None>

2015e:
<None>

2015f:
<None>

2015g:
localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

On hosts with signed 32-bit time_t, localtime no longer mishandles
Pacific/Fiji after 2038-01-16 14:00 UTC.

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Change-Id: I9eb0a8323cb8bd9968fcfe612dc14f45aa3b59d2
23360cc4980213d375718b7c124ecc0a21a1b1b7 29-Sep-2015 Stephen Hines <srhines@google.com> Remove invalid left shifts of -1.

Bug: 24492248

Shifting sign bits left is considered undefined behavior, so we need to
switch these uses to unsigned equivalents. The time_t-related code is
updated relative to upstream sources.

Change-Id: I226e5a929a10f5c57dfcb90c748fdac34eb377c2
5f564540a953a670925e058dabc521f68ffb997c 19-Jun-2014 Elliott Hughes <enh@google.com> Build tzcode with -Werror.

Parts of this are just getting us in sync with upstream, but the
'const' stuff is our own mess. We should kill the *_tz functions
and lose this difference from upstream.

Change-Id: I17d26534ed3f54667143d78147a8c53be56d7b33
627d37cd1f7bb6680f611dbe5f28b74a086567a7 28-Feb-2014 Calin Juravle <calin@google.com> Update tzcode to 2013i

Bug: 12246757
Change-Id: I3d5d2318155b1f54ef80afd58b1e5ca9a6d7018e
e0d0b15de6eaee6c3975e13ad2b0e1238d0fdd8f 27-Sep-2013 Elliott Hughes <enh@google.com> Upgrade to tzcode2013f plus Android modifications (from tzcode2013d plus Android modifications).

localtime.c and strftime.c are still quite different from upstream because of
our extensions, but the other files continue to be identical, and the two
exceptions should be otherwise identical.

From the tzcode2013e release notes:

Changes affecting Godthab time stamps after 2037 if version mismatch

Allow POSIX-like TZ strings where the transition time's hour can
range from -167 through 167, instead of the POSIX-required 0
through 24. E.g., TZ='FJT-12FJST,M10.3.1/146,M1.3.4/75' for the
new Fiji rules. This is a more-compact way to represent
far-future time stamps for America/Godthab, America/Santiago,
Antarctica/Palmer, Asia/Gaza, Asia/Hebron, Asia/Jerusalem,
Pacific/Easter, and Pacific/Fiji. Other zones are unaffected by
this change. (Derived from a suggestion by Arthur David Olson.)

Allow POSIX-like TZ strings where daylight saving time is in
effect all year. E.g., TZ='WART4WARST,J1/0,J365/25' for Western
Argentina Summer Time all year. This supports a more-compact way
to represent the 2013d data for America/Argentina/San_Luis.
Because of the change for San Luis noted above this change does not
affect the current data. (Thanks to Andrew Main (Zefram) for
suggestions that improved this change.)

Where these two TZ changes take effect, there is a minor extension
to the tz file format in that it allows new values for the
embedded TZ-format string, and the tz file format version number
has therefore been increased from 2 to 3 as a precaution.
Version-2-based client code should continue to work as before for
all time stamps before 2038. Existing version-2-based client code
(tzcode, GNU/Linux, Solaris) has been tested on version-3-format
files, and typically works in practice even for time stamps after
2037; the only known exception is America/Godthab.

Changes affecting API

Support for floating-point time_t has been removed.
It was always dicey, and POSIX no longer requires it.
(Thanks to Eric Blake for suggesting to the POSIX committee to
remove it, and thanks to Alan Barrett, Clive D.W. Feather, Andy
Heninger, Arthur David Olson, and Alois Treindl, for reporting
bugs and elucidating some of the corners of the old floating-point
implementation.)

The signatures of 'offtime', 'timeoff', and 'gtime' have been
changed back to the old practice of using 'long' to represent UT
offsets. This had been inadvertently and mistakenly changed to
'int_fast32_t'. (Thanks to Christos Zoulos.)

The code avoids undefined behavior on integer overflow in some
more places, including gmtime, localtime, mktime and zdump.

Changes affecting code internals

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting documentation and commentary

Documentation and commentary is more careful to distinguish UT in
general from UTC in particular. (Thanks to Steve Allen.)

From the tzcode2013f release notes:

Changes affecting API

The types of the global variables 'timezone' and 'altzone' (if present)
have been changed back to 'long'. This is required for 'timezone'
by POSIX, and for 'altzone' by common practice, e.g., Solaris 11.
These variables were originally 'long' in the tz code, but were
mistakenly changed to 'time_t' in 1987; nobody reported the
incompatibility until now. The difference matters on x32, where
'long' is 32 bits and 'time_t' is 64. (Thanks to Elliott Hughes.)

Change-Id: I14937c42a391ddb865e4d89f0783961bcc6baa21
345eb225ae2e87e36354be5f1e62301179482804 22-Aug-2013 Elliott Hughes <enh@google.com> Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.

Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Aug 22 12:47:51 2013 -0700

* localtime.c: Fix another integer overflow bug in mktime.

(time2sub): Avoid undefined behavior on time_t overflow.
Reported by Elliott Hughes in
<http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929

(cherry picked from commit 713fe6463e6ff8cb9689aa8ead88c885d25d03aa)

Change-Id: I9ec79fd8d825e6b9e8bb5af549dbfc2182346c05
713fe6463e6ff8cb9689aa8ead88c885d25d03aa 22-Aug-2013 Elliott Hughes <enh@google.com> Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.

Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Aug 22 12:47:51 2013 -0700

* localtime.c: Fix another integer overflow bug in mktime.

(time2sub): Avoid undefined behavior on time_t overflow.
Reported by Elliott Hughes in
<http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929
Change-Id: I3bf26f1f91371552e0a3828457d27e22af55acb2
ce4783ce76a4ef888466e02e4c6f3a0a3910bce8 13-Jul-2013 Elliott Hughes <enh@google.com> Upgrade to tzcode2013d.

Well, kinda... localtime.c still contains a bunch of Android-specific
hacks, as does strftime.c. But the other files are now exactly the same
as upstream.

This catches up with several years of bug fixes, and fixes most of the
compiler warnings that were in this code. (Just two remain.)

Bug: 1744909
Change-Id: I2ddfecb6fd408c847397c17afb0fff859e27feef
194d3fa048cf909ca592dd56fa538dc9cd3f5ddb 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
edbe7fc97bab7ff0684053d1be564330689bf3ad 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
1dc9e472e19acfe6dc7f41e429236e7eef7ceda1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1767f908af327fa388b1c66883760ad851267013 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution