1 /* Private header for tzdb code. */
8 ** This file is in the public domain, so clarified as of
9 ** 1996-06-05 by Arthur David Olson.
13 ** This header is for use ONLY with the time conversion code.
14 ** There is no guarantee that it will remain unchanged,
15 ** or that it will remain at all.
16 ** Do NOT copy it to any system include directory.
20 #ifndef __STDC_VERSION__
21 # define __STDC_VERSION__ 0
24 /* Define true, false and bool if they don't work out of the box. */
25 #if __STDC_VERSION__ < 199901
29 #elif __STDC_VERSION__ < 202311
34 ** zdump has been made independent of the rest of the time
35 ** conversion package to increase confidence in the verification it provides.
36 ** You can use zdump to help in verifying other implementations.
37 ** To do this, compile with -DUSE_LTZ=0 and link without the tz library.
43 /* This string was in the Factory zone through version 2016f. */
44 #define GRANDPARENTED "Local time zone must be set--use tzsetup"
47 ** Defaults for preprocessor symbols.
48 ** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'.
51 #ifndef HAVE_DECL_ASCTIME_R
52 # define HAVE_DECL_ASCTIME_R 1
55 #if !defined HAVE_GENERIC && defined __has_extension
56 # if __has_extension(c_generic_selections)
57 # define HAVE_GENERIC 1
59 # define HAVE_GENERIC 0
62 /* _Generic is buggy in pre-4.9 GCC. */
63 #if !defined HAVE_GENERIC && defined __GNUC__ && !defined __STRICT_ANSI__
64 # define HAVE_GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__))
67 # define HAVE_GENERIC (201112 <= __STDC_VERSION__)
70 #if !defined HAVE_GETTEXT && defined __has_include
71 # if __has_include(<libintl.h>)
72 # define HAVE_GETTEXT true
76 # define HAVE_GETTEXT false
79 #ifndef HAVE_INCOMPATIBLE_CTIME_R
80 # define HAVE_INCOMPATIBLE_CTIME_R 0
85 #endif /* !defined HAVE_LINK */
87 #ifndef HAVE_MALLOC_ERRNO
88 # define HAVE_MALLOC_ERRNO 1
91 #ifndef HAVE_POSIX_DECLS
92 # define HAVE_POSIX_DECLS 1
96 # define HAVE_SETENV 1
100 # define HAVE_STRDUP 1
104 # define HAVE_STRTOLL 1
108 # define HAVE_SYMLINK 1
109 #endif /* !defined HAVE_SYMLINK */
111 #if !defined HAVE_SYS_STAT_H && defined __has_include
112 # if !__has_include(<sys/stat.h>)
113 # define HAVE_SYS_STAT_H false
116 #ifndef HAVE_SYS_STAT_H
117 # define HAVE_SYS_STAT_H true
120 #if !defined HAVE_UNISTD_H && defined __has_include
121 # if !__has_include(<unistd.h>)
122 # define HAVE_UNISTD_H false
125 #ifndef HAVE_UNISTD_H
126 # define HAVE_UNISTD_H true
129 #ifndef NETBSD_INSPIRED
130 # define NETBSD_INSPIRED 1
133 #if HAVE_INCOMPATIBLE_CTIME_R
134 # define asctime_r _incompatible_asctime_r
135 # define ctime_r _incompatible_ctime_r
136 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
138 /* Enable tm_gmtoff, tm_zone, and environ on GNUish systems. */
139 #define _GNU_SOURCE 1
140 /* Fix asctime_r on Solaris 11. */
141 #define _POSIX_PTHREAD_SEMANTICS 1
142 /* Enable strtoimax on pre-C99 Solaris 11. */
143 #define __EXTENSIONS__ 1
145 /* On GNUish systems where time_t might be 32 or 64 bits, use 64.
146 On these platforms _FILE_OFFSET_BITS must also be 64; otherwise
147 setting _TIME_BITS to 64 does not work. The code does not
148 otherwise rely on _FILE_OFFSET_BITS being 64, since it does not
149 use off_t or functions like 'stat' that depend on off_t. */
150 #ifndef _FILE_OFFSET_BITS
151 # define _FILE_OFFSET_BITS 64
153 #if !defined _TIME_BITS && _FILE_OFFSET_BITS == 64
154 # define _TIME_BITS 64
161 /* Avoid clashes with NetBSD by renaming NetBSD's declarations.
162 If defining the 'timezone' variable, avoid a clash with FreeBSD's
163 'timezone' function by renaming its declaration. */
164 #define localtime_rz sys_localtime_rz
165 #define mktime_z sys_mktime_z
166 #define posix2time_z sys_posix2time_z
167 #define time2posix_z sys_time2posix_z
168 #if defined USG_COMPAT && USG_COMPAT == 2
169 # define timezone sys_timezone
171 #define timezone_t sys_timezone_t
172 #define tzalloc sys_tzalloc
173 #define tzfree sys_tzfree
179 #if defined USG_COMPAT && USG_COMPAT == 2
188 #include <limits.h> /* for CHAR_BIT et al. */
194 # define EINVAL ERANGE
198 # define ELOOP EINVAL
201 # define ENAMETOOLONG EINVAL
204 # define ENOMEM EINVAL
207 # define ENOTSUP EINVAL
210 # define EOVERFLOW EINVAL
214 # include <libintl.h>
215 #endif /* HAVE_GETTEXT */
218 # include <unistd.h> /* for R_OK, and other POSIX goodness */
219 #endif /* HAVE_UNISTD_H */
221 #ifndef HAVE_STRFTIME_L
222 # if _POSIX_VERSION < 200809
223 # define HAVE_STRFTIME_L 0
225 # define HAVE_STRFTIME_L 1
230 # ifndef _XOPEN_VERSION
231 # define USG_COMPAT 0
233 # define USG_COMPAT 1
238 # if _POSIX_VERSION < 198808 && !USG_COMPAT
239 # define HAVE_TZNAME 0
241 # define HAVE_TZNAME 1
246 # if defined __sun || defined _M_XENIX
255 #endif /* !defined R_OK */
258 ** Define HAVE_STDINT_H's default value here, rather than at the
259 ** start, since __GLIBC__ and INTMAX_MAX's values depend on
260 ** previously-included files. glibc 2.1 and Solaris 10 and later have
261 ** stdint.h, even with pre-C99 compilers.
263 #if !defined HAVE_STDINT_H && defined __has_include
264 # define HAVE_STDINT_H true /* C23 __has_include implies C99 stdint.h. */
266 #ifndef HAVE_STDINT_H
267 # define HAVE_STDINT_H \
268 (199901 <= __STDC_VERSION__ \
269 || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \
270 || __CYGWIN__ || INTMAX_MAX)
271 #endif /* !defined HAVE_STDINT_H */
275 #endif /* !HAVE_STDINT_H */
277 #ifndef HAVE_INTTYPES_H
278 # define HAVE_INTTYPES_H HAVE_STDINT_H
281 # include <inttypes.h>
284 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
285 #if defined __LONG_LONG_MAX__ && !defined __STRICT_ANSI__
287 # define LLONG_MAX __LONG_LONG_MAX__
290 # define LLONG_MIN (-1 - LLONG_MAX)
293 # define ULLONG_MAX (LLONG_MAX * 2ull + 1)
297 #ifndef INT_FAST64_MAX
298 # if 1 <= LONG_MAX >> 31 >> 31
299 typedef long int_fast64_t;
300 # define INT_FAST64_MIN LONG_MIN
301 # define INT_FAST64_MAX LONG_MAX
303 /* If this fails, compile with -DHAVE_STDINT_H or with a better compiler. */
304 typedef long long int_fast64_t;
305 # define INT_FAST64_MIN LLONG_MIN
306 # define INT_FAST64_MAX LLONG_MAX
311 # if INT_FAST64_MAX == LONG_MAX
312 # define PRIdFAST64 "ld"
314 # define PRIdFAST64 "lld"
319 # define SCNdFAST64 PRIdFAST64
322 #ifndef INT_FAST32_MAX
323 # if INT_MAX >> 31 == 0
324 typedef long int_fast32_t;
325 # define INT_FAST32_MAX LONG_MAX
326 # define INT_FAST32_MIN LONG_MIN
328 typedef int int_fast32_t;
329 # define INT_FAST32_MAX INT_MAX
330 # define INT_FAST32_MIN INT_MIN
336 typedef long long intmax_t;
338 # define strtoimax strtoll
340 # define INTMAX_MAX LLONG_MAX
341 # define INTMAX_MIN LLONG_MIN
343 typedef long intmax_t;
344 # define INTMAX_MAX LONG_MAX
345 # define INTMAX_MIN LONG_MIN
348 # define strtoimax strtol
353 # if INTMAX_MAX == LLONG_MAX
354 # define PRIdMAX "lld"
356 # define PRIdMAX "ld"
361 # define PTRDIFF_MAX MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t))
364 #ifndef UINT_FAST32_MAX
365 typedef unsigned long uint_fast32_t;
368 #ifndef UINT_FAST64_MAX
369 # if 3 <= ULONG_MAX >> 31 >> 31
370 typedef unsigned long uint_fast64_t;
371 # define UINT_FAST64_MAX ULONG_MAX
373 /* If this fails, compile with -DHAVE_STDINT_H or with a better compiler. */
374 typedef unsigned long long uint_fast64_t;
375 # define UINT_FAST64_MAX ULLONG_MAX
381 typedef unsigned long long uintmax_t;
383 typedef unsigned long uintmax_t;
389 # define PRIuMAX "llu"
391 # define PRIuMAX "lu"
396 # define SIZE_MAX ((size_t) -1)
399 /* Support ckd_add, ckd_sub, ckd_mul on C23 or recent-enough GCC-like
400 hosts, unless compiled with -DHAVE_STDCKDINT_H=0 or with pre-C23 EDG. */
401 #if !defined HAVE_STDCKDINT_H && defined __has_include
402 # if __has_include(<stdckdint.h>)
403 # define HAVE_STDCKDINT_H true
406 #ifdef HAVE_STDCKDINT_H
407 # if HAVE_STDCKDINT_H
408 # include <stdckdint.h>
410 #elif defined __EDG__
411 /* Do nothing, to work around EDG bug <https://bugs.gnu.org/53256>. */
412 #elif defined __has_builtin
413 # if __has_builtin(__builtin_add_overflow)
414 # define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
416 # if __has_builtin(__builtin_sub_overflow)
417 # define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r)
419 # if __has_builtin(__builtin_mul_overflow)
420 # define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r)
423 # define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
424 # define ckd_sub(r, a, b) __builtin_sub_overflow(a, b, r)
425 # define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r)
429 # define ATTRIBUTE_MALLOC __attribute__((malloc))
430 # define ATTRIBUTE_FORMAT(spec) __attribute__((format spec))
432 # define ATTRIBUTE_MALLOC /* empty */
433 # define ATTRIBUTE_FORMAT(spec) /* empty */
436 #if (defined __has_c_attribute \
437 && (202311 <= __STDC_VERSION__ || !defined __STRICT_ANSI__))
438 # define HAVE_HAS_C_ATTRIBUTE true
440 # define HAVE_HAS_C_ATTRIBUTE false
443 #if HAVE_HAS_C_ATTRIBUTE
444 # if __has_c_attribute(fallthrough)
445 # define ATTRIBUTE_FALLTHROUGH [[fallthrough]]
448 #ifndef ATTRIBUTE_FALLTHROUGH
450 # define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough))
452 # define ATTRIBUTE_FALLTHROUGH ((void) 0)
456 #if HAVE_HAS_C_ATTRIBUTE
457 # if __has_c_attribute(maybe_unused)
458 # define ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
461 #ifndef ATTRIBUTE_MAYBE_UNUSED
462 # if 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
463 # define ATTRIBUTE_MAYBE_UNUSED __attribute__((unused))
465 # define ATTRIBUTE_MAYBE_UNUSED /* empty */
469 #if HAVE_HAS_C_ATTRIBUTE
470 # if __has_c_attribute(noreturn)
471 # define ATTRIBUTE_NORETURN [[noreturn]]
474 #ifndef ATTRIBUTE_NORETURN
475 # if 201112 <= __STDC_VERSION__
476 # define ATTRIBUTE_NORETURN _Noreturn
477 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__)
478 # define ATTRIBUTE_NORETURN __attribute__((noreturn))
480 # define ATTRIBUTE_NORETURN /* empty */
484 #if HAVE_HAS_C_ATTRIBUTE
485 # if __has_c_attribute(reproducible)
486 # define ATTRIBUTE_REPRODUCIBLE [[reproducible]]
489 #ifndef ATTRIBUTE_REPRODUCIBLE
491 # define ATTRIBUTE_REPRODUCIBLE __attribute__((pure))
493 # define ATTRIBUTE_REPRODUCIBLE /* empty */
497 #if HAVE_HAS_C_ATTRIBUTE
498 # if __has_c_attribute(unsequenced)
499 # define ATTRIBUTE_UNSEQUENCED [[unsequenced]]
502 #ifndef ATTRIBUTE_UNSEQUENCED
504 # define ATTRIBUTE_UNSEQUENCED __attribute__((const))
506 # define ATTRIBUTE_UNSEQUENCED /* empty */
510 #if __STDC_VERSION__ < 199901 && !defined restrict
511 # define restrict /* empty */
515 ** Workarounds for compilers/systems.
519 # define EPOCH_LOCAL 0
522 # define EPOCH_OFFSET 0
524 #ifndef RESERVE_STD_EXT_IDS
525 # define RESERVE_STD_EXT_IDS 0
528 /* If standard C identifiers with external linkage (e.g., localtime)
529 are reserved and are not already being renamed anyway, rename them
530 as if compiling with '-Dtime_tz=time_t'. */
531 #if !defined time_tz && RESERVE_STD_EXT_IDS && USE_LTZ
532 # define time_tz time_t
536 ** Compile with -Dtime_tz=T to build the tz package with a private
537 ** time_t type equivalent to T rather than the system-supplied time_t.
538 ** This debugging feature can test unusual design decisions
539 ** (e.g., time_t wider than 'long', or unsigned time_t) even on
540 ** typical platforms.
542 #if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0
548 #if defined LOCALTIME_IMPLEMENTATION && TZ_TIME_T
549 static time_t sys_time(time_t *x) { return time(x); }
554 typedef time_tz tz_time_t;
557 # define asctime tz_asctime
559 # define asctime_r tz_asctime_r
561 # define ctime tz_ctime
563 # define ctime_r tz_ctime_r
565 # define difftime tz_difftime
567 # define gmtime tz_gmtime
569 # define gmtime_r tz_gmtime_r
571 # define localtime tz_localtime
573 # define localtime_r tz_localtime_r
575 # define localtime_rz tz_localtime_rz
577 # define mktime tz_mktime
579 # define mktime_z tz_mktime_z
581 # define offtime tz_offtime
583 # define posix2time tz_posix2time
585 # define posix2time_z tz_posix2time_z
587 # define strftime tz_strftime
589 # define time tz_time
591 # define time2posix tz_time2posix
593 # define time2posix_z tz_time2posix_z
595 # define time_t tz_time_t
597 # define timegm tz_timegm
599 # define timelocal tz_timelocal
601 # define timeoff tz_timeoff
603 # define tzalloc tz_tzalloc
605 # define tzfree tz_tzfree
607 # define tzset tz_tzset
610 # define strftime_l tz_strftime_l
614 # define tzname tz_tzname
618 # define daylight tz_daylight
620 # define timezone tz_timezone
624 # define altzone tz_altzone
627 char *asctime(struct tm const *);
628 char *asctime_r(struct tm const *restrict, char *restrict);
629 char *ctime(time_t const *);
630 char *ctime_r(time_t const *, char *);
631 double difftime(time_t, time_t) ATTRIBUTE_UNSEQUENCED;
632 size_t strftime(char *restrict, size_t, char const *restrict,
633 struct tm const *restrict);
635 size_t strftime_l(char *restrict, size_t, char const *restrict,
636 struct tm const *restrict, locale_t);
638 struct tm *gmtime(time_t const *);
639 struct tm *gmtime_r(time_t const *restrict, struct tm *restrict);
640 struct tm *localtime(time_t const *);
641 struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
642 time_t mktime(struct tm *);
643 time_t time(time_t *);
644 time_t timegm(struct tm *);
648 #ifndef HAVE_DECL_TIMEGM
649 # if (202311 <= __STDC_VERSION__ \
650 || defined __GLIBC__ || defined __tm_zone /* musl */ \
651 || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
652 || (defined __APPLE__ && defined __MACH__))
653 # define HAVE_DECL_TIMEGM true
655 # define HAVE_DECL_TIMEGM false
658 #if !HAVE_DECL_TIMEGM && !defined timegm
659 time_t timegm(struct tm *);
662 #if !HAVE_DECL_ASCTIME_R && !defined asctime_r
663 extern char *asctime_r(struct tm const *restrict, char *restrict);
666 #ifndef HAVE_DECL_ENVIRON
667 # if defined environ || defined __USE_GNU
668 # define HAVE_DECL_ENVIRON 1
670 # define HAVE_DECL_ENVIRON 0
674 #if !HAVE_DECL_ENVIRON
675 extern char **environ;
678 #if 2 <= HAVE_TZNAME + (TZ_TIME_T || !HAVE_POSIX_DECLS)
679 extern char *tzname[];
681 #if 2 <= USG_COMPAT + (TZ_TIME_T || !HAVE_POSIX_DECLS)
682 extern long timezone;
685 #if 2 <= ALTZONE + (TZ_TIME_T || !HAVE_POSIX_DECLS)
690 ** The STD_INSPIRED functions are similar, but most also need
691 ** declarations if time_tz is defined.
695 # if TZ_TIME_T || !defined offtime
696 struct tm *offtime(time_t const *, long);
698 # if TZ_TIME_T || !defined timelocal
699 time_t timelocal(struct tm *);
701 # if TZ_TIME_T || !defined timeoff
702 time_t timeoff(struct tm *, long);
704 # if TZ_TIME_T || !defined time2posix
705 time_t time2posix(time_t);
707 # if TZ_TIME_T || !defined posix2time
708 time_t posix2time(time_t);
712 /* Infer TM_ZONE on systems where this information is known, but suppress
713 guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */
714 #if (defined __GLIBC__ \
715 || defined __tm_zone /* musl */ \
716 || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
717 || (defined __APPLE__ && defined __MACH__))
718 # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
719 # define TM_GMTOFF tm_gmtoff
721 # if !defined TM_ZONE && !defined NO_TM_ZONE
722 # define TM_ZONE tm_zone
727 ** Define functions that are ABI compatible with NetBSD but have
728 ** better prototypes. NetBSD 6.1.4 defines a pointer type timezone_t
729 ** and labors under the misconception that 'const timezone_t' is a
730 ** pointer to a constant. This use of 'const' is ineffective, so it
731 ** is not done here. What we call 'struct state' NetBSD calls
732 ** 'struct __state', but this is a private name so it doesn't matter.
735 typedef struct state *timezone_t;
736 struct tm *localtime_rz(timezone_t restrict, time_t const *restrict,
737 struct tm *restrict);
738 time_t mktime_z(timezone_t restrict, struct tm *restrict);
739 timezone_t tzalloc(char const *);
740 void tzfree(timezone_t);
742 # if TZ_TIME_T || !defined posix2time_z
743 time_t posix2time_z(timezone_t, time_t) ATTRIBUTE_REPRODUCIBLE;
745 # if TZ_TIME_T || !defined time2posix_z
746 time_t time2posix_z(timezone_t, time_t) ATTRIBUTE_REPRODUCIBLE;
752 ** Finally, some convenience items.
755 #define TYPE_BIT(type) (sizeof(type) * CHAR_BIT)
756 #define TYPE_SIGNED(type) (((type) -1) < 0)
757 #define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0)
759 /* Minimum and maximum of two values. Use lower case to avoid
760 naming clashes with standard include files. */
761 #define max(a, b) ((a) > (b) ? (a) : (b))
762 #define min(a, b) ((a) < (b) ? (a) : (b))
764 /* Max and min values of the integer type T, of which only the bottom
765 B bits are used, and where the highest-order used bit is considered
766 to be a sign bit if T is signed. */
767 #define MAXVAL(t, b) \
768 ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
769 - 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
770 #define MINVAL(t, b) \
771 ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
773 /* The extreme time values, assuming no padding. */
774 #define TIME_T_MIN_NO_PADDING MINVAL(time_t, TYPE_BIT(time_t))
775 #define TIME_T_MAX_NO_PADDING MAXVAL(time_t, TYPE_BIT(time_t))
777 /* The extreme time values. These are macros, not constants, so that
778 any portability problems occur only when compiling .c files that use
779 the macros, which is safer for applications that need only zdump and zic.
780 This implementation assumes no padding if time_t is signed and
781 either the compiler lacks support for _Generic or time_t is not one
782 of the standard signed integer types. */
784 # define TIME_T_MIN \
785 _Generic((time_t) 0, \
786 signed char: SCHAR_MIN, short: SHRT_MIN, \
787 int: INT_MIN, long: LONG_MIN, long long: LLONG_MIN, \
788 default: TIME_T_MIN_NO_PADDING)
789 # define TIME_T_MAX \
790 (TYPE_SIGNED(time_t) \
791 ? _Generic((time_t) 0, \
792 signed char: SCHAR_MAX, short: SHRT_MAX, \
793 int: INT_MAX, long: LONG_MAX, long long: LLONG_MAX, \
794 default: TIME_T_MAX_NO_PADDING) \
797 # define TIME_T_MIN TIME_T_MIN_NO_PADDING
798 # define TIME_T_MAX TIME_T_MAX_NO_PADDING
802 ** 302 / 1000 is log10(2.0) rounded up.
803 ** Subtract one for the sign bit if the type is signed;
804 ** add one for integer division truncation;
805 ** add one more for a minus sign if the type is signed.
807 #define INT_STRLEN_MAXIMUM(type) \
808 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
809 1 + TYPE_SIGNED(type))
816 # define INITIALIZE(x) ((x) = 0)
818 # define INITIALIZE(x)
821 /* Whether memory access must strictly follow the C standard.
822 If 0, it's OK to read uninitialized storage so long as the value is
823 not relied upon. Defining it to 0 lets mktime access parts of
824 struct tm that might be uninitialized, as a heuristic when the
825 standard doesn't say what to return and when tm_gmtoff can help
826 mktime likely infer a better value. */
828 # define UNINIT_TRAP 0
833 # define unreachable() abort()
834 #elif !defined unreachable
835 # ifdef __has_builtin
836 # if __has_builtin(__builtin_unreachable)
837 # define unreachable() __builtin_unreachable()
839 # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
840 # define unreachable() __builtin_unreachable()
843 # define unreachable() ((void) 0)
848 ** For the benefit of GNU folk...
849 ** '_(MSGID)' uses the current locale's message library string for MSGID.
850 ** The default is to use gettext if available, and use MSGID otherwise.
854 #define _(msgid) gettext(msgid)
855 #else /* !HAVE_GETTEXT */
856 #define _(msgid) msgid
857 #endif /* !HAVE_GETTEXT */
859 #if !defined TZ_DOMAIN && defined HAVE_GETTEXT
860 # define TZ_DOMAIN "tz"
863 #if HAVE_INCOMPATIBLE_CTIME_R
866 char *asctime_r(struct tm const *, char *);
867 char *ctime_r(time_t const *, char *);
868 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
870 /* Handy macros that are independent of tzfile implementation. */
875 SECSPERHOUR = SECSPERMIN * MINSPERHOUR,
879 DAYSPERLYEAR = DAYSPERNYEAR + 1,
881 YEARSPERREPEAT = 400 /* years before a Gregorian repeat */
884 #define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
886 #define DAYSPERREPEAT ((int_fast32_t) 400 * 365 + 100 - 4 + 1)
887 #define SECSPERREPEAT ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
888 #define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT)
917 TM_WDAY_BASE = TM_MONDAY,
919 EPOCH_WDAY = TM_THURSDAY
922 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
925 ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
926 ** isleap(y) == isleap(y % 400)
928 ** isleap(a + b) == isleap((a + b) % 400)
930 ** isleap(a + b) == isleap(a % 400 + b % 400)
931 ** This is true even if % means modulo rather than Fortran remainder
932 ** (which is allowed by C89 but not by C99 or later).
933 ** We use this to avoid addition overflow problems.
936 #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
938 #endif /* !defined PRIVATE_H */