Backport documentation for time functions

Resolves: RHEL-57585
This commit is contained in:
Tulio Magno Quites Machado Filho 2025-02-14 13:38:26 -03:00
parent 8157a2f85a
commit cadb5c6bdc
6 changed files with 2294 additions and 1 deletions

41
glibc-RHEL-57585-1.patch Normal file
View File

@ -0,0 +1,41 @@
commit 400bdb5c85af5a52b3f5653357c9fca87f036bd3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue May 28 10:07:47 2024 -0700
Improve doc for time_t range (BZ 31808)
diff --git a/manual/time.texi b/manual/time.texi
index 404d124d1bfdca5c..ed13a1b4ddb64978 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -123,7 +123,7 @@ The number of clock ticks per second is system-specific.
@code{time_t} is the simplest data type used to represent simple
calendar time.
-In ISO C, @code{time_t} can be either an integer or a floating-point
+In ISO C, @code{time_t} can be either an integer or a real floating
type, and the meaning of @code{time_t} values is not specified. The
only things a strictly conforming program can do with @code{time_t}
values are: pass them to @code{difftime} to get the elapsed time
@@ -134,11 +134,21 @@ and pass them to the functions that convert them to broken-down time
On POSIX-conformant systems, @code{time_t} is an integer type and its
values represent the number of seconds elapsed since the @dfn{epoch},
which is 00:00:00 on January 1, 1970, Coordinated Universal Time.
+The count of seconds ignores leap seconds.
@Theglibc{} additionally guarantees that @code{time_t} is a signed
type, and that all of its functions operate correctly on negative
@code{time_t} values, which are interpreted as times before the epoch.
+Functions like @code{localtime} assume the Gregorian calendar even
+though this is historically inaccurate for timestamps before the
+calendar was introduced or after the calendar will become obsolete.
@cindex epoch
+@Theglibc{} also supports leap seconds as an option, in which case
+@code{time_t} counts leap seconds instead of ignoring them.
+Currently the @code{time_t} type is 64 bits wide on all platforms
+supported by @theglibc{}, except that it is 32 bits wide on a few
+older platforms unless you define @code{_TIME_BITS} to 64.
+@xref{Feature Test Macros}.
@end deftp
@deftp {Data Type} {struct timespec}

203
glibc-RHEL-57585-2.patch Normal file
View File

