OSDN Git Service

Redo the filters based on assumptions discussed in mingw-dvlpr list.
[mingw/mingw-org-wsl.git] / include / time.h
1 /**
2  * @file time.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _TIME_H
25 #define _TIME_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 #define __need_wchar_t
30 #define __need_size_t
31 #define __need_NULL
32
33 #ifndef RC_INVOKED
34 #include <stddef.h>
35 #endif  /* Not RC_INVOKED */
36
37 /*
38  * Number of clock ticks per second. A clock tick is the unit by which
39  * processor time is measured and is returned by 'clock'.
40  */
41 #define CLOCKS_PER_SEC  ((clock_t)1000)
42 #define CLK_TCK         CLOCKS_PER_SEC
43
44
45 #ifndef RC_INVOKED
46
47 /*
48  * A type for storing the current time and date. This is the number of
49  * seconds since midnight Jan 1, 1970.
50  * NOTE: This is also defined in non-ISO sys/types.h.
51  */
52 #ifndef _TIME32_T_DEFINED
53 typedef __int32 __time32_t;
54 #define _TIME32_T_DEFINED
55 #endif
56
57 #ifndef _TIME64_T_DEFINED
58 /* A 64-bit time_t to get to Y3K */
59 typedef __int64 __time64_t;
60 #define _TIME64_T_DEFINED
61 #endif
62
63 #ifndef _TIME_T_DEFINED
64 # ifndef _USE_32BIT_TIME_T
65    typedef      __time64_t time_t;
66 # else
67    typedef      __time32_t time_t;
68 # endif /* !_USE_32BIT_TIME_T */
69 # define _TIME_T_DEFINED
70 #endif
71
72 /*
73  * A type for measuring processor time (in clock ticks).
74  */
75 #ifndef _CLOCK_T_DEFINED
76 typedef long    clock_t;
77 #define _CLOCK_T_DEFINED
78 #endif
79
80 #ifndef _TM_DEFINED
81 /*
82  * A structure for storing all kinds of useful information about the
83  * current (or another) time.
84  */
85 struct tm
86 {
87         int     tm_sec;         /* Seconds: 0-59 (K&R says 0-61?) */
88         int     tm_min;         /* Minutes: 0-59 */
89         int     tm_hour;        /* Hours since midnight: 0-23 */
90         int     tm_mday;        /* Day of the month: 1-31 */
91         int     tm_mon;         /* Months *since* january: 0-11 */
92         int     tm_year;        /* Years since 1900 */
93         int     tm_wday;        /* Days since Sunday (0-6) */
94         int     tm_yday;        /* Days since Jan. 1: 0-365 */
95         int     tm_isdst;       /* +1 Daylight Savings Time, 0 No DST,
96                                  * -1 don't know */
97 };
98 #define _TM_DEFINED
99 #endif
100
101 #ifdef  __cplusplus
102 extern "C" {
103 #endif
104
105 _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
106 _CRTIMP time_t __cdecl __MINGW_NOTHROW  time (time_t*);
107 _CRTIMP double __cdecl __MINGW_NOTHROW  difftime (time_t, time_t);
108 _CRTIMP time_t __cdecl __MINGW_NOTHROW  mktime (struct tm*);
109
110 /*
111  * These functions write to and return pointers to static buffers that may
112  * be overwritten by other function calls. Yikes!
113  *
114  * NOTE: localtime, and perhaps the others of the four functions grouped
115  * below may return NULL if their argument is not 'acceptable'. Also note
116  * that calling asctime with a NULL pointer will produce an Invalid Page
117  * Fault and crap out your program. Guess how I know. Hint: stat called on
118  * a directory gives 'invalid' times in st_atime etc...
119  */
120 _CRTIMP char* __cdecl __MINGW_NOTHROW           asctime (const struct tm*);
121 _CRTIMP char* __cdecl __MINGW_NOTHROW           ctime (const time_t*);
122 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW     gmtime (const time_t*);
123 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW     localtime (const time_t*);
124
125 _CRTIMP size_t __cdecl __MINGW_NOTHROW          strftime (char*, size_t, const char*, const struct tm*);
126
127 #ifndef __STRICT_ANSI__
128
129 extern _CRTIMP void __cdecl __MINGW_NOTHROW     _tzset (void);
130
131 #ifndef _NO_OLDNAMES
132 extern _CRTIMP void __cdecl __MINGW_NOTHROW     tzset (void);
133 #endif
134
135 _CRTIMP char* __cdecl __MINGW_NOTHROW   _strdate(char*);
136 _CRTIMP char* __cdecl __MINGW_NOTHROW   _strtime(char*);
137
138 /* These require newer versions of msvcrt.dll (6.10 or higher). */ 
139 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW  _time64( __time64_t*);
140 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW  _mktime64 (struct tm*);
141 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
142 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
143 _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
144
145 /* These require newer versions of msvcrt.dll (8.00 or higher). */ 
146 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW      _time32 (__time32_t*);
147 _CRTIMP double     __cdecl __MINGW_NOTHROW      _difftime32 (__time32_t, __time32_t);
148 _CRTIMP double     __cdecl __MINGW_NOTHROW      _difftime64 (__time64_t, __time64_t);
149 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW      _mktime32 (struct tm*);
150 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW      _mkgmtime32 (struct tm*);
151 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW      _mkgmtime64 (struct tm*);
152 _CRTIMP char*      __cdecl __MINGW_NOTHROW      _ctime32 (const __time32_t*);
153 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW      _gmtime32 (const __time32_t*);
154 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW      _localtime32 (const __time32_t*);
155
156 #ifndef _USE_32BIT_TIME_T
157 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      time (time_t* _v)                 { return(_time64 (_v)); }
158 _CRTALIAS double           __cdecl __MINGW_NOTHROW      difftime (time_t _v1, time_t _v2) { return(_difftime64 (_v1,_v2)); }
159 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      mktime (struct tm* _v)            { return(_mktime64 (_v)); }
160 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      _mkgmtime (struct tm* _v)         { return(_mkgmtime64 (_v)); }
161 _CRTALIAS char*            __cdecl __MINGW_NOTHROW      ctime (const time_t* _v)          { return(_ctime64 (_v)); }
162 _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW      gmtime (const time_t* _v)         { return(_gmtime64 (_v)); }
163 _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW      localtime (const time_t* _v)      { return(_localtime64 (_v)); }
164 #else
165 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      time (time_t* _v)                 { return(_time32 (_v)); }
166 _CRTALIAS double           __cdecl __MINGW_NOTHROW      difftime (time_t _v1, time_t _v2) { return(_difftime32 (_v1,_v2)); }
167 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      mktime (struct tm* _v)            { return(_mktime32 (_v)); }
168 _CRTALIAS time_t           __cdecl __MINGW_NOTHROW      _mkgmtime (struct tm* _v)         { return(_mkgmtime32 (_v)); }
169 _CRTALIAS char*            __cdecl __MINGW_NOTHROW      ctime (const time_t* _v)          { return(_ctime32 (_v)); }
170 _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW      gmtime (const time_t* _v)         { return(_gmtime32 (_v)); }
171 _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW      localtime (const time_t* _v)      { return(_localtime32 (_v)); }
172 #endif /* !_USE_32BIT_TIME_T */
173
174
175 /*
176  * _daylight: non zero if daylight savings time is used.
177  * _timezone: difference in seconds between GMT and local time.
178  * _tzname: standard/daylight savings time zone names (an array with two
179  *          elements).
180  */
181
182 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
183 extern _CRTIMP int* __cdecl __MINGW_NOTHROW     __p__daylight (void);
184 extern _CRTIMP long* __cdecl __MINGW_NOTHROW    __p__timezone (void);
185 extern _CRTIMP char** __cdecl __MINGW_NOTHROW   __p__tzname (void);
186
187 __MINGW_IMPORT int      _daylight;
188 __MINGW_IMPORT long     _timezone;
189 __MINGW_IMPORT char     *_tzname[2];
190
191 #endif  /* Not __STRICT_ANSI__ */
192
193 #ifndef _NO_OLDNAMES
194 /* These go in the oldnames import library for MSVCRT. */
195 __MINGW_IMPORT int      daylight;
196 __MINGW_IMPORT long     timezone;
197 __MINGW_IMPORT char     *tzname[2];
198 #endif  /* Not _NO_OLDNAMES */
199
200 #ifndef _WTIME_DEFINED
201 /* wide function prototypes, also declared in wchar.h */
202
203 #ifndef __STRICT_ANSI__
204 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wasctime(const struct tm*);
205 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wctime(const time_t*);
206 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wstrdate(wchar_t*);
207 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wstrtime(wchar_t*);
208 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wctime64 (const __time64_t*);
209 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW        _wctime32 (const __time32_t*);
210
211 #ifndef _USE_32BIT_TIME_T
212 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW      _wctime (const time_t* _v) { return(_wctime64 (_v)); }
213 #else
214 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW      _wctime (const time_t* _v) { return(_wctime32 (_v)); }
215 #endif
216
217 #endif /* __STRICT_ANSI__ */
218
219 _CRTIMP size_t __cdecl __MINGW_NOTHROW          wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
220 #define _WTIME_DEFINED
221 #endif /* _WTIME_DEFINED */ 
222
223 #ifdef  __cplusplus
224 }
225 #endif
226
227 #endif  /* Not RC_INVOKED */
228
229 #endif  /* Not _TIME_H */