Commit graph

10 commits

Author SHA1 Message Date
Almaz Mingaleev
d86a3ab241 Update tzcode from 2022a to 2023a.
57b8fc957a
changes the way overflows are tracked: now compiler builtins
are used instead of manual arithmetics. But as int_fast32_t on
64-bit Android takes 8 bytes, new logic behaves differently.
See time_test.cpp changes for more details.

Changes were applied using following commands:
  1) Checkout tzcode repo
  2) Prepare patches for all tzcode file using
    git diff 2022a 2023a -- <file-name> > <file-name-patch>
  3) Apply these patches to files in bionic using
    patch -p1 <file-name> <file-name-patch>

Bug: 279742606
Test: CtsBionicTestCases
Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: atest toybox-tests
Change-Id: I7772a90538b8185bdd2f4be6e9d1740c95509d6c
2023-04-28 16:52:53 +01:00
Almaz Mingaleev
5411aff6bb Bump tzcode from 2016g to 2022a*.
Upstream has renamed tzsetlcl to tzset_unlocked. As bionic's
implementation of tzset_unlock differs from upstream, these changes were
skipped.

Also, upstream has removed constants (SECSPERMIN, etc) from tzfile.h. As
they are used in strptime.c, I've decided to leave them in tzfile.h and
to not bring them into strptime.c.

HAVE_TZNAME and USG_COMPAT flags semantics were updated, thus setting
their values to 2 in Android.bp file. See
1a27ec76bc

* 4742526b7e
and 0e8f0b06ac
were picked up, which are not part of 2022a.

Changes were applied using following commands:
  1) Checkout tzcode repo
  2) Prepare patches for all tzcode file using
    git diff 2016g 2021e -- <file-name> > <file-name-patch>
  3) Apply these patches to files in bionic using
    patch -p1 <file-name> <file-name-patch>

Bug: 25413083
Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: CtsBionicTestCases

Change-Id: I9aba4cbeab30171a32f94d20c8e4057804a4c01f
2022-06-07 09:59:16 +01:00
Elliott Hughes
9fb22a3ec4 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
2015-10-09 15:15:39 -07:00
Calin Juravle
627d37cd1f Update tzcode to 2013i
Bug: 12246757
Change-Id: I3d5d2318155b1f54ef80afd58b1e5ca9a6d7018e
2014-02-28 14:38:14 +00:00
Elliott Hughes
e0d0b15de6 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
2013-09-27 00:04:30 -07:00
Elliott Hughes
ce4783ce76 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
2013-07-12 17:52:44 -07:00
The Android Open Source Project
edbe7fc97b auto import //branches/master/...@140412 2009-03-18 22:20:24 -07:00
The Android Open Source Project
1dc9e472e1 auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
The Android Open Source Project
1767f908af auto import from //depot/cupcake/@135843 2009-03-03 18:28:13 -08:00
The Android Open Source Project
a27d2baa0c Initial Contribution 2008-10-21 07:00:00 -07:00