@ -0,0 +1,203 @@
commit 21fbc0a19366f89638a30eef2b53c6d4baafdb88
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Jun 22 13:44:50 2023 -0700
Call "CST" a time zone abbreviation, not a name
In documentation, call strings like "CST" time zone abbreviations, not
time zone names. This terminology is more precise, and is what tzdb uses.
A string like "CST" is ambiguous and does not fully name a time zone.
diff --git a/manual/conf.texi b/manual/conf.texi
index ba9847aaa4483585..158285dbf06c76ab 100644
--- a/manual/conf.texi
+++ b/manual/conf.texi
@@ -85,10 +85,10 @@ If defined, the unvarying maximum number of streams that a single
process can have open simultaneously. @xref{Opening Streams}.
@end deftypevr
-@cindex limits, time zone name length
+@cindex limits, time zone abbreviation length
@deftypevr Macro int TZNAME_MAX
@standards{POSIX.1, limits.h}
-If defined, the unvarying maximum length of a time zone name.
+If defined, the unvarying maximum length of a time zone abbreviation.
@xref{Time Zone Functions}.
@end deftypevr
@@ -1044,7 +1044,7 @@ simultaneously. Its value is @code{8}.
@item _POSIX_TZNAME_MAX
@standards{POSIX.1, limits.h}
The value of this macro is the most restrictive limit permitted by POSIX
-for the maximum length of a time zone name. Its value is @code{3}.
+for the maximum length of a time zone abbreviation. Its value is @code{3}.
@item _POSIX2_RE_DUP_MAX
@standards{POSIX.2, limits.h}
diff --git a/manual/time.texi b/manual/time.texi
index ed13a1b4ddb64978..ea088ce846b26e8d 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1037,7 +1037,7 @@ The @code{tm_gmtoff} field is derived from BSD and is a GNU library
extension; it is not visible in a strict @w{ISO C} environment.
@item const char *tm_zone
-This field is the name for the time zone that was used to compute this
+This field is the abbreviation for the time zone that was used to compute this
broken-down time value. Like @code{tm_gmtoff}, this field is a BSD and
GNU extension, and is not visible in a strict @w{ISO C} environment.
@end table
@@ -2217,7 +2217,7 @@ The full alternative year representation.
The offset from GMT in @w{ISO 8601}/RFC822 format.
@item %Z
-The timezone name.
+The time zone abbreviation.
@emph{Note:} Currently, this is not fully implemented. The format is
recognized, input is consumed but no field in @var{tm} is set.
@@ -2378,7 +2378,7 @@ current time of the timezone matched, not of the current timezone of the
runtime environment.
@emph{Note}: This is not implemented (currently). The problem is that
-timezone names are not unique. If a fixed timezone is assumed for a
+time zone abbreviations are not unique. If a fixed time zone is assumed for a
given string (say @code{EST} meaning US East Coast time), then uses for
countries other than the USA will fail. So far we have found no good
solution to this.
@@ -2534,10 +2534,10 @@ summer time) in the local time zone:
@r{@var{std} @var{offset}}
@end smallexample
-The @var{std} string specifies the name of the time zone. It must be
+The @var{std} string specifies the time zone abbreviation. It must be
three or more characters long and must not contain a leading colon,
embedded digits, commas, nor plus and minus signs. There is no space
-character separating the time zone name from the @var{offset}, so these
+character separating the time zone abbreviation from the @var{offset}, so these
restrictions are necessary to parse the specification correctly.
The @var{offset} specifies the time value you must add to the local time
@@ -2561,7 +2561,7 @@ The second format is used when there is Daylight Saving Time:
@end smallexample
The initial @var{std} and @var{offset} specify the standard time zone, as
-described above. The @var{dst} string and @var{offset} specify the name
+described above. The @var{dst} string and @var{offset} are the abbreviation
and offset for the corresponding Daylight Saving Time zone; if the
@var{offset} is omitted, it defaults to one hour ahead of standard time.
@@ -2690,10 +2690,10 @@ community of volunteers and put in the public domain.
@deftypevar {char *} tzname [2]
@standards{POSIX.1, time.h}
The array @code{tzname} contains two strings, which are the standard
-names of the pair of time zones (standard and Daylight
-Saving) that the user has selected. @code{tzname[0]} is the name of
+abbreviations of the pair of time zones (standard and Daylight
+Saving) that the user has selected. @code{tzname[0]} abbreviates
the standard time zone (for example, @code{"EST"}), and @code{tzname[1]}
-is the name for the time zone when Daylight Saving Time is in use (for
+abbreviates the time zone when Daylight Saving Time is in use (for
example, @code{"EDT"}). These correspond to the @var{std} and @var{dst}
strings (respectively) from the @code{TZ} environment variable. If
Daylight Saving Time is never used, @code{tzname[1]} is the empty string.
diff --git a/posix/bits/posix1_lim.h b/posix/bits/posix1_lim.h
index c645847858029165..54626e16c059e1f5 100644
--- a/posix/bits/posix1_lim.h
+++ b/posix/bits/posix1_lim.h
@@ -134,7 +134,7 @@
/* Maximum number of characters in a tty name. */
#define _POSIX_TTY_NAME_MAX 9
-/* Maximum length of a timezone name (element of `tzname'). */
+/* Maximum length of a time zone abbreviation (element of 'tzname'). */
#ifdef __USE_XOPEN2K
# define _POSIX_TZNAME_MAX 6
#else
diff --git a/time/mktime.c b/time/mktime.c
index 74d9bbaa5b375723..850b6cdc144bbeda 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -536,7 +536,7 @@ __time64_t
__mktime64 (struct tm *tp)
{
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
- time zone names contained in the external variable 'tzname' shall
+ time zone abbreviations contained in the external variable 'tzname' shall
be set as if the tzset() function had been called. */
__tzset ();
diff --git a/time/time.h b/time/time.h
index bde870c9342a01a3..a6f00196ab4d1649 100644
--- a/time/time.h
+++ b/time/time.h
@@ -214,7 +214,7 @@ extern char *__REDIRECT_NTH (ctime_r, (const time_t *__restrict __timer,
/* Defined in localtime.c. */
-extern char *__tzname[2]; /* Current timezone names. */
+extern char *__tzname[2]; /* Current time zone abbreviations. */
extern int __daylight; /* If daylight-saving time is ever in use. */
extern long int __timezone; /* Seconds west of UTC. */
diff --git a/time/tzfile.c b/time/tzfile.c
index 61cbaebd3e41f95e..07164448d9179b9c 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -407,7 +407,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
fclose (f);
- /* First "register" all timezone names. */
+ /* First "register" all time zone abbreviations. */
for (i = 0; i < num_types; ++i)
if (__tzstring (&zone_names[types[i].idx]) == NULL)
goto ret_free_transitions;
@@ -564,7 +564,7 @@ __tzfile_default (const char *std, const char *dst,
types[1].offset = dstoff;
types[1].isdst = 1;
- /* Reset the zone names to point to the user's names. */
+ /* Reset time zone abbreviations to point to the user's abbreviations. */
__tzname[0] = (char *) std;
__tzname[1] = (char *) dst;
diff --git a/time/tzset.c b/time/tzset.c
index 2fc51194b63bda8e..889b1a426ef25a8b 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -145,7 +145,7 @@ compute_offset (unsigned int ss, unsigned int mm, unsigned int hh)
return ss + mm * 60 + hh * 60 * 60;
}
-/* Parses the time zone name at *TZP, and writes a pointer to an
+/* Parses the time zone abbreviation at *TZP, and writes a pointer to an
interned string to tz_rules[WHICHRULE].name. On success, advances
*TZP, and returns true. Returns false otherwise. */
static bool
@@ -324,10 +324,10 @@ __tzset_parse_tz (const char *tz)
memset (tz_rules, '\0', sizeof tz_rules);
tz_rules[0].name = tz_rules[1].name = "";
- /* Get the standard timezone name. */
+ /* Get the standard time zone abbreviations. */
if (parse_tzname (&tz, 0) && parse_offset (&tz, 0))
{
- /* Get the DST timezone name (if any). */
+ /* Get the DST time zone abbreviation (if any). */
if (*tz != '\0')
{
if (parse_tzname (&tz, 1))
diff --git a/timezone/tst-bz28707.c b/timezone/tst-bz28707.c
index 0a9df1e9a094f1e9..ead469bb7b15d089 100644
--- a/timezone/tst-bz28707.c
+++ b/timezone/tst-bz28707.c
@@ -37,7 +37,7 @@ do_test (void)
tzset ();
return
- /* Sanity-check that we got the right timezone-name for DST. For
+ /* Sanity-check that we got the right abbreviation for DST. For
normal time, we're likely to get "-00" (the "unspecified" marker),
even though the POSIX timezone string says "-04". Let's not test
that. */

1897
glibc-RHEL-57585-3.patch Normal file

File diff suppressed because it is too large Load Diff

113
glibc-RHEL-57585-4.patch Normal file
View File

@ -0,0 +1,113 @@
commit 83a1cc3bc3d28c97d1af6c0957b11fe39fd786d8
Author: Carlos O'Donell <carlos@redhat.com>
Date: Wed Oct 9 18:32:26 2024 -0400
Part of this patch got merged with glibc-RHEL-65356-2.patch however,
the documentation part got removed at the time.
This patch adds the missing documentation that got removed from
glibc-RHEL-65356-2.patch.
--- 8< ---
manual: Fix and test @deftypef* function formatting
The manual contained several instances of incorrect formatting
that were correct texinfo but produced incorrectly rendered manuals
or incorrect behaviour from the tooling.
The most important was incorrect quoting of function returns
by failing to use {} to quote the return. The impact of this
mistake means that 'info libc func' does not jump to the function
in question but instead to the introductory page under the assumption
that func doesn't exist. The function returns are now correctly
quoted.
The second issue was the use of a category specifier with
@deftypefun which doesn't accept a category specifier. If a category
specifier is required then @deftypefn needs to be used. This is
corrected by changing the command to @deftypefn for such functions
that used {Deprecated function} as a category.
The last issue is a missing space between the function name and the
arguments which results in odd function names like "epoll_wait(int"
instead of "epoll_wait". This also impacts the use of 'info libc'
and is corrected.
We additionally remove ';' from the end of function arguments and
add an 'int' return type for dprintf.
Lastly we add a new test check-deftype.sh which verifies the expected
formatting of @deftypefun, @deftypefunx, @deftypefn, and
@deftypefnx. The new test is also run as the summary file is
generated to ensure we don't generate incorrect results.
The existing check-safety.sh is also run directly as a test to increase
coverage since the existing tests only ran on manual install.
The new tests now run as part of the standard "make check" that
pre-commit CI runs and developers should run.
No regressions on x86_64.
HTML and PDF rendering reviewed and looks correct for all changes.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
diff --git a/manual/time.texi b/manual/time.texi
index 39e1a7457e11e538..3e8a46a6bfe96e5d 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1829,7 +1829,7 @@ can be placed in the buffer @var{s} the return value is zero, with the
same problems indicated in the @code{strftime} documentation.
@end deftypefun
-@deftypefun {Deprecated function} {char *} asctime (const struct tm *@var{brokentime})
+@deftypefn {Deprecated function} {char *} asctime (const struct tm *@var{brokentime})
@standards{ISO, time.h}
@safety{@prelim{}@mtunsafe{@mtasurace{:asctime} @mtslocale{}}@asunsafe{}@acsafe{}}
@c asctime @mtasurace:asctime @mtslocale
@@ -1863,9 +1863,9 @@ string.)
@strong{Portability note:}
This obsolescent function is deprecated in C23.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} asctime_r (const struct tm *@var{brokentime}, char *@var{buffer})
+@deftypefn {Deprecated function} {char *} asctime_r (const struct tm *@var{brokentime}, char *@var{buffer})
@standards{???, time.h}
@safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
@c asctime_r @mtslocale
@@ -1884,9 +1884,9 @@ it returns @code{NULL}.
@strong{Portability Note:}
POSIX.1-2024 removed this obsolescent function.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} ctime (const time_t *@var{time})
+@deftypefn {Deprecated function} {char *} ctime (const time_t *@var{time})
@standards{ISO, time.h}
@safety{@prelim{}@mtunsafe{@mtasurace{:tmbuf} @mtasurace{:asctime} @mtsenv{} @mtslocale{}}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
@c ctime @mtasurace:tmbuf @mtasurace:asctime @mtsenv @mtslocale @ascuheap @asulock @aculock @acsmem @acsfd
@@ -1909,9 +1909,9 @@ Calling @code{ctime} also sets the time zone state as if
@strong{Portability note:}
This obsolescent function is deprecated in C23.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} ctime_r (const time_t *@var{time}, char *@var{buffer})
+@deftypefn {Deprecated function} {char *} ctime_r (const time_t *@var{time}, char *@var{buffer})
@standards{???, time.h}
@safety{@prelim{}@mtsafe{@mtsenv{} @mtslocale{}}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
@c ctime_r @mtsenv @mtslocale @ascuheap @asulock @aculock @acsmem @acsfd
@@ -1935,7 +1935,7 @@ it returns @code{NULL}.
@strong{Portability Note:}
POSIX.1-2024 removed this obsolescent function.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
@node Parsing Date and Time
@subsection Convert textual time and date information back

31
glibc-RHEL-57585-5.patch Normal file
View File

@ -0,0 +1,31 @@
commit 1b29cb7b781ecf3f6dc4647c32861119bacbd5ef
Author: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Tue Jan 28 15:31:01 2025 -0300
manual: Safety annotations for timespec_get and timespec_getres
Add preliminary annotations that are consistent with clock_gettime and
clock_getres.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/time.texi b/manual/time.texi
index 3e8a46a6bfe96e5d..c0e645b15ce44788 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -595,6 +595,7 @@ Systems may support more than just this @w{ISO C} clock.
@deftypefun int timespec_get (struct timespec *@var{ts}, int @var{base})
@standards{ISO, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Store into @code{*@var{ts}} the current time according to the @w{ISO
C} time @var{base}.
@@ -603,6 +604,7 @@ The return value is @var{base} on success and @code{0} on failure.
@deftypefun int timespec_getres (struct timespec *@var{res}, int @var{base})
@standards{ISO, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
If @var{ts} is non-null, store into @code{*@var{ts}} the resolution of
the time provided by @code{timespec_get} function for the @w{ISO C}
time @var{base}.

View File

@ -157,7 +157,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 168%{?dist}
Release: 169%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -1114,6 +1114,11 @@ Patch806: glibc-RHEL-24740-1.patch
Patch807: glibc-RHEL-24740-2.patch
Patch808: glibc-RHEL-24740-3.patch
Patch809: glibc-RHEL-71547.patch
Patch810: glibc-RHEL-57585-1.patch
Patch811: glibc-RHEL-57585-2.patch
Patch812: glibc-RHEL-57585-3.patch
Patch813: glibc-RHEL-57585-4.patch
Patch814: glibc-RHEL-57585-5.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -3107,6 +3112,9 @@ update_gconv_modules_cache ()
%endif
%changelog
* Fri Feb 14 2025 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 2.34-169
- Backport documentation for time functions (RHEL-57585)
* Thu Feb 13 2025 Florian Weimer <fweimer@redhat.com> - 2.34-168
- Fix transliteration regression in iconv tool (RHEL-71547)