[00/59] time: sync mktime from Gnulib

Message ID 20250105055750.1668721-1-eggert@cs.ucla.edu (mailing list archive)
Headers
Series time: sync mktime from Gnulib |

Message

Paul Eggert Jan. 5, 2025, 5:56 a.m. UTC
  This patch series syncs mktime from Gnulib.  Among the issues it fixes
is the problem reported by Florian a couple of days ago
in "mktime tm_isdst compatibility improvements"
<https://sourceware.org/pipermail/libc-alpha/2025-January/163342.html>.
This patch series fixes that problem differently from Florian's proposal,
without introducing a new glibc tunable.

Florian Weimer (1):
  time: test DST adjustment for DST-less zones

Paul Eggert (58):
  Split intprops.h into two
  Support stdckdint.h internally if older GCC
  Fix mishandling of default DST rule
  Don't worry about !TZDEFAULT
  Support static_assert in pre-C23 C
  Sync mktime.c from Gnulib 2024-10-04
  Document mktime out-of-range + tm_isdst
  Push tzset lock into callers of time functions
  Omit parse_offset unnecessary *tz == '\0'
  Don’t assume TZif bloat is likely
  tzset no longer calls ftello
  Check TZif files more carefully
  Remove alignment assumption from __tzfile_read
  Treat oddball UTC offset strings as zero
  Simplify __tz_compute
  Improve performance in 2 BC
  Don’t mishandle years < 1970 in compute_change
  Match RFC 9636 names
  Trivial tzset_internal speedup
  Fix obscure bug when stdoffset == dstoffset
  Document assumption that NO_DST == 0
  __use_tzfile is boolean
  Minor tzfile.c clarity improvements
  Stop using zic's -y option
  Fix mishandling of default DST rule
  Simplify treatment of missing and empty TZ
  TZ="" always means UTC sans leap seconds
  Prefer "UTC" for UTC
  Simplify setting tz_rules to UTC
  Update tzname etc. even if TZ is unchanged
  "POSIX TZ" -> "proleptic TZ"
  Reject invalid TZ strings in TZif files
  Reject TZif files containing '\0' in TZ string
  mktime should not consult 'daylight'
  Remove __use_tzfile
  Remove arbitrary limit on TZ, TZDIR lengths
  Tighten setuid TZif file name check
  Avoid a malloc in __tzfile_read
  Free earlier in __tzfile_read
  Improve __tzfile_read TZ="" comment
  Refactor enum tz_rule_type
  __offtime now returns struct tm *
  Fix overflow checking in offtime
  Handle TZif time type 0 correctly
  Remove invalid tzset tests from tst-bz29951.c
  tzset, not localtime, now parses TZif TZ spec
  Minor compute_change widening tweak
  Minor SECSPERDAY widening tweak
  Remove leap-second goto from __tzfile_compute
  Remove use_last label from __tzfile_compute
  Refactor ‘if’ in __tzfile_compute
  Refactor localtime ‘if’ in __tzfile_compute
  Refactor post-transition-table ‘if’
  Refactor __tzfile_compute to avoid two gotos
  Refactor __tzfile_compute index local
  mktime: prefer bool to int
  mktime: port __mktime64 locking to Gnulib
  mktime: improve tm_isdst heuristic

 CONTRIBUTED-BY                     |   9 +
 Makeconfig                         |  16 +-
 NEWS                               |  18 +
 SHARED-FILES                       |   6 +-
 include/intprops-internal.h        | 400 ++++++++++++
 include/intprops.h                 | 356 +----------
 include/stdckdint.h                |   6 +
 include/stdckdint.in.h             |  35 +
 include/sys/cdefs.h                |   8 +
 include/time.h                     |  37 +-
 manual/time.texi                   |  69 +-
 resolv/ns_date.c                   |   2 +-
 sysdeps/generic/netinet/in_systm.h |   2 +-
 sysdeps/nptl/pthread.h             |   2 +-
 time/Makefile                      |   1 +
 time/bits/types/struct_timeb.h     |   2 +-
 time/gmtime.c                      |   8 +-
 time/localtime.c                   |   8 +-
 time/mktime-internal.h             |  14 +-
 time/mktime.c                      | 172 ++---
 time/offtime.c                     |  70 +-
 time/strftime_l.c                  |   3 +-
 time/sys/time.h                    |   2 +-
 time/timegm.c                      |  10 +-
 time/tst-mktime-dst-adjust.c       | 156 +++++
 time/tst-mktime2.c                 |   4 +-
 time/tst-posixtz.c                 |  65 +-
 time/tst-tzname.c                  | 110 +++-
 time/tzfile.c                      | 983 +++++++++++++----------------
 time/tzset.c                       | 510 ++++++++-------
 time/tzset.h                       |  29 +
 timezone/Makefile                  |   5 +-
 timezone/private.h                 |   2 +-
 timezone/test-tz.c                 |   1 +
 timezone/testdata/IST              | Bin 0 -> 285 bytes
 timezone/tst-bz29951.c             |   8 -
 timezone/tst-timezone.c            |  64 +-
 timezone/version                   |   2 +-
 38 files changed, 1865 insertions(+), 1330 deletions(-)
 create mode 100644 include/intprops-internal.h
 create mode 100644 include/stdckdint.h
 create mode 100644 include/stdckdint.in.h
 create mode 100644 time/tst-mktime-dst-adjust.c
 create mode 100644 time/tzset.h
 create mode 100644 timezone/testdata/IST

