This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove the AIX work around code. Instead it should just set it's LOCALTIME_MAX to...
[perl5.git] / time64.h
1 #include <time.h>
2
3 #ifndef LOCALTIME64_H
4 #    define LOCALTIME64_H
5
6 /* Configuration. */
7 /* Define as appropriate for your system */
8 /*
9    HAS_GMTIME_R
10    Defined if your system has gmtime_r()
11
12    HAS_LOCALTIME_R
13    Defined if your system has localtime_r()
14
15    HAS_TIMEGM
16    Defined if your system has timegm()
17
18    HAS_TM_TM_GMTOFF
19    Defined if your tm struct has a "tm_gmtoff" element.
20
21    HAS_TM_TM_ZONE
22    Defined if your tm struct has a "tm_zone" element.
23
24    SYSTEM_LOCALTIME_MAX
25    SYSTEM_LOCALTIME_MIN
26    SYSTEM_GMTIME_MAX
27    SYSTEM_GMTIME_MIN
28    Maximum and minimum values your system's gmtime() and localtime()
29    can handle.
30
31    USE_SYSTEM_LOCALTIME
32    USE_SYSTEM_GMTIME
33    Should we use the system functions if the time is inside their range?
34
35    USE_TM64
36    Should we use a 64 bit safe tm struct which can handle a
37    year range greater than 2 billion?
38 */
39
40 #define SYSTEM_LOCALTIME_MAX    LOCALTIME_MAX
41 #define SYSTEM_LOCALTIME_MIN    LOCALTIME_MIN
42 #define SYSTEM_GMTIME_MAX       GMTIME_MAX
43 #define SYSTEM_GMTIME_MIN       GMTIME_MIN
44
45 /* It'll be faster */
46 #define USE_SYSTEM_LOCALTIME    1
47 #define USE_SYSTEM_GMTIME       1
48
49 /* Let's get all the time */
50 #define USE_TM64
51
52 #ifdef USE_TM64
53 #define TM      TM64
54 #else
55 #define TM      tm
56 #endif
57
58 /* 64 bit types.  Set as appropriate for your system. */
59 typedef Quad_t               Time64_T;
60 typedef Quad_t               Int64;
61 typedef Int64                Year;
62
63 struct TM *gmtime64_r    (const Time64_T *, struct TM *);
64 struct TM *localtime64_r (const Time64_T *, struct TM *);
65 Time64_T   timegm64      (struct TM *);
66
67 /* A copy of the tm struct but with a 64 bit year */
68 struct TM64 {
69         int     tm_sec;
70         int     tm_min;
71         int     tm_hour;
72         int     tm_mday;
73         int     tm_mon;
74         Year    tm_year;
75         int     tm_wday;
76         int     tm_yday;
77         int     tm_isdst;
78
79 #ifdef HAS_TM_TM_GMTOFF
80         long    tm_gmtoff;
81 #endif
82
83 #ifdef HAS_TM_TM_ZONE
84         char    *tm_zone;
85 #endif
86 };
87
88
89 /* Not everyone has gm/localtime_r() */
90 #ifdef HAS_LOCALTIME_R
91 #    define LOCALTIME_R(clock, result) localtime_r(clock, result)
92 #else
93 #    define LOCALTIME_R(clock, result) fake_localtime_r(clock, result)
94 #endif
95 #ifdef HAS_GMTIME_R
96 #    define GMTIME_R(clock, result)    gmtime_r(clock, result)
97 #else
98 #    define GMTIME_R(clock, result)    fake_gmtime_r(clock, result)
99 #endif
100
101 #endif