summaryrefslogtreecommitdiff
path: root/time64.h
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2008-10-04 15:12:50 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-01-03 18:39:12 +0100
commitb86b480f7301a8816081189c89b366a79ab9909f (patch)
treeb8b70910ac882634e38c6c09f77e3c7a3e66f30d /time64.h
parent8efababc2f87779325166ff9fd8b47cde3763a95 (diff)
downloadperl-b86b480f7301a8816081189c89b366a79ab9909f.tar.gz
Update from y2038
Configuration information split out into its own header. Added files to MANIFEST Turn off USE_SYSTEM_GMTIME, ours is more reliable and possibly faster. Fix type warnings found on Windows. Remove unnecessary use of floor() and ceil().
Diffstat (limited to 'time64.h')
-rw-r--r--time64.h83
1 files changed, 22 insertions, 61 deletions
diff --git a/time64.h b/time64.h
index 85e2ff59a6..e8c649b866 100644
--- a/time64.h
+++ b/time64.h
@@ -1,68 +1,15 @@
#include <time.h>
+#include "time64_config.h"
-#ifndef LOCALTIME64_H
-# define LOCALTIME64_H
+#ifndef TIME64_H
+# define TIME64_H
-/* Configuration. */
-/* Define as appropriate for your system */
-/*
- HAS_GMTIME_R
- Defined if your system has gmtime_r()
- HAS_LOCALTIME_R
- Defined if your system has localtime_r()
+/* Set our custom types */
+typedef INT_64_T Int64;
+typedef Int64 Time64_T;
+typedef Int64 Year;
- HAS_TIMEGM
- Defined if your system has timegm()
-
- HAS_TM_TM_GMTOFF
- Defined if your tm struct has a "tm_gmtoff" element.
-
- HAS_TM_TM_ZONE
- Defined if your tm struct has a "tm_zone" element.
-
- SYSTEM_LOCALTIME_MAX
- SYSTEM_LOCALTIME_MIN
- SYSTEM_GMTIME_MAX
- SYSTEM_GMTIME_MIN
- Maximum and minimum values your system's gmtime() and localtime()
- can handle.
-
- USE_SYSTEM_LOCALTIME
- USE_SYSTEM_GMTIME
- Should we use the system functions if the time is inside their range?
-
- USE_TM64
- Should we use a 64 bit safe tm struct which can handle a
- year range greater than 2 billion?
-*/
-
-#define SYSTEM_LOCALTIME_MAX LOCALTIME_MAX
-#define SYSTEM_LOCALTIME_MIN LOCALTIME_MIN
-#define SYSTEM_GMTIME_MAX GMTIME_MAX
-#define SYSTEM_GMTIME_MIN GMTIME_MIN
-
-/* It'll be faster */
-#define USE_SYSTEM_LOCALTIME 1
-#define USE_SYSTEM_GMTIME 1
-
-/* Let's get all the time */
-#define USE_TM64
-
-#ifdef USE_TM64
-#define TM TM64
-#else
-#define TM tm
-#endif
-
-/* 64 bit types. Set as appropriate for your system. */
-typedef Quad_t Time64_T;
-typedef Quad_t Int64;
-typedef Int64 Year;
-
-struct TM *gmtime64_r (const Time64_T *, struct TM *);
-struct TM *localtime64_r (const Time64_T *, struct TM *);
-Time64_T timegm64 (struct TM *);
/* A copy of the tm struct but with a 64 bit year */
struct TM64 {
@@ -86,7 +33,21 @@ struct TM64 {
};
-/* Not everyone has gm/localtime_r() */
+/* Decide which tm struct to use */
+#ifdef USE_TM64
+#define TM TM64
+#else
+#define TM tm
+#endif
+
+
+/* Declare public functions */
+struct TM *gmtime64_r (const Time64_T *, struct TM *);
+struct TM *localtime64_r (const Time64_T *, struct TM *);
+Time64_T timegm64 (struct TM *);
+
+
+/* Not everyone has gm/localtime_r(), provide a replacement */
#ifdef HAS_LOCALTIME_R
# define LOCALTIME_R(clock, result) localtime_r(clock, result)
#else