From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/time.in.h | 116 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 26 deletions(-) (limited to 'gl/time.in.h') diff --git a/gl/time.in.h b/gl/time.in.h index df99c8ab..3ff16e3b 100644 --- a/gl/time.in.h +++ b/gl/time.in.h @@ -1,6 +1,6 @@ /* A more-standard . - Copyright (C) 2007-2024 Free Software Foundation, Inc. + Copyright (C) 2007-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -122,6 +122,23 @@ struct __time_t_must_be_integral { # endif # endif +# if @GNULIB_TZNAME@ +/* tzname[0..1]: Abbreviated time zone names, set by the tzset() function. */ +# if NEED_DECL_TZNAME +extern +# ifdef __cplusplus + "C" +# endif + char *tzname[]; +# endif +# if defined _WIN32 && !defined __CYGWIN__ +/* On native Windows, map 'tzname' to '_tzname' etc., so that -loldnames is not + required. */ +# undef tzname +# define tzname _tzname +# endif +# endif + /* Set *TS to the current time, and return BASE. Upon failure, return 0. */ # if @GNULIB_TIMESPEC_GET@ @@ -130,12 +147,12 @@ struct __time_t_must_be_integral { # undef timespec_get # define timespec_get rpl_timespec_get # endif -_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base) +_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base)); # else # if !@HAVE_TIMESPEC_GET@ -_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) +_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); @@ -159,17 +176,19 @@ _GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - " # undef timespec_getres # define timespec_getres rpl_timespec_getres # endif -_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base) +_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base)); # else # if !@HAVE_TIMESPEC_GETRES@ -_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) +_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (timespec_getres); +# endif # elif defined GNULIB_POSIXCHECK # undef timespec_getres # if HAVE_RAW_DECL_TIMESPEC_GETRES @@ -184,7 +203,7 @@ _GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define time rpl_time # endif -_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp)); +_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp), ); _GL_CXXALIAS_RPL (time, time_t, (time_t *__tp)); # else _GL_CXXALIAS_SYS (time, time_t, (time_t *__tp)); @@ -209,14 +228,14 @@ _GL_WARN_ON_USE (time, "time has consistency problems - " # define nanosleep rpl_nanosleep # endif _GL_FUNCDECL_RPL (nanosleep, int, - (struct timespec const *__rqtp, struct timespec *__rmtp) + (struct timespec const *__rqtp, struct timespec *__rmtp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # else # if ! @HAVE_NANOSLEEP@ _GL_FUNCDECL_SYS (nanosleep, int, - (struct timespec const *__rqtp, struct timespec *__rmtp) + (struct timespec const *__rqtp, struct timespec *__rmtp), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (nanosleep, int, @@ -238,7 +257,7 @@ _GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - " # undef tzset # define tzset rpl_tzset # endif -_GL_FUNCDECL_RPL (tzset, void, (void)); +_GL_FUNCDECL_RPL (tzset, void, (void), ); _GL_CXXALIAS_RPL (tzset, void, (void)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -278,7 +297,7 @@ _GL_WARN_ON_USE (tzset, "tzset has portability problems - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mktime rpl_mktime # endif -_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); # else _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); @@ -304,14 +323,14 @@ _GL_WARN_ON_USE (mktime, "mktime has portability problems - " # define localtime_r rpl_localtime_r # endif _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, @@ -326,14 +345,14 @@ _GL_CXXALIASWARN (localtime_r); # define gmtime_r rpl_gmtime_r # endif _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, - struct tm *restrict __result) + struct tm *restrict __result), _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, @@ -364,7 +383,7 @@ _GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - " # undef localtime # define localtime rpl_localtime # endif -_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) +_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); # else @@ -387,7 +406,7 @@ _GL_WARN_ON_USE (localtime, "localtime has portability problems - " # undef gmtime # define gmtime rpl_gmtime # endif -_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) +_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); # else @@ -403,7 +422,7 @@ _GL_CXXALIASWARN (gmtime); # if ! @HAVE_STRPTIME@ _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, - struct tm *restrict __tm) + struct tm *restrict __tm), _GL_ARG_NONNULL ((1, 2, 3))); # endif _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, @@ -428,7 +447,7 @@ _GL_WARN_ON_USE (strptime, "strptime is unportable - " # ifndef __cplusplus _GL_ATTRIBUTE_DEPRECATED # endif -_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) +_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); # else @@ -450,7 +469,7 @@ _GL_CXXALIASWARN (ctime); # endif _GL_FUNCDECL_RPL (strftime, size_t, (char *restrict __buf, size_t __bufsize, - const char *restrict __fmt, const struct tm *restrict __tp) + const char *restrict __fmt, const struct tm *restrict __tp), _GL_ARG_NONNULL ((1, 3, 4))); _GL_CXXALIAS_RPL (strftime, size_t, (char *restrict __buf, size_t __bufsize, @@ -471,14 +490,24 @@ _GL_WARN_ON_USE (strftime, "strftime has portability problems - " # endif # endif -# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ +# if @GNULIB_TIME_RZ@ /* Functions that use a first-class time zone data type, instead of relying on an implicit global time zone. Inspired by NetBSD. */ /* Represents a time zone. (timezone_t) NULL stands for UTC. */ +# if !@HAVE_TZALLOC@ +# if !GNULIB_defined_timezone_t +# if !@HAVE_TIMEZONE_T@ typedef struct tm_zone *timezone_t; +# else +typedef struct tm_zone *rpl_timezone_t; +# define timezone_t rpl_timezone_t +# endif +# define GNULIB_defined_timezone_t 1 +# endif +# endif /* tzalloc (name) Returns a time zone object for the given time zone NAME. This object @@ -488,37 +517,72 @@ typedef struct tm_zone *timezone_t; would use it the TZ environment variable was unset. May return NULL if NAME is invalid (this is platform dependent) or upon memory allocation failure. */ -_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); +# if !@HAVE_TZALLOC@ +_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name), ); _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); +# endif /* tzfree (tz) Frees a time zone object. The argument must have been returned by tzalloc(). */ -_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); +# if !@HAVE_TZALLOC@ +_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz), ); _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); +# endif /* localtime_rz (tz, &t, &result) Converts an absolute time T to a broken-down time RESULT, assuming the time zone TZ. This function is like 'localtime_r', but relies on the argument TZ instead of an implicit global time zone. */ +# if @REPLACE_LOCALTIME_RZ@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef localtime_rz +# define localtime_rz rpl_localtime_rz +# endif +_GL_FUNCDECL_RPL (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result), + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result)); +# else +# if !@HAVE_TZALLOC@ _GL_FUNCDECL_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, - struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); + struct tm *restrict __result), + _GL_ARG_NONNULL ((2, 3))); +# endif _GL_CXXALIAS_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, struct tm *restrict __result)); +# endif /* mktime_z (tz, &tm) Normalizes the broken-down time TM and converts it to an absolute time, assuming the time zone TZ. Returns the absolute time. This function is like 'mktime', but relies on the argument TZ instead of an implicit global time zone. */ +# if @REPLACE_MKTIME_Z@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mktime_z +# define mktime_z rpl_mktime_z +# endif +_GL_FUNCDECL_RPL (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm), + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm)); +# else +# if !@HAVE_TZALLOC@ _GL_FUNCDECL_SYS (mktime_z, time_t, - (timezone_t __tz, struct tm *restrict __tm) + (timezone_t __tz, struct tm *restrict __tm), _GL_ARG_NONNULL ((2))); +# endif _GL_CXXALIAS_SYS (mktime_z, time_t, (timezone_t __tz, struct tm *restrict __tm)); +# endif /* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' in the 'tm_zone' member of 'struct tm') are valid as long as @@ -535,11 +599,11 @@ _GL_CXXALIAS_SYS (mktime_z, time_t, # undef timegm # define timegm rpl_timegm # endif -_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); # else # if ! @HAVE_TIMEGM@ -_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif -- cgit v1.2.3-74-g34f1