History log of /bionic/libc/tzcode/localtime.c
Revision Date Author Comments
90cb5ffb85a9bc2e725824b3ca8db932d02c45db 07-Aug-2014 Elliott Hughes <enh@google.com> Fix the tzdata update tools.

The recent libcore ZoneInfo changes mean that we can no longer
compile libcore's ZoneInfo against the RI. Luckily, the field in
our data file that we needed ZoneInfo for isn't actually used.
This change removes our dependence on libcore.

I've left the field in to avoid a file format change. We can remove
the field if/when we next have a real need to bump the file format.

Bug: 16168653
Change-Id: Iedad2252c2b49f4d8bb2c7d9078b39b622444ca7
c1a6a7256026431a9ae49ef2a6139ea99410819b 26-Jul-2014 Elliott Hughes <enh@google.com> Remove localtime_tz and strftime_tz.

This also brings our copy of strftime.c much closer to upstream, though
we still have several GNU extensions and hacks to deal with Android32's
broken time_t.

Bug: 15765976

(cherry picked from commit 39d903aea901cd29a4eef3a82c2dbda59b5bc292)

Change-Id: Ie278d3e976b7adc77bad5ce795dd4899cfbf3648
708c11205443cda14cfb21138d441106aa77a5f9 25-Jul-2014 Elliott Hughes <enh@google.com> Start hiding "private/bionic_time.h".

Bug: 15765976

(cherry picked from commit 905e6d58aaf515bf237e62078f8a321920fe4c6b)

Change-Id: Ic7435308e8b521886f42ac7bf59531924921ea67
d10db8261949e4d84b65f5c369153d0ca86ab22c 19-Jun-2014 Elliott Hughes <enh@google.com> Build tzcode with hidden visibility.

Bug: 11156955
Change-Id: Ib98d837b56cbbdfd01687cb3054fe3103eec0da9
2cb752664bbde379c20931fa330563d775b60033 19-Jun-2014 Elliott Hughes <enh@google.com> Fix arm64 localtime.c build.

I'm sick of having so many different compilers.

Change-Id: I9088c38df2504e2b827d0ce5ba0fa551ae48f8f9
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
906eb9999b39edc0d09cd19ae94523e92ed5ad2e 19-Jun-2014 Elliott Hughes <enh@google.com> Update localtime.c.

This brings us closer to upstream's ToT localtime.c; our main interest
being their alternative fix for the stack usage we addressed in commit
8a8b0c9bfcd80c67154ed2aca1e60d815c822acb.

Bug: 14468519
Change-Id: Ic28600115afda7f3158d91255edf422678bac082
5204a9e8ca1ca7304db9998dcf3fc5a2d6087662 12-Jun-2014 Elliott Hughes <enh@google.com> Fix most of the tzcode warnings.

There's one left, but that's not fixed upstream yet.

Change-Id: Iba920cb7b156357c7f5e8220eb55ff1637ff48a1
8a8b0c9bfcd80c67154ed2aca1e60d815c822acb 15-May-2014 Christopher Ferris <cferris@google.com> Do not keep struct state on the stack.

This structure is huge (~18000 bytes on arm64) and can blow out
the stack very easily.
Modify the code to allocate these structures instead of leaving them
on the stack.

Bug: 14468519
Change-Id: I774f71235d896d32a14ab1af06f95ca9ef819f52
1728b2396591853345507a063ed6075dfd251706 14-May-2014 Elliott Hughes <enh@google.com> Switch to g_ for globals.

That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
329103d3e2f42d3e35a060c3e0d326d6476eb2ef 26-Apr-2014 Elliott Hughes <enh@google.com> Don't use so much stack in tzcode.

Bug: 14313703
Bug: https://code.google.com/p/android/issues/detail?id=61130
Change-Id: Id9b240fce20d4a6f2660792070e02b2b5f287655
d892892e8e185b9b948dec6a576f6202b186dc9d 28-Feb-2014 Calin Juravle <calin@google.com> Fix locatime.c indentation after sync

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

Bug: 12246757
Change-Id: I3d5d2318155b1f54ef80afd58b1e5ca9a6d7018e
fd3a9fb0c3b555d2fc93a6436da840ab4ea2fac1 28-Feb-2014 Elliott Hughes <enh@google.com> Vastly reduce the number of read(2)s done in tzload.

This costs us about 1000 fewer syscalls, which makes "adb shell strace date"
a lot more readable (which is the reason I've been meaning to fix this for a
long time now), but also actually saves a measurable amount of time.

Longer-term we should try to keep the tzdata mmap(2)ed in like libcore
does.

Change-Id: I1dd9c81968a13d3a6a55ba17f8a7d5c1f38cd103
3073f90b17b1d2899b036e2c45ba5324f8c34298 28-Feb-2014 Elliott Hughes <enh@google.com> Fix a leak on error in tzload.

Change-Id: Ib5d9aaa7a618e478ce8e5e82f967cf535bb1a5a3
51aeff70218e18a7213fc6b7b9a4112be488bf58 09-Oct-2013 Elliott Hughes <enh@google.com> Fix 32-bit build.

libc/tzcode/localtime.c: In function 'differ_by_repeat':
libc/tzcode/localtime.c:338:2: error: comparison is always false due to limited range of data type [-Werror=type-limits]

Change-Id: Ic84be6391a66e9d50ed98f41d865387c77a60ffa
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
cf178bf7d0300edfeec31528a744aa38a7177c0e 19-Sep-2013 Elliott Hughes <enh@google.com> Use $ANDROID_DATA and $ANDROID_ROOT to find the tzdata.

This lets us run binaries linked against bionic on an x86 host.

