Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Eliminate the extreme bletcherousness which is declaring the tm structs.

Apparently the missing magic was "static".
  • Loading branch information...
commit 247f449fc26b6edbf7876a8f028722632dc25d8c 1 parent 1f754ce
@schwern authored
Showing with 123 additions and 181 deletions.
  1. +64 −56 perl/Time-y2038/y2038/time64_limits.h.in
  2. +0 −74 time64.c
  3. +59 −51 time64_limits.h
View
120 perl/Time-y2038/y2038/time64_limits.h.in
@@ -17,72 +17,80 @@
#define SYSTEM_GMTIME_MIN %%gmtime_min%%
/* Max/min for mktime() */
-#define SYSTEM_MKTIME_MAX_TM_SEC %%mktime_max_tm_sec%%
-#define SYSTEM_MKTIME_MAX_TM_MIN %%mktime_max_tm_min%%
-#define SYSTEM_MKTIME_MAX_TM_HOUR %%mktime_max_tm_hour%%
-#define SYSTEM_MKTIME_MAX_TM_MDAY %%mktime_max_tm_mday%%
-#define SYSTEM_MKTIME_MAX_TM_MON %%mktime_max_tm_mon%%
-#define SYSTEM_MKTIME_MAX_TM_YEAR %%mktime_max_tm_year%%
-#define SYSTEM_MKTIME_MAX_TM_WDAY %%mktime_max_tm_wday%%
-#define SYSTEM_MKTIME_MAX_TM_YDAY %%mktime_max_tm_yday%%
-#define SYSTEM_MKTIME_MAX_TM_ISDST %%mktime_max_tm_isdst%%
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MAX_TM_ZONE "%%mktime_max_tm_zone%%"
-#endif
+static const struct tm SYSTEM_MKTIME_MAX = {
+ %%mktime_max_tm_sec%%,
+ %%mktime_max_tm_min%%,
+ %%mktime_max_tm_hour%%,
+ %%mktime_max_tm_mday%%,
+ %%mktime_max_tm_mon%%,
+ %%mktime_max_tm_year%%,
+ %%mktime_max_tm_wday%%,
+ %%mktime_max_tm_yday%%,
+ %%mktime_max_tm_isdst%%
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MAX_TM_GMTOFF %%mktime_max_tm_gmtoff%%
+ ,%%mktime_max_tm_gmtoff%%
#endif
-
-#define SYSTEM_MKTIME_MIN_TM_SEC %%mktime_min_tm_sec%%
-#define SYSTEM_MKTIME_MIN_TM_MIN %%mktime_min_tm_min%%
-#define SYSTEM_MKTIME_MIN_TM_HOUR %%mktime_min_tm_hour%%
-#define SYSTEM_MKTIME_MIN_TM_MDAY %%mktime_min_tm_mday%%
-#define SYSTEM_MKTIME_MIN_TM_MON %%mktime_min_tm_mon%%
-#define SYSTEM_MKTIME_MIN_TM_YEAR %%mktime_min_tm_year%%
-#define SYSTEM_MKTIME_MIN_TM_WDAY %%mktime_min_tm_wday%%
-#define SYSTEM_MKTIME_MIN_TM_YDAY %%mktime_min_tm_yday%%
-#define SYSTEM_MKTIME_MIN_TM_ISDST %%mktime_min_tm_isdst%%
#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MIN_TM_ZONE "%%mktime_min_tm_zone%%"
+ ,"%%mktime_max_tm_zone%%"
#endif
+};
+
+static const struct tm SYSTEM_MKTIME_MIN = {
+ %%mktime_min_tm_sec%%,
+ %%mktime_min_tm_min%%,
+ %%mktime_min_tm_hour%%,
+ %%mktime_min_tm_mday%%,
+ %%mktime_min_tm_mon%%,
+ %%mktime_min_tm_year%%,
+ %%mktime_min_tm_wday%%,
+ %%mktime_min_tm_yday%%,
+ %%mktime_min_tm_isdst%%
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MIN_TM_GMTOFF %%mktime_min_tm_gmtoff%%
+ ,%%mktime_min_tm_gmtoff%%
#endif
+#ifdef HAS_TM_TM_ZONE
+ ,"%%mktime_min_tm_zone%%"
+#endif
+};
/* Max/min for timegm() */
#ifdef HAS_TIMEGM
- #define SYSTEM_TIMEGM_MAX_TM_SEC %%timegm_max_tm_sec%%
- #define SYSTEM_TIMEGM_MAX_TM_MIN %%timegm_max_tm_min%%
- #define SYSTEM_TIMEGM_MAX_TM_HOUR %%timegm_max_tm_hour%%
- #define SYSTEM_TIMEGM_MAX_TM_MDAY %%timegm_max_tm_mday%%
- #define SYSTEM_TIMEGM_MAX_TM_MON %%timegm_max_tm_mon%%
- #define SYSTEM_TIMEGM_MAX_TM_YEAR %%timegm_max_tm_year%%
- #define SYSTEM_TIMEGM_MAX_TM_WDAY %%timegm_max_tm_wday%%
- #define SYSTEM_TIMEGM_MAX_TM_YDAY %%timegm_max_tm_yday%%
- #define SYSTEM_TIMEGM_MAX_TM_ISDST %%timegm_max_tm_isdst%%
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MAX_TM_ZONE "%%timegm_max_tm_zone%%"
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MAX_TM_GMTOFF %%timegm_max_tm_gmtoff%%
- #endif
-
- #define SYSTEM_TIMEGM_MIN_TM_SEC %%timegm_min_tm_sec%%
- #define SYSTEM_TIMEGM_MIN_TM_MIN %%timegm_min_tm_min%%
- #define SYSTEM_TIMEGM_MIN_TM_HOUR %%timegm_min_tm_hour%%
- #define SYSTEM_TIMEGM_MIN_TM_MDAY %%timegm_min_tm_mday%%
- #define SYSTEM_TIMEGM_MIN_TM_MON %%timegm_min_tm_mon%%
- #define SYSTEM_TIMEGM_MIN_TM_YEAR %%timegm_min_tm_year%%
- #define SYSTEM_TIMEGM_MIN_TM_WDAY %%timegm_min_tm_wday%%
- #define SYSTEM_TIMEGM_MIN_TM_YDAY %%timegm_min_tm_yday%%
- #define SYSTEM_TIMEGM_MIN_TM_ISDST %%timegm_min_tm_isdst%%
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MIN_TM_ZONE "%%timegm_min_tm_zone%%"
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MIN_TM_GMTOFF %%timegm_min_tm_gmtoff%%
- #endif
+static const struct tm SYSTEM_TIMEGM_MAX = {
+ %%timegm_max_tm_sec%%,
+ %%timegm_max_tm_min%%,
+ %%timegm_max_tm_hour%%,
+ %%timegm_max_tm_mday%%,
+ %%timegm_max_tm_mon%%,
+ %%timegm_max_tm_year%%,
+ %%timegm_max_tm_wday%%,
+ %%timegm_max_tm_yday%%,
+ %%timegm_max_tm_isdst%%
+#ifdef HAS_TM_TM_GMTOFF
+ ,%%timegm_max_tm_gmtoff%%
+#endif
+#ifdef HAS_TM_TM_ZONE
+ ,"%%timegm_max_tm_zone%%"
+#endif
+};
+
+static const struct tm SYSTEM_TIMEGM_MIN = {
+ %%timegm_min_tm_sec%%,
+ %%timegm_min_tm_min%%,
+ %%timegm_min_tm_hour%%,
+ %%timegm_min_tm_mday%%,
+ %%timegm_min_tm_mon%%,
+ %%timegm_min_tm_year%%,
+ %%timegm_min_tm_wday%%,
+ %%timegm_min_tm_yday%%,
+ %%timegm_min_tm_isdst%%
+#ifdef HAS_TM_TM_GMTOFF
+ ,%%timegm_min_tm_gmtoff%%
+#endif
+#ifdef HAS_TM_TM_ZONE
+ ,"%%timegm_min_tm_zone%%"
#endif
+};
+#endif /* HAS_TIMEGM */
#endif /* TIME64_LIMITS_H */
View
74 time64.c
@@ -48,80 +48,6 @@ gmtime64_r() is a 64-bit equivalent of gmtime_r().
#include "time64.h"
#include "time64_limits.h"
-struct tm SYSTEM_MKTIME_MAX = {
-SYSTEM_MKTIME_MAX_TM_SEC,
-SYSTEM_MKTIME_MAX_TM_MIN,
-SYSTEM_MKTIME_MAX_TM_HOUR,
-SYSTEM_MKTIME_MAX_TM_MDAY,
-SYSTEM_MKTIME_MAX_TM_MON,
-SYSTEM_MKTIME_MAX_TM_YEAR,
-SYSTEM_MKTIME_MAX_TM_WDAY,
-SYSTEM_MKTIME_MAX_TM_YDAY,
-SYSTEM_MKTIME_MAX_TM_ISDST
-#ifdef HAS_TM_TM_GMTOFF
-,SYSTEM_MKTIME_MAX_TM_GMTOFF
-#endif
-#ifdef HAS_TM_TM_ZONE
-,SYSTEM_MKTIME_MAX_TM_ZONE
-#endif
-};
-
-const struct tm SYSTEM_MKTIME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EGM_MIN_TM_ISDST
-#ifdef HAS_TM_TM_GMTOFF
-,SYSTEM_TIMEGM_MIN_TM_GMTOFF
-#endif
-#ifdef HAS_TM_TM_ZONE
-,SYSTEM_TIMEGM_MIN_TM_ZONE
-#endif
-};
-#endif /* HAS_TIMEGM */
-
/* Spec says except for stftime() and the _r() functions, these
all return static memory. Stabbings! */
View
110 time64_limits.h
@@ -17,71 +17,79 @@
#define SYSTEM_GMTIME_MIN -2147483647-1
/* Max/min for mktime() */
-#define SYSTEM_MKTIME_MAX_TM_SEC 7
-#define SYSTEM_MKTIME_MAX_TM_MIN 14
-#define SYSTEM_MKTIME_MAX_TM_HOUR 19
-#define SYSTEM_MKTIME_MAX_TM_MDAY 18
-#define SYSTEM_MKTIME_MAX_TM_MON 0
-#define SYSTEM_MKTIME_MAX_TM_YEAR 138
-#define SYSTEM_MKTIME_MAX_TM_WDAY 1
-#define SYSTEM_MKTIME_MAX_TM_YDAY 17
-#define SYSTEM_MKTIME_MAX_TM_ISDST 0
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MAX_TM_ZONE "PST"
-#endif
+static const struct tm SYSTEM_MKTIME_MAX = {
+ 7,
+ 14,
+ 19,
+ 18,
+ 0,
+ 138,
+ 1,
+ 17,
+ 0
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MAX_TM_GMTOFF -28800
+ ,-28800
#endif
-
-#define SYSTEM_MKTIME_MIN_TM_SEC 52
-#define SYSTEM_MKTIME_MIN_TM_MIN 45
-#define SYSTEM_MKTIME_MIN_TM_HOUR 12
-#define SYSTEM_MKTIME_MIN_TM_MDAY 13
-#define SYSTEM_MKTIME_MIN_TM_MON 11
-#define SYSTEM_MKTIME_MIN_TM_YEAR 1
-#define SYSTEM_MKTIME_MIN_TM_WDAY 5
-#define SYSTEM_MKTIME_MIN_TM_YDAY 346
-#define SYSTEM_MKTIME_MIN_TM_ISDST 0
#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MIN_TM_ZONE "PST"
+ ,"PST"
#endif
+};
+
+static const struct tm SYSTEM_MKTIME_MIN = {
+ 52,
+ 45,
+ 12,
+ 13,
+ 11,
+ 1,
+ 5,
+ 346,
+ 0
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MIN_TM_GMTOFF -28800
+ ,-28800
#endif
+#ifdef HAS_TM_TM_ZONE
+ ,"PST"
+#endif
+};
/* Max/min for timegm() */
#ifdef HAS_TIMEGM
- #define SYSTEM_TIMEGM_MAX_TM_SEC 7
- #define SYSTEM_TIMEGM_MAX_TM_MIN 14
- #define SYSTEM_TIMEGM_MAX_TM_HOUR 3
- #define SYSTEM_TIMEGM_MAX_TM_MDAY 19
- #define SYSTEM_TIMEGM_MAX_TM_MON 0
- #define SYSTEM_TIMEGM_MAX_TM_YEAR 138
- #define SYSTEM_TIMEGM_MAX_TM_WDAY 2
- #define SYSTEM_TIMEGM_MAX_TM_YDAY 18
- #define SYSTEM_TIMEGM_MAX_TM_ISDST 0
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MAX_TM_ZONE "UTC"
- #endif
+static const struct tm SYSTEM_TIMEGM_MAX = {
+ 7,
+ 14,
+ 3,
+ 19,
+ 0,
+ 138,
+ 2,
+ 18,
+ 0
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MAX_TM_GMTOFF 0
+ ,0
#endif
-
- #define SYSTEM_TIMEGM_MIN_TM_SEC 52
- #define SYSTEM_TIMEGM_MIN_TM_MIN 45
- #define SYSTEM_TIMEGM_MIN_TM_HOUR 20
- #define SYSTEM_TIMEGM_MIN_TM_MDAY 13
- #define SYSTEM_TIMEGM_MIN_TM_MON 11
- #define SYSTEM_TIMEGM_MIN_TM_YEAR 1
- #define SYSTEM_TIMEGM_MIN_TM_WDAY 5
- #define SYSTEM_TIMEGM_MIN_TM_YDAY 346
- #define SYSTEM_TIMEGM_MIN_TM_ISDST 0
#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MIN_TM_ZONE "UTC"
+ ,"UTC"
#endif
+};
+
+static const struct tm SYSTEM_TIMEGM_MIN = {
+ 52,
+ 45,
+ 20,
+ 13,
+ 11,
+ 1,
+ 5,
+ 346,
+ 0
#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MIN_TM_GMTOFF 0
+ ,0
#endif
-#endif
+ #ifdef HAS_TM_TM_ZONE
+ ,"UTC"
+ #endif
+};
+#endif /* HAS_TIMEGM */
#endif /* TIME64_LIMITS_H */
Please sign in to comment.
Something went wrong with that request. Please try again.