xref: /reactos/sdk/include/crt/time.h (revision 803b5e13)
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the w64 mingw-runtime package.
4  * No warranty is given; refer to the file DISCLAIMER within this package.
5  */
6 
7 #ifndef _TIME_H_
8 #define _TIME_H_
9 
10 #include <crtdefs.h>
11 
12 #ifndef _WIN32
13 #error Only Win32 target is supported!
14 #endif
15 
16 #pragma pack(push,_CRT_PACKING)
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #ifndef _TIME32_T_DEFINED
23 #define _TIME32_T_DEFINED
24   typedef long __time32_t;
25 #endif
26 
27 #ifndef _TIME64_T_DEFINED
28 #define _TIME64_T_DEFINED
29 #if _INTEGRAL_MAX_BITS >= 64
30 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
31   typedef int _time64_t __attribute__ ((mode (DI)));
32 #else
33   __MINGW_EXTENSION typedef __int64 __time64_t;
34 #endif
35 #endif
36 #endif
37 
38 #ifndef _TIME_T_DEFINED
39 #define _TIME_T_DEFINED
40 #ifdef _USE_32BIT_TIME_T
41   typedef __time32_t time_t;
42 #else
43   typedef __time64_t time_t;
44 #endif
45 #endif
46 
47 #ifndef _CLOCK_T_DEFINED
48 #define _CLOCK_T_DEFINED
49   typedef long clock_t;
50 #endif
51 
52 #ifndef _SIZE_T_DEFINED
53 #define _SIZE_T_DEFINED
54 #undef size_t
55 #ifdef _WIN64
56 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
57   typedef unsigned int size_t __attribute__ ((mode (DI)));
58 #else
59   __MINGW_EXTENSION typedef unsigned __int64 size_t;
60 #endif
61 #else
62   typedef unsigned int size_t;
63 #endif
64 #endif
65 
66 #ifndef NULL
67 #ifdef __cplusplus
68 #define NULL 0
69 #else
70 #define NULL ((void *)0)
71 #endif
72 #endif
73 
74 #ifndef _TM_DEFINED
75 #define _TM_DEFINED
76   struct tm {
77     int tm_sec;
78     int tm_min;
79     int tm_hour;
80     int tm_mday;
81     int tm_mon;
82     int tm_year;
83     int tm_wday;
84     int tm_yday;
85     int tm_isdst;
86   };
87 #endif
88 
89 #define CLOCKS_PER_SEC 1000
90 
91   _CRTDATA(extern int _daylight);
92   _CRTDATA(extern long _dstbias);
93   _CRTDATA(extern long _timezone);
94   _CRTDATA(extern char * _tzname[2]);
95 
96   _CRTIMP errno_t __cdecl _get_daylight(_Out_ int *_Daylight);
97   _CRTIMP errno_t __cdecl _get_dstbias(_Out_ long *_Daylight_savings_bias);
98   _CRTIMP errno_t __cdecl _get_timezone(_Out_ long *_Timezone);
99 
100   _CRTIMP
101   errno_t
102   __cdecl
103   _get_tzname(
104     _Out_ size_t *_ReturnValue,
105     _Out_writes_z_(_SizeInBytes) char *_Buffer,
106     _In_ size_t _SizeInBytes,
107     _In_ int _Index);
108 
109   _Check_return_
110   _CRTIMP
111   _CRT_INSECURE_DEPRECATE(asctime_s)
112   char *
113   __cdecl
114   asctime(
115     _In_ const struct tm *_Tm);
116 
117   _CRTIMP
118   _CRT_INSECURE_DEPRECATE(_ctime32_s)
119   char *
120   __cdecl
121   _ctime32(
122     _In_ const __time32_t *_Time);
123 
124   _Check_return_ _CRTIMP clock_t __cdecl clock(void);
125 
126   _CRTIMP
127   double
128   __cdecl
129   _difftime32(
130     _In_ __time32_t _Time1,
131     _In_ __time32_t _Time2);
132 
133   _Check_return_
134   _CRTIMP
135   _CRT_INSECURE_DEPRECATE(_gmtime32_s)
136   struct tm *
137   __cdecl
138   _gmtime32(
139     _In_ const __time32_t *_Time);
140 
141   _CRTIMP
142   _CRT_INSECURE_DEPRECATE(_localtime32_s)
143   struct tm *
144   __cdecl
145   _localtime32(
146     _In_ const __time32_t *_Time);
147 
148   _Success_(return > 0)
149   _CRTIMP
150   size_t
151   __cdecl
152   strftime(
153     _Out_writes_z_(_SizeInBytes) char *_Buf,
154     _In_ size_t _SizeInBytes,
155     _In_z_ _Printf_format_string_ const char *_Format,
156     _In_ const struct tm *_Tm);
157 
158   _Success_(return > 0)
159   _CRTIMP
160   size_t
161   __cdecl
162   _strftime_l(
163     _Out_writes_z_(_Max_size) char *_Buf,
164     _In_ size_t _Max_size,
165     _In_z_ _Printf_format_string_ const char *_Format,
166     _In_ const struct tm *_Tm,
167     _In_opt_ _locale_t _Locale);
168 
169   _CRTIMP char *__cdecl _strdate(_Out_writes_z_(9) char *_Buffer);
170   _CRTIMP char *__cdecl _strtime(_Out_writes_z_(9) char *_Buffer);
171   _CRTIMP __time32_t __cdecl _time32(_Out_opt_ __time32_t *_Time);
172   _CRTIMP __time32_t __cdecl _mktime32(_Inout_ struct tm *_Tm);
173   _CRTIMP __time32_t __cdecl _mkgmtime32(_Inout_ struct tm *_Tm);
174   _CRTIMP void __cdecl _tzset(void);
175   _CRT_OBSOLETE(GetLocalTime) unsigned __cdecl _getsystime(_Out_ struct tm *_Tm);
176 
177   _CRT_OBSOLETE(GetLocalTime)
178   unsigned
179   __cdecl
180   _setsystime(
181     _In_ struct tm *_Tm,
182     unsigned _MilliSec);
183 
184   _Check_return_wat_
185   _CRTIMP
186   errno_t
187   __cdecl
188   asctime_s(
189     _Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buf,
190     _In_range_(>= , 26) size_t _SizeInBytes,
191     _In_ const struct tm *_Tm);
192 
193   _Success_(return == 0)
194   _CRTIMP
195   errno_t
196   __cdecl
197   _ctime32_s(
198     _Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buf,
199     _In_ size_t _SizeInBytes,
200     _In_ const __time32_t *_Time);
201 
202   _Check_return_wat_
203   _CRTIMP
204   errno_t
205   __cdecl
206   _gmtime32_s(
207     _In_ struct tm *_Tm,
208     _In_ const __time32_t *_Time);
209 
210   _CRTIMP
211   errno_t
212   __cdecl
213   _localtime32_s(
214     _Out_ struct tm *_Tm,
215     _In_ const __time32_t *_Time);
216 
217   _Check_return_wat_
218   _CRTIMP
219   errno_t
220   __cdecl
221   _strdate_s(
222     _Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf,
223     _In_range_(>= , 9) size_t _SizeInBytes);
224 
225   _Check_return_wat_
226   _CRTIMP
227   errno_t
228   __cdecl
229   _strtime_s(
230     _Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf,
231     _In_range_(>= , 9) size_t _SizeInBytes);
232 
233 #if _INTEGRAL_MAX_BITS >= 64
234 
235   _Check_return_
236   _CRTIMP
237   double
238   __cdecl
239   _difftime64(
240     _In_ __time64_t _Time1,
241     _In_ __time64_t _Time2);
242 
243   _CRTIMP
244   _CRT_INSECURE_DEPRECATE(_ctime64_s)
245   char *
246   __cdecl
247   _ctime64(
248     _In_ const __time64_t *_Time);
249 
250   _CRTIMP
251   _CRT_INSECURE_DEPRECATE(_gmtime64_s)
252   struct tm *
253   __cdecl
254   _gmtime64(
255     _In_ const __time64_t *_Time);
256 
257   _CRTIMP
258   _CRT_INSECURE_DEPRECATE(_localtime64_s)
259   struct tm *
260   __cdecl
261   _localtime64(
262     _In_ const __time64_t *_Time);
263 
264   _CRTIMP __time64_t __cdecl _mktime64(_Inout_ struct tm *_Tm);
265   _CRTIMP __time64_t __cdecl _mkgmtime64(_Inout_ struct tm *_Tm);
266   _CRTIMP __time64_t __cdecl _time64(_Out_opt_ __time64_t *_Time);
267 
268   _CRTIMP
269   errno_t
270   __cdecl
271   _ctime64_s(
272     _Out_writes_z_(_SizeInBytes) char *_Buf,
273     _In_ size_t _SizeInBytes,
274     _In_ const __time64_t *_Time);
275 
276   _CRTIMP
277   errno_t
278   __cdecl
279   _gmtime64_s(
280     _Out_ struct tm *_Tm,
281     _In_ const __time64_t *_Time);
282 
283   _CRTIMP
284   errno_t
285   __cdecl
286   _localtime64_s(
287     _Out_ struct tm *_Tm,
288     _In_ const __time64_t *_Time);
289 
290 #endif /* _INTEGRAL_MAX_BITS >= 64 */
291 
292 #ifndef _WTIME_DEFINED
293 #define _WTIME_DEFINED
294 
295   _CRTIMP
296   _CRT_INSECURE_DEPRECATE(_wasctime_s)
297   wchar_t *
298   __cdecl
299   _wasctime(
300     _In_ const struct tm *_Tm);
301 
302   _CRTIMP wchar_t *__cdecl _wctime(const time_t *_Time);
303 
304   _CRTIMP
305   _CRT_INSECURE_DEPRECATE(_wctime32_s)
306   wchar_t *
307   __cdecl
308   _wctime32(
309     _In_ const __time32_t *_Time);
310 
311   _Success_(return > 0)
312   _CRTIMP
313   size_t
314   __cdecl
315   wcsftime(
316     _Out_writes_z_(_SizeInWords) wchar_t *_Buf,
317     _In_ size_t _SizeInWords,
318     _In_z_ _Printf_format_string_ const wchar_t *_Format,
319     _In_ const struct tm *_Tm);
320 
321   _Success_(return > 0)
322   _CRTIMP
323   size_t
324   __cdecl
325   _wcsftime_l(
326     _Out_writes_z_(_SizeInWords) wchar_t *_Buf,
327     _In_ size_t _SizeInWords,
328     _In_z_ _Printf_format_string_ const wchar_t *_Format,
329     _In_ const struct tm *_Tm,
330     _In_opt_ _locale_t _Locale);
331 
332   _CRTIMP wchar_t *__cdecl _wstrdate(_Out_writes_z_(9) wchar_t *_Buffer);
333   _CRTIMP wchar_t *__cdecl _wstrtime(_Out_writes_z_(9) wchar_t *_Buffer);
334 
335   _CRTIMP
336   errno_t
337   __cdecl
338   _wasctime_s(
339     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
340     _In_range_(>= , 26) size_t _SizeInWords,
341     _In_ const struct tm *_Tm);
342 
343   _Success_(return == 0)
344   _CRTIMP
345   errno_t
346   __cdecl
347   _wctime32_s(
348     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
349     _In_ size_t _SizeInWords,
350     _In_ const __time32_t *_Time);
351 
352   _CRTIMP
353   errno_t
354   __cdecl
355   _wstrdate_s(
356     _Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
357     _In_ size_t _SizeInWords);
358 
359   _CRTIMP
360   errno_t
361   __cdecl
362   _wstrtime_s(
363     _Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
364     _In_range_(>= , 9) size_t _SizeInWords);
365 
366 #if _INTEGRAL_MAX_BITS >= 64
367 
368   _CRTIMP
369   _CRT_INSECURE_DEPRECATE(_wctime64_s)
370   wchar_t *
371   __cdecl
372   _wctime64(
373     _In_ const __time64_t *_Time);
374 
375   _Success_(return == 0)
376   _CRTIMP
377   errno_t
378   __cdecl
379   _wctime64_s(
380     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
381     _In_ size_t _SizeInWords,
382     _In_ const __time64_t *_Time);
383 
384 #endif /* _INTEGRAL_MAX_BITS >= 64 */
385 
386 #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
387 #define _INC_WTIME_INL
388 #ifdef _USE_32BIT_TIME_T
389 /* Do it like this to be compatible to msvcrt.dll on 32 bit windows XP and before */
390 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
391 #else
392 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
393 #endif
394 #endif
395 
396 #endif /* !_WTIME_DEFINED */
397 
398  _CRTIMP double __cdecl difftime(time_t _Time1,time_t _Time2);
399  _CRTIMP char *__cdecl ctime(const time_t *_Time);
400  _CRTIMP struct tm *__cdecl gmtime(const time_t *_Time);
401  _CRTIMP struct tm *__cdecl localtime(const time_t *_Time);
402  _CRTIMP struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
403 
404  _CRTIMP time_t __cdecl mktime(struct tm *_Tm);
405  _CRTIMP time_t __cdecl _mkgmtime(struct tm *_Tm);
406  _CRTIMP time_t __cdecl time(time_t *_Time);
407 
408 #if !defined(RC_INVOKED)  && !defined(_NO_INLINING)  && !defined(_CRTBLD)
409 #ifdef _USE_32BIT_TIME_T
410 #if 0
411 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
412 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
413 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
414 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime32(_Time); }
415 __CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); }
416 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
417 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
418 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
419 #endif
420 #else
421 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
422 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
423 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
424 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
425 __CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); }
426 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
427 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
428 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
429 #endif
430 #endif
431 
432 #if !defined(NO_OLDNAMES) || defined(_POSIX)
433 #define CLK_TCK CLOCKS_PER_SEC
434 
435   _CRTIMP extern int daylight;
436   _CRTIMP extern long timezone;
437   _CRTIMP extern char *tzname[2];
438   _CRTIMP void __cdecl tzset(void);
439 #endif
440 
441 #ifdef __cplusplus
442 }
443 #endif
444 
445 #pragma pack(pop)
446 
447 #endif /* End _TIME_H_ */
448