Commit | Line | Data |
806a119a |
1 | #include <time.h> |
b86b480f |
2 | #include "time64_config.h" |
806a119a |
3 | |
b86b480f |
4 | #ifndef TIME64_H |
5 | # define TIME64_H |
a272e669 |
6 | |
948ea7a9 |
7 | |
b86b480f |
8 | /* Set our custom types */ |
9 | typedef INT_64_T Int64; |
10 | typedef Int64 Time64_T; |
d95a2ea5 |
11 | typedef I32 Year; |
948ea7a9 |
12 | |
806a119a |
13 | |
14 | /* A copy of the tm struct but with a 64 bit year */ |
15 | struct TM64 { |
16 | int tm_sec; |
17 | int tm_min; |
18 | int tm_hour; |
19 | int tm_mday; |
20 | int tm_mon; |
21 | Year tm_year; |
22 | int tm_wday; |
23 | int tm_yday; |
24 | int tm_isdst; |
25 | |
26 | #ifdef HAS_TM_TM_GMTOFF |
27 | long tm_gmtoff; |
28 | #endif |
29 | |
30 | #ifdef HAS_TM_TM_ZONE |
b02dc803 |
31 | # ifdef __GLIBC__ |
a8cb0261 |
32 | const char *tm_zone; |
b02dc803 |
33 | # else |
34 | char *tm_zone; |
35 | # endif |
806a119a |
36 | #endif |
37 | }; |
a272e669 |
38 | |
948ea7a9 |
39 | |
b86b480f |
40 | /* Decide which tm struct to use */ |
41 | #ifdef USE_TM64 |
42 | #define TM TM64 |
43 | #else |
44 | #define TM tm |
45 | #endif |
46 | |
47 | |
7430375d |
48 | /* Declare functions */ |
49 | static struct TM *S_gmtime64_r (const Time64_T *, struct TM *); |
50 | static struct TM *S_localtime64_r (const Time64_T *, struct TM *); |
51 | static Time64_T S_timegm64 (struct TM *); |
b86b480f |
52 | |
53 | |
54 | /* Not everyone has gm/localtime_r(), provide a replacement */ |
948ea7a9 |
55 | #ifdef HAS_LOCALTIME_R |
4c6e94b1 |
56 | # define LOCALTIME_R(clock, result) (L_R_TZSET localtime_r(clock, result)) |
948ea7a9 |
57 | #else |
7430375d |
58 | # define LOCALTIME_R(clock, result) (L_R_TZSET S_localtime_r(clock, result)) |
948ea7a9 |
59 | #endif |
60 | #ifdef HAS_GMTIME_R |
61 | # define GMTIME_R(clock, result) gmtime_r(clock, result) |
62 | #else |
7430375d |
63 | # define GMTIME_R(clock, result) S_gmtime_r(clock, result) |
948ea7a9 |
64 | #endif |
65 | |
a272e669 |
66 | #endif |