diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2024-04-06 23:39:53 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2024-04-07 13:35:48 -0700 |
| commit | 1f94147a79fcb7211f1421b87383cad93986797f (patch) | |
| tree | e75fd16819071d7cf0b84adafa81e56fb91d0f99 /timezone | |
| parent | 57581acd9559217e859fdac693145ce6399f4d70 (diff) | |
| download | glibc-1f94147a79fcb7211f1421b87383cad93986797f.tar.xz glibc-1f94147a79fcb7211f1421b87383cad93986797f.zip | |
timezone: sync to TZDB 2024a
Sync tzselect, zdump, zic to TZDB 2024a.
This patch incorporates the following TZDB source code changes,
listed roughly in descending order of importance.
zic now supports links to links, needed for future tzdata
zic now defaults to '-b slim'
zic now updates output files atomically
zic has new options -R, -l -, -p -
zic -r now uses -00 for unspecified timestamps
zdump now uses [lo,hi) for both -c and -t
Fix several integer overflow bugs
zic now checks input bytes more carefully
Simplify and fix new TZDIR setup
Default time_t to 64 bits on glibc 2.34+ 32-bit
zic now generates TZ strings that conform to POSIX when all-year DST
zic -v now shows extreme-int tm_year transitions
Fix zic bug in last time type of Asia/Gaza etc.
Fix zic bug with Palestine after 2075
Fix bug uncovered by recent change to Iran history
Fix 'zic -b fat' bug with Port Moresby 32-bit data
Fix zic bug with -r @X where X is deduced from TZ
Fix bug with zic -r cutoff before 1st transition
Fix leap second expiry and truncation
Fix zic bug on Linux 2.6.16 and 2.6.17
Fix bug with 'zic -d /a/b/c' if /a is unwriteable
Don't mistruncate TZif files at leap seconds
Fix zdump undefined behavior if !USE_LTZ
zdump -v reports localtime+gmtime failures better
Fix zdump diagnostic for missing timezone
Don't assume nonempty argv
Port better to C23
Do not assume negative >> behavior
I18nize zdump a bit better
Port zdump to right_only installations
New tzselect menu option 'now'
tzselect can now use current time to help choose
Improve tzselect behavior for Turkey etc.
tzselect: do not create temporary files
tzselect: work around mawk bug with {2,}
tzselect: Port to POSIX awk, which prohibits -v newlines
Do not use empty RE in tzselect
Don't set TZ in tzselect
Avoid sed, expr in tzselect
tzselect: Fix problems with spaces in TZDIR
Improve tzselect diagnostics
Remove zic workaround for Qt bug 53071
Remove zic support for "min" in Rule lines
Remove zic support for zic -y, Rule TYPEs, pacificnew
Remove tzselect workaround for Bash 1.14.7 bug
* SHARED-FILES: Update to match current sync.
* config.h.in (HAVE_STRERROR): Remove; no longer needed.
* timezone/Makefile ($(objpfx)zic.o): Depend on tzdir.h.
($(objpfx)tzdir.h): New rule to build a placeholder.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Copy verbatim from TZDB 2024a.
Diffstat (limited to 'timezone')
| -rw-r--r-- | timezone/Makefile | 7 | ||||
| -rw-r--r-- | timezone/private.h | 597 | ||||
| -rw-r--r-- | timezone/tzfile.h | 32 | ||||
| -rwxr-xr-x | timezone/tzselect.ksh | 923 | ||||
| -rw-r--r-- | timezone/version | 2 | ||||
| -rw-r--r-- | timezone/zdump.c | 453 | ||||
| -rw-r--r-- | timezone/zic.c | 2210 |
7 files changed, 2679 insertions, 1545 deletions
diff --git a/timezone/Makefile b/timezone/Makefile index d7acb387ba..cf4ef3bf7e 100644 --- a/timezone/Makefile +++ b/timezone/Makefile @@ -49,6 +49,13 @@ endif include ../Rules +$(objpfx)zic.o: $(objpfx)tzdir.h + +# In glibc this file is an empty placeholder, +# as tz-cflags defines TZDEFAULT and TZDIR. +$(objpfx)tzdir.h: + > $@ + $(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h $(objpfx)version.h: $(common-objpfx)config.make diff --git a/timezone/private.h b/timezone/private.h index 8513663036..0dac6af4e3 100644 --- a/timezone/private.h +++ b/timezone/private.h @@ -17,6 +17,40 @@ ** Thank you! */ +/* PORT_TO_C89 means the code should work even if the underlying + compiler and library support only C89 plus C99's 'long long' + and perhaps a few other extensions to C89. SUPPORT_C89 means the + tzcode library should support C89 callers in addition to the usual + support for C99-and-later callers; however, C89 support can trigger + latent bugs in C99-and-later callers. These macros are obsolescent, + and the plan is to remove them along with any code needed only when + they are nonzero. A good time to do that might be in the year 2029 + because RHEL 7 (whose GCC defaults to C89) extended life cycle + support (ELS) is scheduled to end on 2028-06-30. */ +#ifndef PORT_TO_C89 +# define PORT_TO_C89 0 +#endif +#ifndef SUPPORT_C89 +# define SUPPORT_C89 0 +#endif + +#ifndef __STDC_VERSION__ +# define __STDC_VERSION__ 0 +#endif + +/* Define true, false and bool if they don't work out of the box. */ +#if PORT_TO_C89 && __STDC_VERSION__ < 199901 +# define true 1 +# define false 0 +# define bool int +#elif __STDC_VERSION__ < 202311 +# include <stdbool.h> +#endif + +#if __STDC_VERSION__ < 202311 +# define static_assert(cond) extern int static_assert_check[(cond) ? 1 : -1] +#endif + /* ** zdump has been made independent of the rest of the time ** conversion package to increase confidence in the verification it provides. @@ -36,79 +70,84 @@ */ #ifndef HAVE_DECL_ASCTIME_R -#define HAVE_DECL_ASCTIME_R 1 +# define HAVE_DECL_ASCTIME_R 1 #endif -#if !defined HAVE_GENERIC && defined __has_extension -# if __has_extension(c_generic_selections) -# define HAVE_GENERIC 1 -# else -# define HAVE_GENERIC 0 +#if !defined HAVE__GENERIC && defined __has_extension +# if !__has_extension(c_generic_selections) +# define HAVE__GENERIC 0 # endif #endif /* _Generic is buggy in pre-4.9 GCC. */ -#if !defined HAVE_GENERIC && defined __GNUC__ -# define HAVE_GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__)) +#if !defined HAVE__GENERIC && defined __GNUC__ && !defined __STRICT_ANSI__ +# define HAVE__GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__)) #endif -#ifndef HAVE_GENERIC -# define HAVE_GENERIC (201112 <= __STDC_VERSION__) +#ifndef HAVE__GENERIC +# define HAVE__GENERIC (201112 <= __STDC_VERSION__) #endif +#if !defined HAVE_GETTEXT && defined __has_include +# if __has_include(<libintl.h>) +# define HAVE_GETTEXT true +# endif +#endif #ifndef HAVE_GETTEXT -#define HAVE_GETTEXT 0 -#endif /* !defined HAVE_GETTEXT */ +# define HAVE_GETTEXT false +#endif #ifndef HAVE_INCOMPATIBLE_CTIME_R -#define HAVE_INCOMPATIBLE_CTIME_R 0 +# define HAVE_INCOMPATIBLE_CTIME_R 0 #endif #ifndef HAVE_LINK -#define HAVE_LINK 1 +# define HAVE_LINK 1 #endif /* !defined HAVE_LINK */ -#ifndef HAVE_POSIX_DECLS -#define HAVE_POSIX_DECLS 1 +#ifndef HAVE_MALLOC_ERRNO +# define HAVE_MALLOC_ERRNO 1 #endif -#ifndef HAVE_STDBOOL_H -#define HAVE_STDBOOL_H (199901 <= __STDC_VERSION__) +#ifndef HAVE_POSIX_DECLS +# define HAVE_POSIX_DECLS 1 #endif -#ifndef HAVE_STRDUP -#define HAVE_STRDUP 1 +#ifndef HAVE_SETENV +# define HAVE_SETENV 1 #endif -#ifndef HAVE_STRTOLL -#define HAVE_STRTOLL 1 +#ifndef HAVE_STRDUP +# define HAVE_STRDUP 1 #endif #ifndef HAVE_SYMLINK -#define HAVE_SYMLINK 1 +# define HAVE_SYMLINK 1 #endif /* !defined HAVE_SYMLINK */ +#if !defined HAVE_SYS_STAT_H && defined __has_include +# if !__has_include(<sys/stat.h>) +# define HAVE_SYS_STAT_H false +# endif +#endif #ifndef HAVE_SYS_STAT_H -#define HAVE_SYS_STAT_H 1 -#endif /* !defined HAVE_SYS_STAT_H */ - -#ifndef HAVE_SYS_WAIT_H -#define HAVE_SYS_WAIT_H 1 -#endif /* !defined HAVE_SYS_WAIT_H */ +# define HAVE_SYS_STAT_H true +#endif +#if !defined HAVE_UNISTD_H && defined __has_include +# if !__has_include(<unistd.h>) +# define HAVE_UNISTD_H false +# endif +#endif #ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif /* !defined HAVE_UNISTD_H */ - -#ifndef HAVE_UTMPX_H -#define HAVE_UTMPX_H 1 -#endif /* !defined HAVE_UTMPX_H */ +# define HAVE_UNISTD_H true +#endif #ifndef NETBSD_INSPIRED # define NETBSD_INSPIRED 1 #endif #if HAVE_INCOMPATIBLE_CTIME_R -#define asctime_r _incompatible_asctime_r -#define ctime_r _incompatible_ctime_r +# define asctime_r _incompatible_asctime_r +# define ctime_r _incompatible_ctime_r #endif /* HAVE_INCOMPATIBLE_CTIME_R */ /* Enable tm_gmtoff, tm_zone, and environ on GNUish systems. */ @@ -118,15 +157,17 @@ /* Enable strtoimax on pre-C99 Solaris 11. */ #define __EXTENSIONS__ 1 -/* To avoid having 'stat' fail unnecessarily with errno == EOVERFLOW, - enable large files on GNUish systems ... */ +/* On GNUish systems where time_t might be 32 or 64 bits, use 64. + On these platforms _FILE_OFFSET_BITS must also be 64; otherwise + setting _TIME_BITS to 64 does not work. The code does not + otherwise rely on _FILE_OFFSET_BITS being 64, since it does not + use off_t or functions like 'stat' that depend on off_t. */ #ifndef _FILE_OFFSET_BITS # define _FILE_OFFSET_BITS 64 #endif -/* ... and on AIX ... */ -#define _LARGE_FILES 1 -/* ... and enable large inode numbers on Mac OS X 10.5 and later. */ -#define _DARWIN_USE_64_BIT_INODE 1 +#if !defined _TIME_BITS && _FILE_OFFSET_BITS == 64 +# define _TIME_BITS 64 +#endif /* ** Nested includes @@ -157,16 +198,29 @@ #undef tzalloc #undef tzfree -#include <sys/types.h> /* for time_t */ +#include <stddef.h> #include <string.h> +#if !PORT_TO_C89 +# include <inttypes.h> +#endif #include <limits.h> /* for CHAR_BIT et al. */ #include <stdlib.h> #include <errno.h> +#ifndef EINVAL +# define EINVAL ERANGE +#endif + +#ifndef ELOOP +# define ELOOP EINVAL +#endif #ifndef ENAMETOOLONG # define ENAMETOOLONG EINVAL #endif +#ifndef ENOMEM +# define ENOMEM EINVAL +#endif #ifndef ENOTSUP # define ENOTSUP EINVAL #endif @@ -175,11 +229,11 @@ #endif #if HAVE_GETTEXT -#include <libintl.h> +# include <libintl.h> #endif /* HAVE_GETTEXT */ #if HAVE_UNISTD_H -#include <unistd.h> /* for R_OK, and other POSIX goodness */ +# include <unistd.h> /* for R_OK, and other POSIX goodness */ #endif /* HAVE_UNISTD_H */ #ifndef HAVE_STRFTIME_L @@ -215,27 +269,29 @@ #endif #ifndef R_OK -#define R_OK 4 +# define R_OK 4 #endif /* !defined R_OK */ -/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ -#define is_digit(c) ((unsigned)(c) - '0' <= 9) +#if PORT_TO_C89 /* ** Define HAVE_STDINT_H's default value here, rather than at the ** start, since __GLIBC__ and INTMAX_MAX's values depend on -** previously-included files. glibc 2.1 and Solaris 10 and later have +** previously included files. glibc 2.1 and Solaris 10 and later have ** stdint.h, even with pre-C99 compilers. */ +#if !defined HAVE_STDINT_H && defined __has_include +# define HAVE_STDINT_H true /* C23 __has_include implies C99 stdint.h. */ +#endif #ifndef HAVE_STDINT_H -#define HAVE_STDINT_H \ +# define HAVE_STDINT_H \ (199901 <= __STDC_VERSION__ \ - || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \ + || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \ || __CYGWIN__ || INTMAX_MAX) #endif /* !defined HAVE_STDINT_H */ #if HAVE_STDINT_H -#include <stdint.h> +# include <stdint.h> #endif /* !HAVE_STDINT_H */ #ifndef HAVE_INTTYPES_H @@ -246,36 +302,36 @@ #endif /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ -#ifdef __LONG_LONG_MAX__ +#if defined __LONG_LONG_MAX__ && !defined __STRICT_ANSI__ # ifndef LLONG_MAX # define LLONG_MAX __LONG_LONG_MAX__ # endif # ifndef LLONG_MIN # define LLONG_MIN (-1 - LLONG_MAX) # endif +# ifndef ULLONG_MAX +# define ULLONG_MAX (LLONG_MAX * 2ull + 1) +# endif #endif #ifndef INT_FAST64_MAX -# ifdef LLONG_MAX -typedef long long int_fast64_t; -# define INT_FAST64_MIN LLONG_MIN -# define INT_FAST64_MAX LLONG_MAX -# else -# if LONG_MAX >> 31 < 0xffffffff -Please use a compiler that supports a 64-bit integer type (or wider); -you may need to compile with "-DHAVE_STDINT_H". -# endif -typedef long int_fast64_t; +# if 1 <= LONG_MAX >> 31 >> 31 +typedef long int_fast64_t; # define INT_FAST64_MIN LONG_MIN # define INT_FAST64_MAX LONG_MAX +# else +/* If this fails, compile with -DHAVE_STDINT_H or with a better compiler. */ +typedef long long int_fast64_t; +# define INT_FAST64_MIN LLONG_MIN +# define INT_FAST64_MAX LLONG_MAX # endif #endif #ifndef PRIdFAST64 -# if INT_FAST64_MAX == LLONG_MAX -# define PRIdFAST64 "lld" -# else +# if INT_FAST64_MAX == LONG_MAX # define PRIdFAST64 "ld" +# else +# define PRIdFAST64 "lld" # endif #endif @@ -298,6 +354,9 @@ typedef int int_fast32_t; #ifndef INTMAX_MAX # ifdef LLONG_MAX typedef long long intmax_t; +# ifndef HAVE_STRTOLL +# define HAVE_STRTOLL true +# endif # if HAVE_STRTOLL # define strtoimax strtoll # endif @@ -321,66 +380,183 @@ typedef long intmax_t; # endif #endif +#ifndef PTRDIFF_MAX +# define PTRDIFF_MAX MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t)) +#endif + +#ifndef UINT_FAST32_MAX +typedef unsigned long uint_fast32_t; +#endif + #ifndef UINT_FAST64_MAX -# if defined ULLONG_MAX || defined __LONG_LONG_MAX__ -typedef unsigned long long uint_fast64_t; +# if 3 <= ULONG_MAX >> 31 >> 31 +typedef unsigned long uint_fast64_t; +# define UINT_FAST64_MAX ULONG_MAX # else -# if ULONG_MAX >> 31 >> 1 < 0xffffffff -Please use a compiler that supports a 64-bit integer type (or wider); -you may need to compile with "-DHAVE_STDINT_H". -# endif -typedef unsigned long uint_fast64_t; +/* If this fails, compile with -DHAVE_STDINT_H or with a better compiler. */ +typedef unsigned long long uint_fast64_t; +# define UINT_FAST64_MAX ULLONG_MAX # endif #endif #ifndef UINTMAX_MAX -# if defined ULLONG_MAX || defined __LONG_LONG_MAX__ +# ifdef ULLONG_MAX typedef unsigned long long uintmax_t; +# define UINTMAX_MAX ULLONG_MAX # else typedef unsigned long uintmax_t; +# define UINTMAX_MAX ULONG_MAX # endif #endif #ifndef PRIuMAX -# if defined ULLONG_MAX || defined __LONG_LONG_MAX__ +# ifdef ULLONG_MAX # define PRIuMAX "llu" # else # define PRIuMAX "lu" # endif #endif -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif /* !defined INT32_MAX */ -#ifndef INT32_MIN -#define INT32_MIN (-1 - INT32_MAX) -#endif /* !defined INT32_MIN */ - #ifndef SIZE_MAX -#define SIZE_MAX ((size_t) -1) +# define SIZE_MAX ((size_t) -1) +#endif + +#endif /* PORT_TO_C89 */ + +/* The maximum size of any created object, as a signed integer. + Although the C standard does not outright prohibit larger objects, + behavior is undefined if the result of pointer subtraction does not + fit into ptrdiff_t, and the code assumes in several places that + pointer subtraction works. As a practical matter it's OK to not + support objects larger than this. */ +#define INDEX_MAX ((ptrdiff_t) min(PTRDIFF_MAX, SIZE_MAX)) + +/* Support ckd_add, ckd_sub, ckd_mul on C23 or recent-enough GCC-like + hosts, unless compiled with -DHAVE_STDCKDINT_H=0 or with pre-C23 EDG. */ +#if !defined HAVE_STDCKDINT_H && defined __has_include +# if __has_include(<stdckdint.h>) +# define HAVE_STDCKDINT_H true +# endif +#endif +#ifdef HAVE_STDCKDINT_H +# if HAVE_STDCKDINT_H +# include <stdckdint.h> +# endif +#elif defined __EDG__ +/* Do nothing, to work around EDG bug <https://bugs.gnu.org/53256>. */ +#elif defined __has_builtin +# if __has_builtin(__builtin_add_overflow) +# define ckd_add(r, a, b) __builtin_add_overflow(a, b, r) +# endif +# if __has_builtin(__builtin_sub_overflow) +# define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r) +# endif +# if __has_builtin(__builtin_mul_overflow) +# define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r) +# endif +#elif 7 <= __GNUC__ +# define ckd_add(r, a, b) __builtin_add_overflow(a, b, r) +# define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r) +# define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r) #endif #if 3 <= __GNUC__ -# define ATTRIBUTE_CONST __attribute__ ((const)) -# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -# define ATTRIBUTE_PURE __attribute__ ((__pure__)) -# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +# define ATTRIBUTE_MALLOC __attribute__((malloc)) +# define ATTRIBUTE_FORMAT(spec) __attribute__((format spec)) #else -# define ATTRIBUTE_CONST /* empty */ # define ATTRIBUTE_MALLOC /* empty */ -# define ATTRIBUTE_PURE /* empty */ # define ATTRIBUTE_FORMAT(spec) /* empty */ #endif -#if !defined _Noreturn && __STDC_VERSION__ < 201112 -# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) -# define _Noreturn __attribute__ ((__noreturn__)) +#if (defined __has_c_attribute \ + && (202311 <= __STDC_VERSION__ || !defined __STRICT_ANSI__)) +# define HAVE___HAS_C_ATTRIBUTE true +#else +# define HAVE___HAS_C_ATTRIBUTE false +#endif + +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(deprecated) +# define ATTRIBUTE_DEPRECATED [[deprecated]] +# endif +#endif +#ifndef ATTRIBUTE_DEPRECATED +# if 3 < __GNUC__ + (2 <= __GNUC_MINOR__) +# define ATTRIBUTE_DEPRECATED __attribute__((deprecated)) +# else +# define ATTRIBUTE_DEPRECATED /* empty */ +# endif +#endif + +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(fallthrough) +# define ATTRIBUTE_FALLTHROUGH [[fallthrough]] +# endif +#endif +#ifndef ATTRIBUTE_FALLTHROUGH +# if 7 <= __GNUC__ +# define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough)) # else -# define _Noreturn +# define ATTRIBUTE_FALLTHROUGH ((void) 0) # endif #endif -#if __STDC_VERSION__ < 199901 && !defined restrict +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(maybe_unused) +# define ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]] +# endif +#endif +#ifndef ATTRIBUTE_MAYBE_UNUSED +# if 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define ATTRIBUTE_MAYBE_UNUSED __attribute__((unused)) +# else +# define ATTRIBUTE_MAYBE_UNUSED /* empty */ +# endif +#endif + +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(noreturn) +# define ATTRIBUTE_NORETURN [[noreturn]] +# endif +#endif +#ifndef ATTRIBUTE_NORETURN +# if 201112 <= __STDC_VERSION__ +# define ATTRIBUTE_NORETURN _Noreturn +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# else +# define ATTRIBUTE_NORETURN /* empty */ +# endif +#endif + +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(reproducible) +# define ATTRIBUTE_REPRODUCIBLE [[reproducible]] +# endif +#endif +#ifndef ATTRIBUTE_REPRODUCIBLE +# if 3 <= __GNUC__ +# define ATTRIBUTE_REPRODUCIBLE __attribute__((pure)) +# else +# define ATTRIBUTE_REPRODUCIBLE /* empty */ +# endif +#endif + +#if HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute(unsequenced) +# define ATTRIBUTE_UNSEQUENCED [[unsequenced]] +# endif +#endif +#ifndef ATTRIBUTE_UNSEQUENCED +# if 3 <= __GNUC__ +# define ATTRIBUTE_UNSEQUENCED __attribute__((const)) +# else +# define ATTRIBUTE_UNSEQUENCED /* empty */ +# endif +#endif + +#if (__STDC_VERSION__ < 199901 && !defined restrict \ + && (PORT_TO_C89 || defined _MSC_VER)) # define restrict /* empty */ #endif @@ -418,10 +594,11 @@ typedef unsigned long uintmax_t; # define TZ_TIME_T 0 #endif -#if TZ_TIME_T -# ifdef LOCALTIME_IMPLEMENTATION +#if defined LOCALTIME_IMPLEMENTATION && TZ_TIME_T static time_t sys_time(time_t *x) { return time(x); } -# endif +#endif + +#if TZ_TIME_T typedef time_tz tz_time_t; @@ -477,8 +654,6 @@ typedef time_tz tz_time_t; # define tzfree tz_tzfree # undef tzset # define tzset tz_tzset -# undef tzsetwall -# define tzsetwall tz_tzsetwall # if HAVE_STRFTIME_L # undef strftime_l # define strftime_l tz_strftime_l @@ -498,11 +673,16 @@ typedef time_tz tz_time_t; # define altzone tz_altzone # endif -char *asctime(struct tm const *); +# if __STDC_VERSION__ < 202311 +# define DEPRECATED_IN_C23 /* empty */ +# else +# define DEPRECATED_IN_C23 ATTRIBUTE_DEPRECATED +# endif +DEPRECATED_IN_C23 char *asctime(struct tm const *); char *asctime_r(struct tm const *restrict, char *restrict); -char *ctime(time_t const *); +DEPRECATED_IN_C23 char *ctime(time_t const *); char *ctime_r(time_t const *, char *); -double difftime(time_t, time_t) ATTRIBUTE_CONST; +ATTRIBUTE_UNSEQUENCED double difftime(time_t, time_t); size_t strftime(char *restrict, size_t, char const *restrict, struct tm const *restrict); # if HAVE_STRFTIME_L @@ -515,9 +695,24 @@ struct tm *localtime(time_t const *); struct tm *localtime_r(time_t const *restrict, struct tm *restrict); time_t mktime(struct tm *); time_t time(time_t *); +time_t timegm(struct tm *); void tzset(void); #endif +#ifndef HAVE_DECL_TIMEGM +# if (202311 <= __STDC_VERSION__ \ + || defined __GLIBC__ || defined __tm_zone /* musl */ \ + || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__)) +# define HAVE_DECL_TIMEGM true +# else +# define HAVE_DECL_TIMEGM false +# endif +#endif +#if !HAVE_DECL_TIMEGM && !defined timegm +time_t timegm(struct tm *); +#endif + #if !HAVE_DECL_ASCTIME_R && !defined asctime_r extern char *asctime_r(struct tm const *restrict, char *restrict); #endif @@ -550,21 +745,18 @@ extern long altzone; ** declarations if time_tz is defined. */ -#ifdef STD_INSPIRED -# if TZ_TIME_T || !defined tzsetwall -void tzsetwall(void); -# endif +#ifndef STD_INSPIRED +# define STD_INSPIRED 0 +#endif +#if STD_INSPIRED # if TZ_TIME_T || !defined offtime struct tm *offtime(time_t const *, long); # endif -# if TZ_TIME_T || !defined timegm -time_t timegm(struct tm *); -# endif # if TZ_TIME_T || !defined timelocal time_t timelocal(struct tm *); # endif # if TZ_TIME_T || !defined timeoff -time_t timeoff(struct tm *, long); +# define EXTERN_TIMEOFF # endif # if TZ_TIME_T || !defined time2posix time_t time2posix(time_t); @@ -576,7 +768,9 @@ time_t posix2time(time_t); /* Infer TM_ZONE on systems where this information is known, but suppress guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */ -#if (defined __GLIBC__ \ +#if (200809 < _POSIX_VERSION \ + || defined __GLIBC__ \ + || defined __tm_zone /* musl */ \ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \ || (defined __APPLE__ && defined __MACH__)) # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF @@ -602,12 +796,12 @@ struct tm *l |