Change-Id: Icd60cf99a90d747c77304c05b4f764e4d26af985
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
e7aaad8b832bdff3b88aa62b5c7597e5fd3db520 25-Apr-2013 Elliott Hughes <enh@google.com> Improve diagnostics in the face of bad tzdata.

Bug: 8373554
Change-Id: If8df5e956105e01cce95221ff0a7fa9d2b474db3
744df77d4730cff99ac36f9761153620105dd9d7 14-Mar-2013 Elliott Hughes <enh@google.com> am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids."

* commit '2e7b8d6399fdea6e43dd07f353346324d2bf4ec4':
Don't search off the end of the index for bad Olson ids.
e0175ca7e440a87e9d03f249fc8f210063df7908 14-Mar-2013 Elliott Hughes <enh@google.com> Don't search off the end of the index for bad Olson ids.

In the old code, the index was a file to itself, so it made sense to
read until you hit the end of the file. In the new code, the index is
followed by hundreds of KiB of data, so we need to just search the
index.

Bug: 8368791
Change-Id: Icf5f8b5516cf3a93679fa849c9f6cd1cb100e0f1
4a05bef4c06dac05f1c9aa8cfc5b7e7dd6642385 12-Mar-2013 Elliott Hughes <enh@google.com> Cache the most-recently used timezone for mktime_tz and localtime_tz.

Normally, the C library implicitly caches your timezone by virtue
of the fact that the prehistoric API assumes a single timezone for
the entire process.

The unfortunate mktime_tz and localtime_tz extensions work around
this, but represent timezones as strings to their callers, so code
that makes heavy use of these needs a cache to be able to perform
acceptably until it can hopefully one day be rewritten to use
java.util.Calendar or icu4c.

Bug: 8270865
Change-Id: I92e3964e86dc33ceac925f819cc5e26ff4203f50
b989c9ceda71f6f75112645b5c45af341275cbab 16-Jan-2013 Elliott Hughes <enh@google.com> Revert "DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic.""

This reverts commit f4b34b6c3942be273ad7298a40be0d312b183aab.
acb907fb0d253391c1515f488f2a51dcda502e7c 15-Jan-2013 Elliott Hughes <enh@google.com> Revert "DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic.""

This reverts commit f4b34b6c3942be273ad7298a40be0d312b183aab.

The revert was only meant to apply to the jb-mr1 branch, but accidentally
leaked out into AOSP. This revert-revert gets AOSP master and internal
master back in sync.
49271d89dabae182f5614c0d5fb232dac3c16067 25-Oct-2012 Elliott Hughes <enh@google.com> Fix recovery: don't assert if there's no tzdata.

Change-Id: I4d808b57c63ec1ccc024da7fd6a65691e0d455c5
2393535f0d7df55dae3b4fbf5dbcfa7f87192762 22-Oct-2012 Elliott Hughes <enh@google.com> Support zone.tab in bionic, and remove the file format version.

Bug: 7012465
Change-Id: I6335c91ebadc609fae85bad94db972be7574b6e4
1c295720343009a7393706f2285a4d026e97eebf 20-Oct-2012 Elliott Hughes <enh@google.com> Make bionic look in /data/misc for tzdata updates.

Bug: 7012465
Change-Id: I4d1018f686f2409600fdb6630732cae33efe8f02
8b95404d001b285220ae7cbef661b0446a02858b 18-Oct-2012 Elliott Hughes <enh@google.com> Fixes x86 build.

Change-Id: I0e576784b2224668d58ebea03986d534ee0e43b4
d23af232688bf6980e4503cda6b12ed739292931 18-Oct-2012 Elliott Hughes <enh@google.com> Pull bionic's time zone data from the new single 'tzdata' file.

Bug: 7012465
Change-Id: Iec71e448bf7a40af30ca89150b3c336e67a44a43
f4b34b6c3942be273ad7298a40be0d312b183aab 24-Sep-2012 Elliott Hughes <enh@google.com> DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic."

This reverts commit 3a936a4980046a7eeb8d53a3296058d8f3a1f770.

We don't want this in jb-mr1.
3a936a4980046a7eeb8d53a3296058d8f3a1f770 11-Sep-2012 Elliott Hughes <enh@google.com> Add the libcutils localtime_tz and mktime_t extensions to bionic.

Bug: 7012465
Change-Id: Ib66f061e29199ba134545111dc79f9b50c8f4a21
6481b91520150e9664a3c4abc5d2aebdce422f93 06-Dec-2010 David 'Digit' Turner <digit@google.com> <time.h>: Add timegm(), timelocal() and others.

Add timegm(), timelocal(), time2posix() and posix2time() to the
C library.

Change-Id: I34d5771ed83dd994870a5ca58a511d01898b1ffb
50ace4fec5e8cb5afcbc656a4556fa528adfd760 17-Jun-2010 David 'Digit' Turner <digit@google.com> Remove compiler warnings when building Bionic.

Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
194d3fa048cf909ca592dd56fa538dc9cd3f5ddb 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
2093d350be21ff086f9e145404877941b9a42c5c 10-Sep-2009 David 'Digit' Turner <digit@google.com> Fix an infinite loop in time2sub.

The problem is that time_t is signed, and the original code relied on the
fact that (X + c < X) in case of overflow for c >= 0. Unfortunately, this
condition is only guaranteed by the standard for unsigned arithmetic, and
the gcc 4.4.0 optimizer did completely remove the corresponding test from
the code. This resulted in a missing boundary check, and an infinite loop.

The problem is solved by testing explicitely for TIME_T_MIN and TIME_T_MAX
in the loop that uses this.

Also fix increment_overflow and long_increment_overflow which were buggy
for exactly the same reasons.

Note: a similar fix is needed for system/core/libcutils
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