sync to trunk revision 36500
[reactos.git] / reactos / include / crt / time.h
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 #ifndef _TIME_H_
7 #define _TIME_H_
8
9 #include <_mingw.h>
10
11 #ifndef _WIN32
12 #error Only Win32 target is supported!
13 #endif
14
15 #pragma pack(push,_CRT_PACKING)
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #ifndef _CRTIMP
22 #define _CRTIMP __declspec(dllimport)
23 #endif
24
25 #ifndef _WCHAR_T_DEFINED
26 #define _WCHAR_T_DEFINED
27 typedef unsigned short wchar_t;
28 #endif
29
30 #ifndef _TIME32_T_DEFINED
31 #define _TIME32_T_DEFINED
32 typedef long __time32_t;
33 #endif
34
35 #ifndef _TIME64_T_DEFINED
36 #define _TIME64_T_DEFINED
37 #if _INTEGRAL_MAX_BITS >= 64
38 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
39 typedef int _time64_t __attribute__ ((mode (DI)));
40 #else
41 typedef __int64 __time64_t;
42 #endif
43 #endif
44 #endif
45
46 #ifndef _TIME_T_DEFINED
47 #define _TIME_T_DEFINED
48 #ifdef _USE_32BIT_TIME_T
49 typedef __time32_t time_t;
50 #else
51 typedef __time64_t time_t;
52 #endif
53 #endif
54
55 #ifndef _CLOCK_T_DEFINED
56 #define _CLOCK_T_DEFINED
57 typedef long clock_t;
58 #endif
59
60 #ifndef _SIZE_T_DEFINED
61 #define _SIZE_T_DEFINED
62 #undef size_t
63 #ifdef _WIN64
64 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
65 typedef unsigned int size_t __attribute__ ((mode (DI)));
66 #else
67 typedef unsigned __int64 size_t;
68 #endif
69 #else
70 typedef unsigned int size_t;
71 #endif
72 #endif
73
74 #ifndef _SSIZE_T_DEFINED
75 #define _SSIZE_T_DEFINED
76 #undef ssize_t
77 #ifdef _WIN64
78 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
79 typedef int ssize_t __attribute__ ((mode (DI)));
80 #else
81 typedef __int64 ssize_t;
82 #endif
83 #else
84 typedef int ssize_t;
85 #endif
86 #endif
87
88 #ifndef NULL
89 #ifdef __cplusplus
90 #define NULL 0
91 #else
92 #define NULL ((void *)0)
93 #endif
94 #endif
95
96 #ifdef _USE_32BIT_TIME_T
97 #define _localtime32 localtime
98 #define _difftime32 difftime
99 #define _ctime32 ctime
100 #define _gmtime32 gmtime
101 #define _mktime32 mktime
102 #define _time32 _time
103 #endif
104
105 #ifndef _TM_DEFINED
106 #define _TM_DEFINED
107 struct tm {
108 int tm_sec;
109 int tm_min;
110 int tm_hour;
111 int tm_mday;
112 int tm_mon;
113 int tm_year;
114 int tm_wday;
115 int tm_yday;
116 int tm_isdst;
117 };
118 #endif
119
120 #define CLOCKS_PER_SEC 1000
121
122 _CRTIMP int _daylight;
123 _CRTIMP long _dstbias;
124 _CRTIMP long _timezone;
125 _CRTIMP char * _tzname[2];
126
127 _CRTIMP errno_t __cdecl _get_daylight(int *_Daylight);
128 _CRTIMP errno_t __cdecl _get_dstbias(long *_Daylight_savings_bias);
129 _CRTIMP errno_t __cdecl _get_timezone(long *_Timezone);
130 _CRTIMP errno_t __cdecl _get_tzname(size_t *_ReturnValue,char *_Buffer,size_t _SizeInBytes,int _Index);
131 char *__cdecl asctime(const struct tm *_Tm);
132 _CRTIMP char *__cdecl _ctime32(const __time32_t *_Time);
133 clock_t __cdecl clock(void);
134 _CRTIMP double __cdecl _difftime32(__time32_t _Time1,__time32_t _Time2);
135 _CRTIMP struct tm *__cdecl _gmtime32(const __time32_t *_Time);
136 _CRTIMP struct tm *__cdecl _localtime32(const __time32_t *_Time);
137 size_t __cdecl strftime(char *_Buf,size_t _SizeInBytes,const char *_Format,const struct tm *_Tm);
138 _CRTIMP size_t __cdecl _strftime_l(char *_Buf,size_t _Max_size,const char *_Format,const struct tm *_Tm,_locale_t _Locale);
139 _CRTIMP char *__cdecl _strdate(char *_Buffer);
140 _CRTIMP char *__cdecl _strtime(char *_Buffer);
141 _CRTIMP __time32_t __cdecl _time32(__time32_t *_Time);
142 _CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm);
143 _CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm);
144 #if defined (_POSIX_) || defined(__GNUC__)
145 void __cdecl tzset(void);
146 #else
147 _CRTIMP void __cdecl _tzset(void);
148 #endif
149
150 double __cdecl _difftime64(__time64_t _Time1,__time64_t _Time2);
151 _CRTIMP char *__cdecl _ctime64(const __time64_t *_Time);
152 _CRTIMP struct tm *__cdecl _gmtime64(const __time64_t *_Time);
153 _CRTIMP struct tm *__cdecl _localtime64(const __time64_t *_Time);
154 _CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm);
155 _CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm);
156 _CRTIMP __time64_t __cdecl _time64(__time64_t *_Time);
157
158 unsigned __cdecl _getsystime(struct tm *_Tm);
159 unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec);
160
161 #ifndef _SIZE_T_DEFINED
162 #define _SIZE_T_DEFINED
163 #ifdef _WIN64
164 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
165 typedef unsigned int size_t __attribute__ ((mode (DI)));
166 #else
167 typedef unsigned __int64 size_t;
168 #endif
169 #else
170 typedef unsigned long size_t;
171 #endif
172 #endif
173
174 #ifndef _SSIZE_T_DEFINED
175 #define _SSIZE_T_DEFINED
176 #ifdef _WIN64
177 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
178 typedef int ssize_t __attribute__ ((mode (DI)));
179 #else
180 typedef __int64 ssize_t;
181 #endif
182 #else
183 typedef long ssize_t;
184 #endif
185 #endif
186
187 #ifndef _WTIME_DEFINED
188 _CRTIMP wchar_t *__cdecl _wasctime(const struct tm *_Tm);
189 _CRTIMP wchar_t *__cdecl _wctime32(const __time32_t *_Time);
190 size_t __cdecl wcsftime(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm);
191 _CRTIMP size_t __cdecl _wcsftime_l(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm,_locale_t _Locale);
192 _CRTIMP wchar_t *__cdecl _wstrdate(wchar_t *_Buffer);
193 _CRTIMP wchar_t *__cdecl _wstrtime(wchar_t *_Buffer);
194 _CRTIMP wchar_t *__cdecl _wctime64(const __time64_t *_Time);
195
196 #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
197 #define _INC_WTIME_INL
198 #ifdef _USE_32BIT_TIME_T
199 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
200 #else
201 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
202 #endif
203 #endif
204
205 #define _WTIME_DEFINED
206 #endif
207
208 #ifndef RC_INVOKED
209 double __cdecl difftime(time_t _Time1,time_t _Time2);
210 char *__cdecl ctime(const time_t *_Time);
211 struct tm *__cdecl gmtime(const time_t *_Time);
212 struct tm *__cdecl localtime(const time_t *_Time);
213 struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
214
215 time_t __cdecl mktime(struct tm *_Tm);
216 time_t __cdecl _mkgmtime(struct tm *_Tm);
217 time_t __cdecl time(time_t *_Time);
218
219 #ifdef _USE_32BIT_TIME_T
220 #if 0
221 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
222 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
223 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
224 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
225 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
226 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
227 #endif
228 #else
229 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
230 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
231 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
232 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
233 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
234 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
235 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
236 #endif
237 #endif
238
239 #if !defined(NO_OLDNAMES) || defined(_POSIX)
240 #define CLK_TCK CLOCKS_PER_SEC
241
242 _CRTIMP extern int daylight;
243 _CRTIMP extern long timezone;
244 _CRTIMP extern char *tzname[2];
245 void __cdecl tzset(void);
246 #endif
247
248 #ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
249 #define _TIMEVAL_DEFINED
250 struct timeval {
251 long tv_sec;
252 long tv_usec;
253 };
254 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
255 #define timercmp(tvp,uvp,cmp) ((tvp)->tv_sec cmp (uvp)->tv_sec || (tvp)->tv_sec==(uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
256 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
257 #endif /* _TIMEVAL_DEFINED */
258
259 #ifndef __STRICT_ANSI__
260 #ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
261 #define _TIMEZONE_DEFINED
262 struct timezone {
263 int tz_minuteswest;
264 int tz_dsttime;
265 };
266
267 extern int __cdecl mingw_gettimeofday (struct timeval *p, struct timezone *z);
268 #endif
269 #endif /* __STRICT_ANSI__ */
270
271 #ifdef __cplusplus
272 }
273 #endif
274
275 #pragma pack(pop)
276
277 #include <sec_api/time_s.h>
278
279 /* Adding timespec definition. */
280 #include <sys/timeb.h>
281
282 #endif /* End _TIME_H_ */
283