History log of /bionic/libc/tzcode/localtime.c
Revision Date Author Comments
0e8616a37ab3af8567c130de8e83b968ffca79a6 11-Apr-2017 Elliott Hughes <enh@google.com> Move localtime.c over to CachedProperty.

Since localtime.c is C, this entails pulling our code out into its own
C++ file, which we should probably have done years ago anyway.

Bug: N/A
Test: ran tests, and manually tested via Settings
Change-Id: Ifc787a553e8f739a87641a2d35321aca40a47286
14eb5abc20038acfbba1c199641c10dc84ee251e 01-Apr-2017 Elliott Hughes <enh@google.com> Only use environment variables on the host.

It's faster and safer to skip them on the device, where we know where
everything is anyway.

(cherrypick of cf6365690cc68bdd7e16648fb7881ba0b5cae93d.)

Bug: http://b/36807787
Test: ran tests
Change-Id: I0bb7879cc46f194152c67ddaf072cbebb424f789
cf6365690cc68bdd7e16648fb7881ba0b5cae93d 01-Apr-2017 Elliott Hughes <enh@google.com> Only use environment variables on the host.

It's faster and safer to skip them on the device, where we know where
everything is anyway.

Bug: http://b/36807787
Test: ran tests
Change-Id: I0bb7879cc46f194152c67ddaf072cbebb424f789
ea87716696bf635706b6f3fa56b8a145add83aff 11-Jan-2017 Elliott Hughes <enh@google.com> localtime_r(3) should act as if it calls tzset(3).

See code comment.

Bug: http://b/31339449
Test: ran tests & benchmarks
Change-Id: I6b6a63750ef41664dc4698207e6a53e77cc28cdf
4edd651ed32ba3f09ace7529b5fb85f46cae508f 04-Oct-2016 Elliott Hughes <enh@google.com> Add missing O_CLOEXEC and TEMP_FAILURE_RETRY to localtime.c.

Follow-on change from http://b/31848040.

Test: *time* tests.
Change-Id: I3f1c9ce19b90f6f8c1ac6e0753e3fed0ff63c0b4
fa8f1d0ab21ae18e34c4d2274872f0f2e19cb479 03-Oct-2016 Elliott Hughes <enh@google.com> Fix tzdata loading.

Android uses one large file of tzdata, so the "read up to the maximum
possible length of a valid tzfile" code in upstream localtime.c is
broken: there is always data after the current tzfile (even the
last tzfile is followed by the zone.tab data). This patch passes the
exact length through to the read(2) call so we don't over-read, rather
than have to rewrite upstream code that measures back from the "end" of
the tzfile.

The old code failed the existing time.strftime_null_tm_zone test after
updating to tzdata2016g.

(cherry picked from commit 81c46fc10fa60fd341f11024d8d3f26ff2c69082)

Bug: http://b/31848040
Test: time.strftime_null_tm_zone
Change-Id: Iee059b5a8c051bd4952cfd80f02b00d83e489d5e
81c46fc10fa60fd341f11024d8d3f26ff2c69082 03-Oct-2016 Elliott Hughes <enh@google.com> Fix tzdata loading.

Android uses one large file of tzdata, so the "read up to the maximum
possible length of a valid tzfile" code in upstream localtime.c is
broken: there is always data after the current tzfile (even the
last tzfile is followed by the zone.tab data). This patch passes the
exact length through to the read(2) call so we don't over-read, rather
than have to rewrite upstream code that measures back from the "end" of
the tzfile.

The old code failed the existing time.strftime_null_tm_zone test after
updating to tzdata2016g.

Bug: http://b/31848040
Test: time.strftime_null_tm_zone
Change-Id: Iee059b5a8c051bd4952cfd80f02b00d83e489d5e
a9209d7a0ee7ef40f9a14cab2b6756d7e6f8b919 17-Sep-2016 Elliott Hughes <enh@google.com> Fix some easy cases of __ANDROID__ versus __BIONIC__.

We need to make a clearer distinction for bionic on the host. This patch
doesn't fully address things like "should host bionic try to talk to netd?"
for now, but is a step in the right direction.

Bug: http://b/31559095
Test: bionic tests.
Change-Id: I49812f8b75d9d78c4fd8a8ddf5df1201d63771d6
f8ebaa498562cfb199a9b28da5eae2770f9b3163 13-Aug-2016 Elliott Hughes <enh@google.com> Fix mktime's errno behavior.

Don't touch errno on success, do set it to EOVERFLOW (the only allowed errno
value according to POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/mktime.html)
on failure.

Bug: http://b/30477946
Change-Id: Ia915c7b9c3bfcd2f9025530cf5b068fe4dd4fd9e
0a610d00fee344f804d3338c880d73d2de5db143 29-Jul-2016 Elliott Hughes <enh@google.com> Upgrade to tzcode-2016f.

