Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
    35         kx /* Private header for tzdb code.  */
    35         kx 
    35         kx #ifndef PRIVATE_H
    35         kx 
    35         kx #define PRIVATE_H
    35         kx 
    35         kx /*
    35         kx ** This file is in the public domain, so clarified as of
    35         kx ** 1996-06-05 by Arthur David Olson.
    35         kx */
    35         kx 
    35         kx /*
    35         kx ** This header is for use ONLY with the time conversion code.
    35         kx ** There is no guarantee that it will remain unchanged,
    35         kx ** or that it will remain at all.
    35         kx ** Do NOT copy it to any system include directory.
    35         kx ** Thank you!
    35         kx */
    35         kx 
    35         kx /* PORT_TO_C89 means the code should work even if the underlying
    35         kx    compiler and library support only C89.  SUPPORT_C89 means the
    35         kx    tzcode library should support C89 callers in addition to the usual
    35         kx    support for C99-and-later callers.  These macros are obsolescent,
    35         kx    and the plan is to remove them along with any code needed only when
    35         kx    they are nonzero.  */
    35         kx #ifndef PORT_TO_C89
    35         kx # define PORT_TO_C89 0
    35         kx #endif
    35         kx #ifndef SUPPORT_C89
    35         kx # define SUPPORT_C89 0
    35         kx #endif
    35         kx 
    35         kx #ifndef __STDC_VERSION__
    35         kx # define __STDC_VERSION__ 0
    35         kx #endif
    35         kx 
    35         kx /* Define true, false and bool if they don't work out of the box.  */
    35         kx #if PORT_TO_C89 && __STDC_VERSION__ < 199901
    35         kx # define true 1
    35         kx # define false 0
    35         kx # define bool int
    35         kx #elif __STDC_VERSION__ < 202311
    35         kx # include <stdbool.h>
    35         kx #endif
    35         kx 
    35         kx #if __STDC_VERSION__ < 202311
    35         kx # define static_assert(cond) extern int static_assert_check[(cond) ? 1 : -1]
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** zdump has been made independent of the rest of the time
    35         kx ** conversion package to increase confidence in the verification it provides.
    35         kx ** You can use zdump to help in verifying other implementations.
    35         kx ** To do this, compile with -DUSE_LTZ=0 and link without the tz library.
    35         kx */
    35         kx #ifndef USE_LTZ
    35         kx # define USE_LTZ 1
    35         kx #endif
    35         kx 
    35         kx /* This string was in the Factory zone through version 2016f.  */
    35         kx #define GRANDPARENTED	"Local time zone must be set--see zic manual page"
    35         kx 
    35         kx /*
    35         kx ** Defaults for preprocessor symbols.
    35         kx ** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'.
    35         kx */
    35         kx 
    35         kx #ifndef HAVE_DECL_ASCTIME_R
    35         kx # define HAVE_DECL_ASCTIME_R 1
    35         kx #endif
    35         kx 
    35         kx #if !defined HAVE__GENERIC && defined __has_extension
    35         kx # if __has_extension(c_generic_selections)
    35         kx #  define HAVE__GENERIC 1
    35         kx # else
    35         kx #  define HAVE__GENERIC 0
    35         kx # endif
    35         kx #endif
    35         kx /* _Generic is buggy in pre-4.9 GCC.  */
    35         kx #if !defined HAVE__GENERIC && defined __GNUC__ && !defined __STRICT_ANSI__
    35         kx # define HAVE__GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__))
    35         kx #endif
    35         kx #ifndef HAVE__GENERIC
    35         kx # define HAVE__GENERIC (201112 <= __STDC_VERSION__)
    35         kx #endif
    35         kx 
    35         kx #if !defined HAVE_GETTEXT && defined __has_include
    35         kx # if __has_include(<libintl.h>)
    35         kx #  define HAVE_GETTEXT true
    35         kx # endif
    35         kx #endif
    35         kx #ifndef HAVE_GETTEXT
    35         kx # define HAVE_GETTEXT false
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_INCOMPATIBLE_CTIME_R
    35         kx # define HAVE_INCOMPATIBLE_CTIME_R 0
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_LINK
    35         kx # define HAVE_LINK 1
    35         kx #endif /* !defined HAVE_LINK */
    35         kx 
    35         kx #ifndef HAVE_MALLOC_ERRNO
    35         kx # define HAVE_MALLOC_ERRNO 1
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_POSIX_DECLS
    35         kx # define HAVE_POSIX_DECLS 1
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_SETENV
    35         kx # define HAVE_SETENV 1
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_STRDUP
    35         kx # define HAVE_STRDUP 1
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_SYMLINK
    35         kx # define HAVE_SYMLINK 1
    35         kx #endif /* !defined HAVE_SYMLINK */
    35         kx 
    35         kx #if !defined HAVE_SYS_STAT_H && defined __has_include
    35         kx # if !__has_include(<sys/stat.h>)
    35         kx #  define HAVE_SYS_STAT_H false
    35         kx # endif
    35         kx #endif
    35         kx #ifndef HAVE_SYS_STAT_H
    35         kx # define HAVE_SYS_STAT_H true
    35         kx #endif
    35         kx 
    35         kx #if !defined HAVE_UNISTD_H && defined __has_include
    35         kx # if !__has_include(<unistd.h>)
    35         kx #  define HAVE_UNISTD_H false
    35         kx # endif
    35         kx #endif
    35         kx #ifndef HAVE_UNISTD_H
    35         kx # define HAVE_UNISTD_H true
    35         kx #endif
    35         kx 
    35         kx #ifndef NETBSD_INSPIRED
    35         kx # define NETBSD_INSPIRED 1
    35         kx #endif
    35         kx 
    35         kx #if HAVE_INCOMPATIBLE_CTIME_R
    35         kx # define asctime_r _incompatible_asctime_r
    35         kx # define ctime_r _incompatible_ctime_r
    35         kx #endif /* HAVE_INCOMPATIBLE_CTIME_R */
    35         kx 
    35         kx /* Enable tm_gmtoff, tm_zone, and environ on GNUish systems.  */
    35         kx #define _GNU_SOURCE 1
    35         kx /* Fix asctime_r on Solaris 11.  */
    35         kx #define _POSIX_PTHREAD_SEMANTICS 1
    35         kx /* Enable strtoimax on pre-C99 Solaris 11.  */
    35         kx #define __EXTENSIONS__ 1
    35         kx 
    35         kx /* On GNUish systems where time_t might be 32 or 64 bits, use 64.
    35         kx    On these platforms _FILE_OFFSET_BITS must also be 64; otherwise
    35         kx    setting _TIME_BITS to 64 does not work.  The code does not
    35         kx    otherwise rely on _FILE_OFFSET_BITS being 64, since it does not
    35         kx    use off_t or functions like 'stat' that depend on off_t.  */
    35         kx #ifndef _FILE_OFFSET_BITS
    35         kx # define _FILE_OFFSET_BITS 64
    35         kx #endif
    35         kx #if !defined _TIME_BITS && _FILE_OFFSET_BITS == 64
    35         kx # define _TIME_BITS 64
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** Nested includes
    35         kx */
    35         kx 
    35         kx /* Avoid clashes with NetBSD by renaming NetBSD's declarations.
    35         kx    If defining the 'timezone' variable, avoid a clash with FreeBSD's
    35         kx    'timezone' function by renaming its declaration.  */
    35         kx #define localtime_rz sys_localtime_rz
    35         kx #define mktime_z sys_mktime_z
    35         kx #define posix2time_z sys_posix2time_z
    35         kx #define time2posix_z sys_time2posix_z
    35         kx #if defined USG_COMPAT && USG_COMPAT == 2
    35         kx # define timezone sys_timezone
    35         kx #endif
    35         kx #define timezone_t sys_timezone_t
    35         kx #define tzalloc sys_tzalloc
    35         kx #define tzfree sys_tzfree
    35         kx #include <time.h>
    35         kx #undef localtime_rz
    35         kx #undef mktime_z
    35         kx #undef posix2time_z
    35         kx #undef time2posix_z
    35         kx #if defined USG_COMPAT && USG_COMPAT == 2
    35         kx # undef timezone
    35         kx #endif
    35         kx #undef timezone_t
    35         kx #undef tzalloc
    35         kx #undef tzfree
    35         kx 
    35         kx #include <stddef.h>
    35         kx #include <string.h>
    35         kx #if !PORT_TO_C89
    35         kx # include <inttypes.h>
    35         kx #endif
    35         kx #include <limits.h>	/* for CHAR_BIT et al. */
    35         kx #include <stdlib.h>
    35         kx 
    35         kx #include <errno.h>
    35         kx 
    35         kx #ifndef EINVAL
    35         kx # define EINVAL ERANGE
    35         kx #endif
    35         kx 
    35         kx #ifndef ELOOP
    35         kx # define ELOOP EINVAL
    35         kx #endif
    35         kx #ifndef ENAMETOOLONG
    35         kx # define ENAMETOOLONG EINVAL
    35         kx #endif
    35         kx #ifndef ENOMEM
    35         kx # define ENOMEM EINVAL
    35         kx #endif
    35         kx #ifndef ENOTSUP
    35         kx # define ENOTSUP EINVAL
    35         kx #endif
    35         kx #ifndef EOVERFLOW
    35         kx # define EOVERFLOW EINVAL
    35         kx #endif
    35         kx 
    35         kx #if HAVE_GETTEXT
    35         kx # include <libintl.h>
    35         kx #endif /* HAVE_GETTEXT */
    35         kx 
    35         kx #if HAVE_UNISTD_H
    35         kx # include <unistd.h> /* for R_OK, and other POSIX goodness */
    35         kx #endif /* HAVE_UNISTD_H */
    35         kx 
    35         kx #ifndef HAVE_STRFTIME_L
    35         kx # if _POSIX_VERSION < 200809
    35         kx #  define HAVE_STRFTIME_L 0
    35         kx # else
    35         kx #  define HAVE_STRFTIME_L 1
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef USG_COMPAT
    35         kx # ifndef _XOPEN_VERSION
    35         kx #  define USG_COMPAT 0
    35         kx # else
    35         kx #  define USG_COMPAT 1
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_TZNAME
    35         kx # if _POSIX_VERSION < 198808 && !USG_COMPAT
    35         kx #  define HAVE_TZNAME 0
    35         kx # else
    35         kx #  define HAVE_TZNAME 1
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef ALTZONE
    35         kx # if defined __sun || defined _M_XENIX
    35         kx #  define ALTZONE 1
    35         kx # else
    35         kx #  define ALTZONE 0
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef R_OK
    35         kx # define R_OK 4
    35         kx #endif /* !defined R_OK */
    35         kx 
    35         kx #if PORT_TO_C89
    35         kx 
    35         kx /*
    35         kx ** Define HAVE_STDINT_H's default value here, rather than at the
    35         kx ** start, since __GLIBC__ and INTMAX_MAX's values depend on
    35         kx ** previously included files.  glibc 2.1 and Solaris 10 and later have
    35         kx ** stdint.h, even with pre-C99 compilers.
    35         kx */
    35         kx #if !defined HAVE_STDINT_H && defined __has_include
    35         kx # define HAVE_STDINT_H true /* C23 __has_include implies C99 stdint.h.  */
    35         kx #endif
    35         kx #ifndef HAVE_STDINT_H
    35         kx # define HAVE_STDINT_H \
    35         kx    (199901 <= __STDC_VERSION__ \
    35         kx     || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \
    35         kx     || __CYGWIN__ || INTMAX_MAX)
    35         kx #endif /* !defined HAVE_STDINT_H */
    35         kx 
    35         kx #if HAVE_STDINT_H
    35         kx # include <stdint.h>
    35         kx #endif /* !HAVE_STDINT_H */
    35         kx 
    35         kx #ifndef HAVE_INTTYPES_H
    35         kx # define HAVE_INTTYPES_H HAVE_STDINT_H
    35         kx #endif
    35         kx #if HAVE_INTTYPES_H
    35         kx # include <inttypes.h>
    35         kx #endif
    35         kx 
    35         kx /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX.  */
    35         kx #if defined __LONG_LONG_MAX__ && !defined __STRICT_ANSI__
    35         kx # ifndef LLONG_MAX
    35         kx #  define LLONG_MAX __LONG_LONG_MAX__
    35         kx # endif
    35         kx # ifndef LLONG_MIN
    35         kx #  define LLONG_MIN (-1 - LLONG_MAX)
    35         kx # endif
    35         kx # ifndef ULLONG_MAX
    35         kx #  define ULLONG_MAX (LLONG_MAX * 2ull + 1)
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef INT_FAST64_MAX
    35         kx # if 1 <= LONG_MAX >> 31 >> 31
    35         kx typedef long int_fast64_t;
    35         kx #  define INT_FAST64_MIN LONG_MIN
    35         kx #  define INT_FAST64_MAX LONG_MAX
    35         kx # else
    35         kx /* If this fails, compile with -DHAVE_STDINT_H or with a better compiler.  */
    35         kx typedef long long int_fast64_t;
    35         kx #  define INT_FAST64_MIN LLONG_MIN
    35         kx #  define INT_FAST64_MAX LLONG_MAX
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef PRIdFAST64
    35         kx # if INT_FAST64_MAX == LONG_MAX
    35         kx #  define PRIdFAST64 "ld"
    35         kx # else
    35         kx #  define PRIdFAST64 "lld"
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef SCNdFAST64
    35         kx # define SCNdFAST64 PRIdFAST64
    35         kx #endif
    35         kx 
    35         kx #ifndef INT_FAST32_MAX
    35         kx # if INT_MAX >> 31 == 0
    35         kx typedef long int_fast32_t;
    35         kx #  define INT_FAST32_MAX LONG_MAX
    35         kx #  define INT_FAST32_MIN LONG_MIN
    35         kx # else
    35         kx typedef int int_fast32_t;
    35         kx #  define INT_FAST32_MAX INT_MAX
    35         kx #  define INT_FAST32_MIN INT_MIN
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef INTMAX_MAX
    35         kx # ifdef LLONG_MAX
    35         kx typedef long long intmax_t;
    35         kx #  ifndef HAVE_STRTOLL
    35         kx #   define HAVE_STRTOLL true
    35         kx #  endif
    35         kx #  if HAVE_STRTOLL
    35         kx #   define strtoimax strtoll
    35         kx #  endif
    35         kx #  define INTMAX_MAX LLONG_MAX
    35         kx #  define INTMAX_MIN LLONG_MIN
    35         kx # else
    35         kx typedef long intmax_t;
    35         kx #  define INTMAX_MAX LONG_MAX
    35         kx #  define INTMAX_MIN LONG_MIN
    35         kx # endif
    35         kx # ifndef strtoimax
    35         kx #  define strtoimax strtol
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef PRIdMAX
    35         kx # if INTMAX_MAX == LLONG_MAX
    35         kx #  define PRIdMAX "lld"
    35         kx # else
    35         kx #  define PRIdMAX "ld"
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef PTRDIFF_MAX
    35         kx # define PTRDIFF_MAX MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t))
    35         kx #endif
    35         kx 
    35         kx #ifndef UINT_FAST32_MAX
    35         kx typedef unsigned long uint_fast32_t;
    35         kx #endif
    35         kx 
    35         kx #ifndef UINT_FAST64_MAX
    35         kx # if 3 <= ULONG_MAX >> 31 >> 31
    35         kx typedef unsigned long uint_fast64_t;
    35         kx #  define UINT_FAST64_MAX ULONG_MAX
    35         kx # else
    35         kx /* If this fails, compile with -DHAVE_STDINT_H or with a better compiler.  */
    35         kx typedef unsigned long long uint_fast64_t;
    35         kx #  define UINT_FAST64_MAX ULLONG_MAX
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef UINTMAX_MAX
    35         kx # ifdef ULLONG_MAX
    35         kx typedef unsigned long long uintmax_t;
    35         kx #  define UINTMAX_MAX ULLONG_MAX
    35         kx # else
    35         kx typedef unsigned long uintmax_t;
    35         kx #  define UINTMAX_MAX ULONG_MAX
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef PRIuMAX
    35         kx # ifdef ULLONG_MAX
    35         kx #  define PRIuMAX "llu"
    35         kx # else
    35         kx #  define PRIuMAX "lu"
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #ifndef SIZE_MAX
    35         kx # define SIZE_MAX ((size_t) -1)
    35         kx #endif
    35         kx 
    35         kx #endif /* PORT_TO_C89 */
    35         kx 
    35         kx /* The maximum size of any created object, as a signed integer.
    35         kx    Although the C standard does not outright prohibit larger objects,
    35         kx    behavior is undefined if the result of pointer subtraction does not
    35         kx    fit into ptrdiff_t, and the code assumes in several places that
    35         kx    pointer subtraction works.  As a practical matter it's OK to not
    35         kx    support objects larger than this.  */
    35         kx #define INDEX_MAX ((ptrdiff_t) min(PTRDIFF_MAX, SIZE_MAX))
    35         kx 
    35         kx /* Support ckd_add, ckd_sub, ckd_mul on C23 or recent-enough GCC-like
    35         kx    hosts, unless compiled with -DHAVE_STDCKDINT_H=0 or with pre-C23 EDG.  */
    35         kx #if !defined HAVE_STDCKDINT_H && defined __has_include
    35         kx # if __has_include(<stdckdint.h>)
    35         kx #  define HAVE_STDCKDINT_H true
    35         kx # endif
    35         kx #endif
    35         kx #ifdef HAVE_STDCKDINT_H
    35         kx # if HAVE_STDCKDINT_H
    35         kx #  include <stdckdint.h>
    35         kx # endif
    35         kx #elif defined __EDG__
    35         kx /* Do nothing, to work around EDG bug <https://bugs.gnu.org/53256>.  */
    35         kx #elif defined __has_builtin
    35         kx # if __has_builtin(__builtin_add_overflow)
    35         kx #  define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
    35         kx # endif
    35         kx # if __has_builtin(__builtin_sub_overflow)
    35         kx #  define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r)
    35         kx # endif
    35         kx # if __has_builtin(__builtin_mul_overflow)
    35         kx #  define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r)
    35         kx # endif
    35         kx #elif 7 <= __GNUC__
    35         kx # define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
    35         kx # define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r)
    35         kx # define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r)
    35         kx #endif
    35         kx 
    35         kx #if 3 <= __GNUC__
    35         kx # define ATTRIBUTE_MALLOC __attribute__((malloc))
    35         kx # define ATTRIBUTE_FORMAT(spec) __attribute__((format spec))
    35         kx #else
    35         kx # define ATTRIBUTE_MALLOC /* empty */
    35         kx # define ATTRIBUTE_FORMAT(spec) /* empty */
    35         kx #endif
    35         kx 
    35         kx #if (defined __has_c_attribute \
    35         kx      && (202311 <= __STDC_VERSION__ || !defined __STRICT_ANSI__))
    35         kx # define HAVE___HAS_C_ATTRIBUTE true
    35         kx #else
    35         kx # define HAVE___HAS_C_ATTRIBUTE false
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(deprecated)
    35         kx #  define ATTRIBUTE_DEPRECATED [[deprecated]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_DEPRECATED
    35         kx # if 3 < __GNUC__ + (2 <= __GNUC_MINOR__)
    35         kx #  define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
    35         kx # else
    35         kx #  define ATTRIBUTE_DEPRECATED /* empty */
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(fallthrough)
    35         kx #  define ATTRIBUTE_FALLTHROUGH [[fallthrough]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_FALLTHROUGH
    35         kx # if 7 <= __GNUC__
    35         kx #  define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough))
    35         kx # else
    35         kx #  define ATTRIBUTE_FALLTHROUGH ((void) 0)
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(maybe_unused)
    35         kx #  define ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_MAYBE_UNUSED
    35         kx # if 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
    35         kx #  define ATTRIBUTE_MAYBE_UNUSED __attribute__((unused))
    35         kx # else
    35         kx #  define ATTRIBUTE_MAYBE_UNUSED /* empty */
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(noreturn)
    35         kx #  define ATTRIBUTE_NORETURN [[noreturn]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_NORETURN
    35         kx # if 201112 <= __STDC_VERSION__
    35         kx #  define ATTRIBUTE_NORETURN _Noreturn
    35         kx # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__)
    35         kx #  define ATTRIBUTE_NORETURN __attribute__((noreturn))
    35         kx # else
    35         kx #  define ATTRIBUTE_NORETURN /* empty */
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(reproducible)
    35         kx #  define ATTRIBUTE_REPRODUCIBLE [[reproducible]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_REPRODUCIBLE
    35         kx # if 3 <= __GNUC__
    35         kx #  define ATTRIBUTE_REPRODUCIBLE __attribute__((pure))
    35         kx # else
    35         kx #  define ATTRIBUTE_REPRODUCIBLE /* empty */
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if HAVE___HAS_C_ATTRIBUTE
    35         kx # if __has_c_attribute(unsequenced)
    35         kx #  define ATTRIBUTE_UNSEQUENCED [[unsequenced]]
    35         kx # endif
    35         kx #endif
    35         kx #ifndef ATTRIBUTE_UNSEQUENCED
    35         kx # if 3 <= __GNUC__
    35         kx #  define ATTRIBUTE_UNSEQUENCED __attribute__((const))
    35         kx # else
    35         kx #  define ATTRIBUTE_UNSEQUENCED /* empty */
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if (__STDC_VERSION__ < 199901 && !defined restrict \
    35         kx      && (PORT_TO_C89 || defined _MSC_VER))
    35         kx # define restrict /* empty */
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** Workarounds for compilers/systems.
    35         kx */
    35         kx 
    35         kx #ifndef EPOCH_LOCAL
    35         kx # define EPOCH_LOCAL 0
    35         kx #endif
    35         kx #ifndef EPOCH_OFFSET
    35         kx # define EPOCH_OFFSET 0
    35         kx #endif
    35         kx #ifndef RESERVE_STD_EXT_IDS
    35         kx # define RESERVE_STD_EXT_IDS 0
    35         kx #endif
    35         kx 
    35         kx /* If standard C identifiers with external linkage (e.g., localtime)
    35         kx    are reserved and are not already being renamed anyway, rename them
    35         kx    as if compiling with '-Dtime_tz=time_t'.  */
    35         kx #if !defined time_tz && RESERVE_STD_EXT_IDS && USE_LTZ
    35         kx # define time_tz time_t
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** Compile with -Dtime_tz=T to build the tz package with a private
    35         kx ** time_t type equivalent to T rather than the system-supplied time_t.
    35         kx ** This debugging feature can test unusual design decisions
    35         kx ** (e.g., time_t wider than 'long', or unsigned time_t) even on
    35         kx ** typical platforms.
    35         kx */
    35         kx #if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0
    35         kx # define TZ_TIME_T 1
    35         kx #else
    35         kx # define TZ_TIME_T 0
    35         kx #endif
    35         kx 
    35         kx #if defined LOCALTIME_IMPLEMENTATION && TZ_TIME_T
    35         kx static time_t sys_time(time_t *x) { return time(x); }
    35         kx #endif
    35         kx 
    35         kx #if TZ_TIME_T
    35         kx 
    35         kx typedef time_tz tz_time_t;
    35         kx 
    35         kx # undef  asctime
    35         kx # define asctime tz_asctime
    35         kx # undef  asctime_r
    35         kx # define asctime_r tz_asctime_r
    35         kx # undef  ctime
    35         kx # define ctime tz_ctime
    35         kx # undef  ctime_r
    35         kx # define ctime_r tz_ctime_r
    35         kx # undef  difftime
    35         kx # define difftime tz_difftime
    35         kx # undef  gmtime
    35         kx # define gmtime tz_gmtime
    35         kx # undef  gmtime_r
    35         kx # define gmtime_r tz_gmtime_r
    35         kx # undef  localtime
    35         kx # define localtime tz_localtime
    35         kx # undef  localtime_r
    35         kx # define localtime_r tz_localtime_r
    35         kx # undef  localtime_rz
    35         kx # define localtime_rz tz_localtime_rz
    35         kx # undef  mktime
    35         kx # define mktime tz_mktime
    35         kx # undef  mktime_z
    35         kx # define mktime_z tz_mktime_z
    35         kx # undef  offtime
    35         kx # define offtime tz_offtime
    35         kx # undef  posix2time
    35         kx # define posix2time tz_posix2time
    35         kx # undef  posix2time_z
    35         kx # define posix2time_z tz_posix2time_z
    35         kx # undef  strftime
    35         kx # define strftime tz_strftime
    35         kx # undef  time
    35         kx # define time tz_time
    35         kx # undef  time2posix
    35         kx # define time2posix tz_time2posix
    35         kx # undef  time2posix_z
    35         kx # define time2posix_z tz_time2posix_z
    35         kx # undef  time_t
    35         kx # define time_t tz_time_t
    35         kx # undef  timegm
    35         kx # define timegm tz_timegm
    35         kx # undef  timelocal
    35         kx # define timelocal tz_timelocal
    35         kx # undef  timeoff
    35         kx # define timeoff tz_timeoff
    35         kx # undef  tzalloc
    35         kx # define tzalloc tz_tzalloc
    35         kx # undef  tzfree
    35         kx # define tzfree tz_tzfree
    35         kx # undef  tzset
    35         kx # define tzset tz_tzset
    35         kx # if HAVE_STRFTIME_L
    35         kx #  undef  strftime_l
    35         kx #  define strftime_l tz_strftime_l
    35         kx # endif
    35         kx # if HAVE_TZNAME
    35         kx #  undef  tzname
    35         kx #  define tzname tz_tzname
    35         kx # endif
    35         kx # if USG_COMPAT
    35         kx #  undef  daylight
    35         kx #  define daylight tz_daylight
    35         kx #  undef  timezone
    35         kx #  define timezone tz_timezone
    35         kx # endif
    35         kx # if ALTZONE
    35         kx #  undef  altzone
    35         kx #  define altzone tz_altzone
    35         kx # endif
    35         kx 
    35         kx # if __STDC_VERSION__ < 202311
    35         kx #  define DEPRECATED_IN_C23 /* empty */
    35         kx # else
    35         kx #  define DEPRECATED_IN_C23 ATTRIBUTE_DEPRECATED
    35         kx # endif
    35         kx DEPRECATED_IN_C23 char *asctime(struct tm const *);
    35         kx char *asctime_r(struct tm const *restrict, char *restrict);
    35         kx DEPRECATED_IN_C23 char *ctime(time_t const *);
    35         kx char *ctime_r(time_t const *, char *);
    35         kx ATTRIBUTE_UNSEQUENCED double difftime(time_t, time_t);
    35         kx size_t strftime(char *restrict, size_t, char const *restrict,
    35         kx 		struct tm const *restrict);
    35         kx # if HAVE_STRFTIME_L
    35         kx size_t strftime_l(char *restrict, size_t, char const *restrict,
    35         kx 		  struct tm const *restrict, locale_t);
    35         kx # endif
    35         kx struct tm *gmtime(time_t const *);
    35         kx struct tm *gmtime_r(time_t const *restrict, struct tm *restrict);
    35         kx struct tm *localtime(time_t const *);
    35         kx struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
    35         kx time_t mktime(struct tm *);
    35         kx time_t time(time_t *);
    35         kx time_t timegm(struct tm *);
    35         kx void tzset(void);
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_DECL_TIMEGM
    35         kx # if (202311 <= __STDC_VERSION__ \
    35         kx       || defined __GLIBC__ || defined __tm_zone /* musl */ \
    35         kx       || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
    35         kx       || (defined __APPLE__ && defined __MACH__))
    35         kx #  define HAVE_DECL_TIMEGM true
    35         kx # else
    35         kx #  define HAVE_DECL_TIMEGM false
    35         kx # endif
    35         kx #endif
    35         kx #if !HAVE_DECL_TIMEGM && !defined timegm
    35         kx time_t timegm(struct tm *);
    35         kx #endif
    35         kx 
    35         kx #if !HAVE_DECL_ASCTIME_R && !defined asctime_r
    35         kx extern char *asctime_r(struct tm const *restrict, char *restrict);
    35         kx #endif
    35         kx 
    35         kx #ifndef HAVE_DECL_ENVIRON
    35         kx # if defined environ || defined __USE_GNU
    35         kx #  define HAVE_DECL_ENVIRON 1
    35         kx # else
    35         kx #  define HAVE_DECL_ENVIRON 0
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx #if !HAVE_DECL_ENVIRON
    35         kx extern char **environ;
    35         kx #endif
    35         kx 
    35         kx #if 2 <= HAVE_TZNAME + (TZ_TIME_T || !HAVE_POSIX_DECLS)
    35         kx extern char *tzname[];
    35         kx #endif
    35         kx #if 2 <= USG_COMPAT + (TZ_TIME_T || !HAVE_POSIX_DECLS)
    35         kx extern long timezone;
    35         kx extern int daylight;
    35         kx #endif
    35         kx #if 2 <= ALTZONE + (TZ_TIME_T || !HAVE_POSIX_DECLS)
    35         kx extern long altzone;
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** The STD_INSPIRED functions are similar, but most also need
    35         kx ** declarations if time_tz is defined.
    35         kx */
    35         kx 
    35         kx #ifndef STD_INSPIRED
    35         kx # define STD_INSPIRED 0
    35         kx #endif
    35         kx #if STD_INSPIRED
    35         kx # if TZ_TIME_T || !defined offtime
    35         kx struct tm *offtime(time_t const *, long);
    35         kx # endif
    35         kx # if TZ_TIME_T || !defined timelocal
    35         kx time_t timelocal(struct tm *);
    35         kx # endif
    35         kx # if TZ_TIME_T || !defined timeoff
    35         kx time_t timeoff(struct tm *, long);
    35         kx # endif
    35         kx # if TZ_TIME_T || !defined time2posix
    35         kx time_t time2posix(time_t);
    35         kx # endif
    35         kx # if TZ_TIME_T || !defined posix2time
    35         kx time_t posix2time(time_t);
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx /* Infer TM_ZONE on systems where this information is known, but suppress
    35         kx    guessing if NO_TM_ZONE is defined.  Similarly for TM_GMTOFF.  */
    35         kx #if (defined __GLIBC__ \
    35         kx      || defined __tm_zone /* musl */ \
    35         kx      || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
    35         kx      || (defined __APPLE__ && defined __MACH__))
    35         kx # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
    35         kx #  define TM_GMTOFF tm_gmtoff
    35         kx # endif
    35         kx # if !defined TM_ZONE && !defined NO_TM_ZONE
    35         kx #  define TM_ZONE tm_zone
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** Define functions that are ABI compatible with NetBSD but have
    35         kx ** better prototypes.  NetBSD 6.1.4 defines a pointer type timezone_t
    35         kx ** and labors under the misconception that 'const timezone_t' is a
    35         kx ** pointer to a constant.  This use of 'const' is ineffective, so it
    35         kx ** is not done here.  What we call 'struct state' NetBSD calls
    35         kx ** 'struct __state', but this is a private name so it doesn't matter.
    35         kx */
    35         kx #if NETBSD_INSPIRED
    35         kx typedef struct state *timezone_t;
    35         kx struct tm *localtime_rz(timezone_t restrict, time_t const *restrict,
    35         kx 			struct tm *restrict);
    35         kx time_t mktime_z(timezone_t restrict, struct tm *restrict);
    35         kx timezone_t tzalloc(char const *);
    35         kx void tzfree(timezone_t);
    35         kx # if STD_INSPIRED
    35         kx #  if TZ_TIME_T || !defined posix2time_z
    35         kx ATTRIBUTE_REPRODUCIBLE time_t posix2time_z(timezone_t, time_t);
    35         kx #  endif
    35         kx #  if TZ_TIME_T || !defined time2posix_z
    35         kx ATTRIBUTE_REPRODUCIBLE time_t time2posix_z(timezone_t, time_t);
    35         kx #  endif
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** Finally, some convenience items.
    35         kx */
    35         kx 
    35         kx #define TYPE_BIT(type) (CHAR_BIT * (ptrdiff_t) sizeof(type))
    35         kx #define TYPE_SIGNED(type) (((type) -1) < 0)
    35         kx #define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0)
    35         kx 
    35         kx /* Minimum and maximum of two values.  Use lower case to avoid
    35         kx    naming clashes with standard include files.  */
    35         kx #define max(a, b) ((a) > (b) ? (a) : (b))
    35         kx #define min(a, b) ((a) < (b) ? (a) : (b))
    35         kx 
    35         kx /* Max and min values of the integer type T, of which only the bottom
    35         kx    B bits are used, and where the highest-order used bit is considered
    35         kx    to be a sign bit if T is signed.  */
    35         kx #define MAXVAL(t, b)						\
    35         kx   ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))			\
    35         kx 	- 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
    35         kx #define MINVAL(t, b)						\
    35         kx   ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
    35         kx 
    35         kx /* The extreme time values, assuming no padding.  */
    35         kx #define TIME_T_MIN_NO_PADDING MINVAL(time_t, TYPE_BIT(time_t))
    35         kx #define TIME_T_MAX_NO_PADDING MAXVAL(time_t, TYPE_BIT(time_t))
    35         kx 
    35         kx /* The extreme time values.  These are macros, not constants, so that
    35         kx    any portability problems occur only when compiling .c files that use
    35         kx    the macros, which is safer for applications that need only zdump and zic.
    35         kx    This implementation assumes no padding if time_t is signed and
    35         kx    either the compiler lacks support for _Generic or time_t is not one
    35         kx    of the standard signed integer types.  */
    35         kx #if HAVE__GENERIC
    35         kx # define TIME_T_MIN \
    35         kx     _Generic((time_t) 0, \
    35         kx 	     signed char: SCHAR_MIN, short: SHRT_MIN, \
    35         kx 	     int: INT_MIN, long: LONG_MIN, long long: LLONG_MIN, \
    35         kx 	     default: TIME_T_MIN_NO_PADDING)
    35         kx # define TIME_T_MAX \
    35         kx     (TYPE_SIGNED(time_t) \
    35         kx      ? _Generic((time_t) 0, \
    35         kx 		signed char: SCHAR_MAX, short: SHRT_MAX, \
    35         kx 		int: INT_MAX, long: LONG_MAX, long long: LLONG_MAX, \
    35         kx 		default: TIME_T_MAX_NO_PADDING)			    \
    35         kx      : (time_t) -1)
    35         kx enum { SIGNED_PADDING_CHECK_NEEDED
    35         kx          = _Generic((time_t) 0,
    35         kx 		    signed char: false, short: false,
    35         kx 		    int: false, long: false, long long: false,
    35         kx 		    default: true) };
    35         kx #else
    35         kx # define TIME_T_MIN TIME_T_MIN_NO_PADDING
    35         kx # define TIME_T_MAX TIME_T_MAX_NO_PADDING
    35         kx enum { SIGNED_PADDING_CHECK_NEEDED = true };
    35         kx #endif
    35         kx /* Try to check the padding assumptions.  Although TIME_T_MAX and the
    35         kx    following check can both have undefined behavior on oddball
    35         kx    platforms due to shifts exceeding widths of signed integers, these
    35         kx    platforms' compilers are likely to diagnose these issues in integer
    35         kx    constant expressions, so it shouldn't hurt to check statically.  */
    35         kx static_assert(! TYPE_SIGNED(time_t) || ! SIGNED_PADDING_CHECK_NEEDED
    35         kx 	      || TIME_T_MAX >> (TYPE_BIT(time_t) - 2) == 1);
    35         kx 
    35         kx /*
    35         kx ** 302 / 1000 is log10(2.0) rounded up.
    35         kx ** Subtract one for the sign bit if the type is signed;
    35         kx ** add one for integer division truncation;
    35         kx ** add one more for a minus sign if the type is signed.
    35         kx */
    35         kx #define INT_STRLEN_MAXIMUM(type) \
    35         kx 	((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
    35         kx 	1 + TYPE_SIGNED(type))
    35         kx 
    35         kx /*
    35         kx ** INITIALIZE(x)
    35         kx */
    35         kx 
    35         kx #ifdef GCC_LINT
    35         kx # define INITIALIZE(x)	((x) = 0)
    35         kx #else
    35         kx # define INITIALIZE(x)
    35         kx #endif
    35         kx 
    35         kx /* Whether memory access must strictly follow the C standard.
    35         kx    If 0, it's OK to read uninitialized storage so long as the value is
    35         kx    not relied upon.  Defining it to 0 lets mktime access parts of
    35         kx    struct tm that might be uninitialized, as a heuristic when the
    35         kx    standard doesn't say what to return and when tm_gmtoff can help
    35         kx    mktime likely infer a better value.  */
    35         kx #ifndef UNINIT_TRAP
    35         kx # define UNINIT_TRAP 0
    35         kx #endif
    35         kx 
    35         kx #ifdef DEBUG
    35         kx # undef unreachable
    35         kx # define unreachable() abort()
    35         kx #elif !defined unreachable
    35         kx # ifdef __has_builtin
    35         kx #  if __has_builtin(__builtin_unreachable)
    35         kx #   define unreachable() __builtin_unreachable()
    35         kx #  endif
    35         kx # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
    35         kx #  define unreachable() __builtin_unreachable()
    35         kx # endif
    35         kx # ifndef unreachable
    35         kx #  define unreachable() ((void) 0)
    35         kx # endif
    35         kx #endif
    35         kx 
    35         kx /*
    35         kx ** For the benefit of GNU folk...
    35         kx ** '_(MSGID)' uses the current locale's message library string for MSGID.
    35         kx ** The default is to use gettext if available, and use MSGID otherwise.
    35         kx */
    35         kx 
    35         kx #ifndef _
    35         kx #if HAVE_GETTEXT
    35         kx #define _(msgid) gettext(msgid)
    35         kx #else /* !HAVE_GETTEXT */
    35         kx #define _(msgid) msgid
    35         kx #endif /* !HAVE_GETTEXT */
    35         kx #endif /* !defined _ */
    35         kx 
    35         kx #if !defined TZ_DOMAIN && defined HAVE_GETTEXT
    35         kx # define TZ_DOMAIN "tz"
    35         kx #endif
    35         kx 
    35         kx #if HAVE_INCOMPATIBLE_CTIME_R
    35         kx #undef asctime_r
    35         kx #undef ctime_r
    35         kx char *asctime_r(struct tm const *restrict, char *restrict);
    35         kx char *ctime_r(time_t const *, char *);
    35         kx #endif /* HAVE_INCOMPATIBLE_CTIME_R */
    35         kx 
    35         kx /* Handy macros that are independent of tzfile implementation.  */
    35         kx 
    35         kx enum {
    35         kx   SECSPERMIN = 60,
    35         kx   MINSPERHOUR = 60,
    35         kx   SECSPERHOUR = SECSPERMIN * MINSPERHOUR,
    35         kx   HOURSPERDAY = 24,
    35         kx   DAYSPERWEEK = 7,
    35         kx   DAYSPERNYEAR = 365,
    35         kx   DAYSPERLYEAR = DAYSPERNYEAR + 1,
    35         kx   MONSPERYEAR = 12,
    35         kx   YEARSPERREPEAT = 400	/* years before a Gregorian repeat */
    35         kx };
    35         kx 
    35         kx #define SECSPERDAY	((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
    35         kx 
    35         kx #define DAYSPERREPEAT		((int_fast32_t) 400 * 365 + 100 - 4 + 1)
    35         kx #define SECSPERREPEAT		((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
    35         kx #define AVGSECSPERYEAR		(SECSPERREPEAT / YEARSPERREPEAT)
    35         kx 
    35         kx enum {
    35         kx   TM_SUNDAY,
    35         kx   TM_MONDAY,
    35         kx   TM_TUESDAY,
    35         kx   TM_WEDNESDAY,
    35         kx   TM_THURSDAY,
    35         kx   TM_FRIDAY,
    35         kx   TM_SATURDAY
    35         kx };
    35         kx 
    35         kx enum {
    35         kx   TM_JANUARY,
    35         kx   TM_FEBRUARY,
    35         kx   TM_MARCH,
    35         kx   TM_APRIL,
    35         kx   TM_MAY,
    35         kx   TM_JUNE,
    35         kx   TM_JULY,
    35         kx   TM_AUGUST,
    35         kx   TM_SEPTEMBER,
    35         kx   TM_OCTOBER,
    35         kx   TM_NOVEMBER,
    35         kx   TM_DECEMBER
    35         kx };
    35         kx 
    35         kx enum {
    35         kx   TM_YEAR_BASE = 1900,
    35         kx   TM_WDAY_BASE = TM_MONDAY,
    35         kx   EPOCH_YEAR = 1970,
    35         kx   EPOCH_WDAY = TM_THURSDAY
    35         kx };
    35         kx 
    35         kx #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
    35         kx 
    35         kx /*
    35         kx ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
    35         kx **	isleap(y) == isleap(y % 400)
    35         kx ** and so
    35         kx **	isleap(a + b) == isleap((a + b) % 400)
    35         kx ** or
    35         kx **	isleap(a + b) == isleap(a % 400 + b % 400)
    35         kx ** This is true even if % means modulo rather than Fortran remainder
    35         kx ** (which is allowed by C89 but not by C99 or later).
    35         kx ** We use this to avoid addition overflow problems.
    35         kx */
    35         kx 
    35         kx #define isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
    35         kx 
    35         kx #endif /* !defined PRIVATE_H */