--
2.45.2
  

Comments

Carlos O'Donell Jan. 6, 2025, 2:30 p.m. UTC | #1
On 1/5/25 12:56 AM, Paul Eggert wrote:
> This patch series syncs mktime from Gnulib.  Among the issues it fixes
> is the problem reported by Florian a couple of days ago
> in "mktime tm_isdst compatibility improvements"
> <https://sourceware.org/pipermail/libc-alpha/2025-January/163342.html>.
> This patch series fixes that problem differently from Florian's proposal,
> without introducing a new glibc tunable.

Please do not push this while we are preparing for glibc 2.41 to go out
on February 1st (I see you mention this in your other email, but I'll note
the version and date here).

Please note that pre-commit CI has failed for this series and the patches
introduce link namespace failures.

Link namespace failures can be seen here:
https://patchwork.sourceware.org/project/glibc/patch/20250105055750.1668721-60-eggert@cs.ucla.edu/
  
Joseph Myers Jan. 6, 2025, 9:34 p.m. UTC | #2
On Mon, 6 Jan 2025, Carlos O'Donell wrote:

> On 1/5/25 12:56 AM, Paul Eggert wrote:
> > This patch series syncs mktime from Gnulib.  Among the issues it fixes
> > is the problem reported by Florian a couple of days ago
> > in "mktime tm_isdst compatibility improvements"
> > <https://sourceware.org/pipermail/libc-alpha/2025-January/163342.html>.
> > This patch series fixes that problem differently from Florian's proposal,
> > without introducing a new glibc tunable.
> 
> Please do not push this while we are preparing for glibc 2.41 to go out
> on February 1st (I see you mention this in your other email, but I'll note
> the version and date here).
> 
> Please note that pre-commit CI has failed for this series and the patches
> introduce link namespace failures.
> 
> Link namespace failures can be seen here:
> https://patchwork.sourceware.org/project/glibc/patch/20250105055750.1668721-60-eggert@cs.ucla.edu/

Those look like conform (compile-time) namespace failures, not link 
namespace.  Concretely, in patch 5, the static_assert definition in the 
sys/cdefs.h wrapper needs to be under a !_ISOMAC conditional.
  
Paul Eggert Jan. 6, 2025, 9:43 p.m. UTC | #3
On 1/6/25 13:34, Joseph Myers wrote:
> in patch 5, the static_assert definition in the
> sys/cdefs.h wrapper needs to be under a !_ISOMAC conditional

Thanks for diagnosing that. I'll put that into v2 (no rush since the 
patchset won't be committed before the next release).

The static_assert stuff is because Gnulib arranges for C23-style 
single-argument static_assert to work regardless of what standard files 
are included, whereas glibc code doesn't assume C23 yet.