No significant changes other than a default implementation of strftime_l.

Change-Id: I6edd2c03e5e7559f012c0c87d43f7109d641d3ca
3e3f4a51b8a846ce6ae010795892addf9e428137 21-Jul-2016 Elliott Hughes <enh@google.com> Treat "persist.sys.timezone" as being a Java-format timezone.

POSIX and Java disagree about the sign in a timezone string like "GMT+3".
This means that if you set "persist.sys.timezone" to such a string, native
code and Java code disagree about what time it is. Resolve this by
translating to POSIX form for native code.

Bug: http://b/25463955
Change-Id: I7c08c459dd8514348a12ce419edcbfbfe8f6d327
Test: manually tested with setprop and date.
76dfa6e351952e60893e236022df54a23a558b65 06-Jan-2016 Elliott Hughes <enh@google.com> Remove mktime_tz.

Bug: http://b/15765976
Change-Id: Ifc8cd19ae621e611d66173ae927ef9a0445965c1
d1c28a361b66f8a131fc277df455cb6835a5327e 13-Nov-2015 Elliott Hughes <enh@google.com> Improve libc time zone fallback behavior.

We should fall back to GMT if neither the environment variable nor the
system property is set. This is the case if you wipe a WiFi-only device,
because we currently only take the time zone from cell networks.

Bug: http://b/24773112
Change-Id: I90d236d4d492b6562d75021bd312030b91c1e298
384ffe34638c91158465e143ddd867479c89cd52 02-Nov-2015 Christopher Ferris <cferris@google.com> Fix comment to reflect the actual reality.

The original comment implied that Android 32 bit was the only one
using a bad time_t, but it turns out 32 bit glibc has the same time_t
as Android. Update the comment to reflect this reality.

Change-Id: I72cdd2c677a6521f7b43d4695a52fd8fdc3305bd
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
d0578949ace9444e07e254f5baa592283baba304 02-Oct-2015 Mark Salyzyn <salyzyn@google.com> bionic: tzset running hot

logd makes a non-insignificant number of calls to localtime, 3% of
the time in logd is spent performing __system_property_get within the
context of tzset_locked().

Bug: 23685592
Change-Id: I75f8c2d436b60374e92c166b87393abda9487af7
1f95ffecc22995abe6ac8cdd6dbb74f6f9a42b2f 02-Mar-2015 Neil Fuller <nfuller@google.com> Changes to re-enable overrides for tz data

Bug: 10637303
Change-Id: I5d525b66cf30d34b421803b876445596bed8d64d
154e2026c83575eb17101df3a8d1192e305588d4 27-May-2014 Satoru Takeuchi <satoru.x.takeuchi@sonymobile.com> libc: Fix mktime returns an uncorrect time in empty TZ case

The mktime API returned an uncorrect time when TZ is set as empty.
A timezone UTC/GMT+0 should be implied in the empty case. However
mktime keeps previous information about timezone. If mktime was called
with a timezone which has DST before, the "defaulttype" member of
"state" structure wouldn't be 0. Then it would be used next time,
even though UTC/GMT+0 doesn't have DST.

Added initialization of the "defaulttype" in the empty TZ case.

Change-Id: Ic480c63c548c05444134e0aefb30a7b380e3f40b
e24bf5d7b972597ba5b7b38ca777d8eae98332dd 27-Oct-2014 Elliott Hughes <enh@google.com> Disable tzdata in $ANDROID_DATA.

(cherry picked from 4c30130a2155c37e80af4c3b53bf4f6ce832e760.)

Bug: 18139284
Change-Id: I2670dc1791d635139a5d39a438dc08777439476b
4c30130a2155c37e80af4c3b53bf4f6ce832e760 27-Oct-2014 Elliott Hughes <enh@google.com> Disable tzdata in $ANDROID_DATA.

Bug: 18139284
Change-Id: I2670dc1791d635139a5d39a438dc08777439476b
13bab43337242094663d6f699ad996ddc99ec582 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.

(cherry-pick of 90cb5ffb85a9bc2e725824b3ca8db932d02c45db.)

Bug: 16168653
Change-Id: Iedad2252c2b49f4d8bb2c7d9078b39b622444ca7
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
905e6d58aaf515bf237e62078f8a321920fe4c6b 25-Jul-2014 Elliott Hughes <enh@google.com> Start hiding "private/bionic_time.h".

Bug: 15765976
Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
39d903aea901cd29a4eef3a82c2dbda59b5bc292 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
Change-Id: Ic9ef36e8acd3619504ecc4d73feec2b61fd4dfa1
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