31 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
38 #ifndef HAVE_DECL_ASCTIME_R
39 #define HAVE_DECL_ASCTIME_R 1
42 #if !defined HAVE_GENERIC && defined __has_extension
43 # if __has_extension(c_generic_selections)
44 # define HAVE_GENERIC 1
46 # define HAVE_GENERIC 0
50 #if !defined HAVE_GENERIC && defined __GNUC__
51 # define HAVE_GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__))
54 # define HAVE_GENERIC (201112 <= __STDC_VERSION__)
58 #define HAVE_GETTEXT 0
61 #ifndef HAVE_INCOMPATIBLE_CTIME_R
62 #define HAVE_INCOMPATIBLE_CTIME_R 0
69 #ifndef HAVE_POSIX_DECLS
70 #define HAVE_POSIX_DECLS 1
73 #ifndef HAVE_STDBOOL_H
74 #define HAVE_STDBOOL_H (199901 <= __STDC_VERSION__)
82 #define HAVE_STRTOLL 1
86 #define HAVE_SYMLINK 1
89 #ifndef HAVE_SYS_STAT_H
90 #define HAVE_SYS_STAT_H 1
93 #ifndef HAVE_SYS_WAIT_H
94 #define HAVE_SYS_WAIT_H 1
98 #define HAVE_UNISTD_H 1
102 #define HAVE_UTMPX_H 1
105 #ifndef NETBSD_INSPIRED
109 #if HAVE_INCOMPATIBLE_CTIME_R
110 #define asctime_r _incompatible_asctime_r
111 #define ctime_r _incompatible_ctime_r
115 #define _GNU_SOURCE 1
117 #define _POSIX_PTHREAD_SEMANTICS 1
119 #define __EXTENSIONS__ 1
123 #ifndef _FILE_OFFSET_BITS
124 # define _FILE_OFFSET_BITS 64
127 #define _LARGE_FILES 1
129 #define _DARWIN_USE_64_BIT_INODE 1
138 #define localtime_rz sys_localtime_rz
139 #define mktime_z sys_mktime_z
140 #define posix2time_z sys_posix2time_z
141 #define time2posix_z sys_time2posix_z
142 #if defined USG_COMPAT && USG_COMPAT == 2
143 # define timezone sys_timezone
145 #define timezone_t sys_timezone_t
146 #define tzalloc sys_tzalloc
147 #define tzfree sys_tzfree
153 #if defined USG_COMPAT && USG_COMPAT == 2
160 #include <sys/types.h>
168 # define ENAMETOOLONG EINVAL
171 # define ENOTSUP EINVAL
174 # define EOVERFLOW EINVAL
185 #ifndef HAVE_STRFTIME_L
186 # if _POSIX_VERSION < 200809
187 # define HAVE_STRFTIME_L 0
189 # define HAVE_STRFTIME_L 1
194 # ifndef _XOPEN_VERSION
195 # define USG_COMPAT 0
197 # define USG_COMPAT 1
202 # if _POSIX_VERSION < 198808 && !USG_COMPAT
203 # define HAVE_TZNAME 0
205 # define HAVE_TZNAME 1
210 # if defined __sun || defined _M_XENIX
222 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
230 #ifndef HAVE_STDINT_H
231 #define HAVE_STDINT_H \
232 (199901 <= __STDC_VERSION__ \
233 || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \
234 || __CYGWIN__ || INTMAX_MAX)
241 #ifndef HAVE_INTTYPES_H
242 # define HAVE_INTTYPES_H HAVE_STDINT_H
245 # include <inttypes.h>
249 #ifdef __LONG_LONG_MAX__
251 # define LLONG_MAX __LONG_LONG_MAX__
254 # define LLONG_MIN (-1 - LLONG_MAX)
258 #ifndef INT_FAST64_MAX
260 typedef long long int_fast64_t;
261 # define INT_FAST64_MIN LLONG_MIN
262 # define INT_FAST64_MAX LLONG_MAX
264 # if LONG_MAX >> 31 < 0xffffffff
265 Please use a compiler that supports a 64-bit integer type (or wider);
266 you may need to compile with
"-DHAVE_STDINT_H".
268 typedef long int_fast64_t;
269 # define INT_FAST64_MIN LONG_MIN
270 # define INT_FAST64_MAX LONG_MAX
275 # if INT_FAST64_MAX == LLONG_MAX
276 # define PRIdFAST64 "lld"
278 # define PRIdFAST64 "ld"
283 # define SCNdFAST64 PRIdFAST64
286 #ifndef INT_FAST32_MAX
287 # if INT_MAX >> 31 == 0
288 typedef long int_fast32_t;
289 # define INT_FAST32_MAX LONG_MAX
290 # define INT_FAST32_MIN LONG_MIN
292 typedef int int_fast32_t;
293 # define INT_FAST32_MAX INT_MAX
294 # define INT_FAST32_MIN INT_MIN
300 typedef long long intmax_t;
302 # define strtoimax strtoll
304 # define INTMAX_MAX LLONG_MAX
305 # define INTMAX_MIN LLONG_MIN
307 typedef long intmax_t;
308 # define INTMAX_MAX LONG_MAX
309 # define INTMAX_MIN LONG_MIN
312 # define strtoimax strtol
317 # if INTMAX_MAX == LLONG_MAX
318 # define PRIdMAX "lld"
320 # define PRIdMAX "ld"
324 #ifndef UINT_FAST64_MAX
325 # if defined ULLONG_MAX || defined __LONG_LONG_MAX__
326 typedef unsigned long long uint_fast64_t;
328 # if ULONG_MAX >> 31 >> 1 < 0xffffffff
329 Please use a compiler that supports a 64-bit integer type (or wider);
330 you may need to compile with
"-DHAVE_STDINT_H".
332 typedef unsigned long uint_fast64_t;
337 # if defined ULLONG_MAX || defined __LONG_LONG_MAX__
338 typedef unsigned long long uintmax_t;
340 typedef unsigned long uintmax_t;
345 # if defined ULLONG_MAX || defined __LONG_LONG_MAX__
346 # define PRIuMAX "llu"
348 # define PRIuMAX "lu"
353 #define INT32_MAX 0x7fffffff
356 #define INT32_MIN (-1 - INT32_MAX)
360 #define SIZE_MAX ((size_t) -1)
364 # define ATTRIBUTE_CONST __attribute__ ((const))
365 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
366 # define ATTRIBUTE_PURE __attribute__ ((__pure__))
367 # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
369 # define ATTRIBUTE_CONST
370 # define ATTRIBUTE_MALLOC
371 # define ATTRIBUTE_PURE
372 # define ATTRIBUTE_FORMAT(spec)
375 #if !defined _Noreturn && __STDC_VERSION__ < 201112
376 # if 2 < __GNUC__ + (8 <= __GNUC_MINOR__)
377 # define _Noreturn __attribute__ ((__noreturn__))
383 #if __STDC_VERSION__ < 199901 && !defined restrict
392 # define EPOCH_LOCAL 0
395 # define EPOCH_OFFSET 0
397 #ifndef RESERVE_STD_EXT_IDS
398 # define RESERVE_STD_EXT_IDS 0
404 #if !defined time_tz && RESERVE_STD_EXT_IDS && USE_LTZ
405 # define time_tz time_t
415 #if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0
422 # ifdef LOCALTIME_IMPLEMENTATION
423 static time_t sys_time(time_t *x) {
return time(x); }
426 typedef time_tz tz_time_t;
429 # define asctime tz_asctime
431 # define asctime_r tz_asctime_r
433 # define ctime tz_ctime
435 # define ctime_r tz_ctime_r
437 # define difftime tz_difftime
439 # define gmtime tz_gmtime
441 # define gmtime_r tz_gmtime_r
443 # define localtime tz_localtime
445 # define localtime_r tz_localtime_r
447 # define localtime_rz tz_localtime_rz
449 # define mktime tz_mktime
451 # define mktime_z tz_mktime_z
453 # define offtime tz_offtime
455 # define posix2time tz_posix2time
457 # define posix2time_z tz_posix2time_z
459 # define strftime tz_strftime
461 # define time tz_time
463 # define time2posix tz_time2posix
465 # define time2posix_z tz_time2posix_z
467 # define time_t tz_time_t
469 # define timegm tz_timegm
471 # define timelocal tz_timelocal
473 # define timeoff tz_timeoff
475 # define tzalloc tz_tzalloc
477 # define tzfree tz_tzfree
479 # define tzset tz_tzset
481 # define tzsetwall tz_tzsetwall
484 # define strftime_l tz_strftime_l
488 # define tzname tz_tzname
492 # define daylight tz_daylight
494 # define timezone tz_timezone
498 # define altzone tz_altzone
501 char *asctime(
struct tm
const *);
502 char *asctime_r(
struct tm
const *restrict,
char *restrict);
503 char *ctime(time_t
const *);
504 char *ctime_r(time_t
const *,
char *);
505 double difftime(time_t, time_t) ATTRIBUTE_CONST;
506 size_t strftime(
char *restrict,
size_t,
char const *restrict,
507 struct tm
const *restrict);
509 size_t strftime_l(
char *restrict,
size_t,
char const *restrict,
510 struct tm
const *restrict, locale_t);
512 struct tm *gmtime(time_t
const *);
513 struct tm *gmtime_r(time_t
const *restrict,
struct tm *restrict);
514 struct tm *localtime(time_t
const *);
515 struct tm *localtime_r(time_t
const *restrict,
struct tm *restrict);
516 time_t mktime(
struct tm *);
517 time_t time(time_t *);
521 #if !HAVE_DECL_ASCTIME_R && !defined asctime_r
522 extern char *asctime_r(
struct tm
const *restrict,
char *restrict);
525 #ifndef HAVE_DECL_ENVIRON
526 # if defined environ || defined __USE_GNU
527 # define HAVE_DECL_ENVIRON 1
529 # define HAVE_DECL_ENVIRON 0
533 #if !HAVE_DECL_ENVIRON
534 extern char **environ;
537 #if 2 <= HAVE_TZNAME + (TZ_TIME_T || !HAVE_POSIX_DECLS)
538 extern char *tzname[];
540 #if 2 <= USG_COMPAT + (TZ_TIME_T || !HAVE_POSIX_DECLS)
541 extern long timezone;
544 #if 2 <= ALTZONE + (TZ_TIME_T || !HAVE_POSIX_DECLS)
554 # if TZ_TIME_T || !defined tzsetwall
555 void tzsetwall(
void);
557 # if TZ_TIME_T || !defined offtime
558 struct tm *offtime(time_t
const *,
long);
560 # if TZ_TIME_T || !defined timegm
561 time_t timegm(
struct tm *);
563 # if TZ_TIME_T || !defined timelocal
564 time_t timelocal(
struct tm *);
566 # if TZ_TIME_T || !defined timeoff
567 time_t timeoff(
struct tm *,
long);
569 # if TZ_TIME_T || !defined time2posix
570 time_t time2posix(time_t);
572 # if TZ_TIME_T || !defined posix2time
573 time_t posix2time(time_t);
579 #if (defined __GLIBC__ \
580 || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
581 || (defined __APPLE__ && defined __MACH__))
582 # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
583 # define TM_GMTOFF tm_gmtoff
585 # if !defined TM_ZONE && !defined NO_TM_ZONE
586 # define TM_ZONE tm_zone
599 typedef struct state *timezone_t;
600 struct tm *localtime_rz(timezone_t restrict, time_t
const *restrict,
601 struct tm *restrict);
602 time_t mktime_z(timezone_t restrict,
struct tm *restrict);
603 timezone_t tzalloc(
char const *);
604 void tzfree(timezone_t);
606 # if TZ_TIME_T || !defined posix2time_z
607 time_t posix2time_z(timezone_t, time_t) ATTRIBUTE_PURE;
609 # if TZ_TIME_T || !defined time2posix_z
610 time_t time2posix_z(timezone_t, time_t) ATTRIBUTE_PURE;
620 # include <stdbool.h>
627 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
628 #define TYPE_SIGNED(type) (((type) -1) < 0)
629 #define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0)
634 #define MAXVAL(t, b) \
635 ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
636 - 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
637 #define MINVAL(t, b) \
638 ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
641 #define TIME_T_MIN_NO_PADDING MINVAL(time_t, TYPE_BIT(time_t))
642 #define TIME_T_MAX_NO_PADDING MAXVAL(time_t, TYPE_BIT(time_t))
651 # define TIME_T_MIN \
652 _Generic((time_t) 0, \
653 signed char: SCHAR_MIN, short: SHRT_MIN, \
654 int: INT_MIN, long: LONG_MIN, long long: LLONG_MIN, \
655 default: TIME_T_MIN_NO_PADDING)
656 # define TIME_T_MAX \
657 (TYPE_SIGNED(time_t) \
658 ? _Generic((time_t) 0, \
659 signed char: SCHAR_MAX, short: SHRT_MAX, \
660 int: INT_MAX, long: LONG_MAX, long long: LLONG_MAX, \
661 default: TIME_T_MAX_NO_PADDING) \
664 # define TIME_T_MIN TIME_T_MIN_NO_PADDING
665 # define TIME_T_MAX TIME_T_MAX_NO_PADDING
674 #define INT_STRLEN_MAXIMUM(type) \
675 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
676 1 + TYPE_SIGNED(type))
683 # define INITIALIZE(x) ((x) = 0)
685 # define INITIALIZE(x)
689 # define UNINIT_TRAP 0
699 #define _(msgid) gettext(msgid)
701 #define _(msgid) msgid
704 #if !defined TZ_DOMAIN && defined HAVE_GETTEXT
705 # define TZ_DOMAIN "tz"
708 #if HAVE_INCOMPATIBLE_CTIME_R
711 char *asctime_r(
struct tm
const *,
char *);
712 char *ctime_r(time_t
const *,
char *);
717 #define YEARSPERREPEAT 400
719 #define SECSPERMIN 60
720 #define MINSPERHOUR 60
721 #define HOURSPERDAY 24
722 #define DAYSPERWEEK 7
723 #define DAYSPERNYEAR 365
724 #define DAYSPERLYEAR 366
725 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
726 #define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
727 #define MONSPERYEAR 12
732 #define TM_WEDNESDAY 3
733 #define TM_THURSDAY 4
735 #define TM_SATURDAY 6
738 #define TM_FEBRUARY 1
745 #define TM_SEPTEMBER 8
747 #define TM_NOVEMBER 10
748 #define TM_DECEMBER 11
750 #define TM_YEAR_BASE 1900
752 #define EPOCH_YEAR 1970
753 #define EPOCH_WDAY TM_THURSDAY
755 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
769 #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
776 #define AVGSECSPERYEAR 31556952L
777 #define SECSPERREPEAT \
778 ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
779 #define SECSPERREPEAT_BITS 34