RE: [PATCH] compress 2.018
[p5sagit/p5-mst-13.2.git] / time64.h
1 #include <time.h>
2 #include "time64_config.h"
3
4 #ifndef TIME64_H
5 #    define TIME64_H
6
7
8 /* Set our custom types */
9 typedef INT_64_T        Int64;
10 typedef Int64           Time64_T;
11 typedef I32             Year;
12
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
31 #  ifdef __GLIBC__
32         const char    *tm_zone;
33 #  else
34         char    *tm_zone;
35 #  endif
36 #endif
37 };
38
39
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
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 *);
52
53
54 /* Not everyone has gm/localtime_r(), provide a replacement */
55 #ifdef HAS_LOCALTIME_R
56 #    define LOCALTIME_R(clock, result) (L_R_TZSET localtime_r(clock, result))
57 #else
58 #    define LOCALTIME_R(clock, result) (L_R_TZSET S_localtime_r(clock, result))
59 #endif
60 #ifdef HAS_GMTIME_R
61 #    define GMTIME_R(clock, result)    gmtime_r(clock, result)
62 #else
63 #    define GMTIME_R(clock, result)    S_gmtime_r(clock, result)
64 #endif
65
66 #endif