summaryrefslogtreecommitdiff
path: root/private.h
diff options
context:
space:
mode:
Diffstat (limited to 'private.h')
-rw-r--r--private.h44
1 files changed, 36 insertions, 8 deletions
diff --git a/private.h b/private.h
index 838ab2b2df8f..0dac6af4e3cb 100644
--- a/private.h
+++ b/private.h
@@ -18,11 +18,15 @@
*/
/* PORT_TO_C89 means the code should work even if the underlying
- compiler and library support only C89. SUPPORT_C89 means the
+ 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. These macros are obsolescent,
+ 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. */
+ 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
@@ -70,9 +74,7 @@
#endif
#if !defined HAVE__GENERIC && defined __has_extension
-# if __has_extension(c_generic_selections)
-# define HAVE__GENERIC 1
-# else
+# if !__has_extension(c_generic_selections)
# define HAVE__GENERIC 0
# endif
#endif
@@ -754,7 +756,7 @@ struct tm *offtime(time_t const *, long);
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);
@@ -766,7 +768,8 @@ 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__))
@@ -896,6 +899,19 @@ static_assert(! TYPE_SIGNED(time_t) || ! SIGNED_PADDING_CHECK_NEEDED
# define UNINIT_TRAP 0
#endif
+/* localtime.c sometimes needs access to timeoff if it is not already public.
+ tz_private_timeoff should be used only by localtime.c. */
+#if (!defined EXTERN_TIMEOFF \
+ && defined TM_GMTOFF && (200809 < _POSIX_VERSION || ! UNINIT_TRAP))
+# ifndef timeoff
+# define timeoff tz_private_timeoff
+# endif
+# define EXTERN_TIMEOFF
+#endif
+#ifdef EXTERN_TIMEOFF
+time_t timeoff(struct tm *, long);
+#endif
+
#ifdef DEBUG
# undef unreachable
# define unreachable() abort()
@@ -955,6 +971,18 @@ enum {
#define SECSPERREPEAT ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
#define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT)
+/* How many years to generate (in zic.c) or search through (in localtime.c).
+ This is two years larger than the obvious 400, to avoid edge cases.
+ E.g., suppose a non-POSIX.1-2017 rule applies from 2012 on with transitions
+ in March and September, plus one-off transitions in November 2013.
+ If zic looked only at the last 400 years, it would set max_year=2413,
+ with the intent that the 400 years 2014 through 2413 will be repeated.
+ The last transition listed in the tzfile would be in 2413-09,
+ less than 400 years after the last one-off transition in 2013-11.
+ Two years is not overkill for localtime.c, as a one-year bump
+ would mishandle 2023d's America/Ciudad_Juarez for November 2422. */
+enum { years_of_observations = YEARSPERREPEAT + 2 };
+
enum {
TM_SUNDAY,
TM_MONDAY,