remove struct timezone from time.h, always declare __tzset(), revert changes from...
[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 /*
97 #ifdef _USE_32BIT_TIME_T
98 #define _localtime32 localtime
99 #define _difftime32 difftime
100 #define _ctime32 ctime
101 #define _gmtime32 gmtime
102 #define _mktime32 mktime
103 #define _time32 time
104 #endif
105 */
106
107 #ifndef _TM_DEFINED
108 #define _TM_DEFINED
109 struct tm {
110 int tm_sec;
111 int tm_min;
112 int tm_hour;
113 int tm_mday;
114 int tm_mon;
115 int tm_year;
116 int tm_wday;
117 int tm_yday;
118 int tm_isdst;
119 };
120 #endif
121
122 #define CLOCKS_PER_SEC 1000
123
124 __MINGW_IMPORT int _daylight;
125 __MINGW_IMPORT long _dstbias;
126 __MINGW_IMPORT long _timezone;
127 __MINGW_IMPORT char * _tzname[2];
128
129 _CRTIMP errno_t __cdecl _get_daylight(int *_Daylight);
130 _CRTIMP errno_t __cdecl _get_dstbias(long *_Daylight_savings_bias);
131 _CRTIMP errno_t __cdecl _get_timezone(long *_Timezone);
132 _CRTIMP errno_t __cdecl _get_tzname(size_t *_ReturnValue,char *_Buffer,size_t _SizeInBytes,int _Index);
133 char *__cdecl asctime(const struct tm *_Tm);
134 _CRTIMP char *__cdecl _ctime32(const __time32_t *_Time);
135 clock_t __cdecl clock(void);
136 _CRTIMP double __cdecl _difftime32(__time32_t _Time1,__time32_t _Time2);
137 _CRTIMP struct tm *__cdecl _gmtime32(const __time32_t *_Time);
138 _CRTIMP struct tm *__cdecl _localtime32(const __time32_t *_Time);
139 size_t __cdecl strftime(char *_Buf,size_t _SizeInBytes,const char *_Format,const struct tm *_Tm);
140 _CRTIMP size_t __cdecl _strftime_l(char *_Buf,size_t _Max_size,const char *_Format,const struct tm *_Tm,_locale_t _Locale);
141 _CRTIMP char *__cdecl _strdate(char *_Buffer);
142 _CRTIMP char *__cdecl _strtime(char *_Buffer);
143 _CRTIMP __time32_t __cdecl _time32(__time32_t *_Time);
144 _CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm);
145 _CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm);
146 #if defined (_POSIX_) || defined(__GNUC__)
147 void __cdecl tzset(void);
148 #endif
149 _CRTIMP void __cdecl _tzset(void);
150
151 #if _INTEGRAL_MAX_BITS >= 64
152 double __cdecl _difftime64(__time64_t _Time1,__time64_t _Time2);
153 _CRTIMP char *__cdecl _ctime64(const __time64_t *_Time);
154 _CRTIMP struct tm *__cdecl _gmtime64(const __time64_t *_Time);
155 _CRTIMP struct tm *__cdecl _localtime64(const __time64_t *_Time);
156 _CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm);
157 _CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm);
158 _CRTIMP __time64_t __cdecl _time64(__time64_t *_Time);
159 #endif
160 unsigned __cdecl _getsystime(struct tm *_Tm);
161 unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec);
162
163 #ifndef _WTIME_DEFINED
164 _CRTIMP wchar_t *__cdecl _wasctime(const struct tm *_Tm);
165 _CRTIMP wchar_t *__cdecl _wctime32(const __time32_t *_Time);
166 size_t __cdecl wcsftime(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm);
167 _CRTIMP size_t __cdecl _wcsftime_l(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm,_locale_t _Locale);
168 _CRTIMP wchar_t *__cdecl _wstrdate(wchar_t *_Buffer);
169 _CRTIMP wchar_t *__cdecl _wstrtime(wchar_t *_Buffer);
170 #if _INTEGRAL_MAX_BITS >= 64
171 _CRTIMP wchar_t *__cdecl _wctime64(const __time64_t *_Time);
172 #endif
173
174 #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
175 #define _INC_WTIME_INL
176 #ifdef _USE_32BIT_TIME_T
177 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
178 #else
179 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
180 #endif
181 #endif
182
183 #define _WTIME_DEFINED
184 #endif
185
186 #ifndef RC_INVOKED
187 double __cdecl difftime(time_t _Time1,time_t _Time2);
188 char *__cdecl ctime(const time_t *_Time);
189 struct tm *__cdecl gmtime(const time_t *_Time);
190 struct tm *__cdecl localtime(const time_t *_Time);
191 struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
192
193 _CRTIMP time_t __cdecl mktime(struct tm *_Tm);
194 _CRTIMP time_t __cdecl _mkgmtime(struct tm *_Tm);
195 _CRTIMP time_t __cdecl time(time_t *_Time);
196
197 #ifdef _USE_32BIT_TIME_T
198 #if 0
199 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
200 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
201 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
202 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime32(_Time); }
203 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
204 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
205 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
206 #endif
207 #else
208 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
209 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
210 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
211 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
212 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
213 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
214 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
215 #endif
216 #endif
217
218 #if !defined(NO_OLDNAMES) || defined(_POSIX)
219 #define CLK_TCK CLOCKS_PER_SEC
220
221 _CRTIMP extern int daylight;
222 _CRTIMP extern long timezone;
223 _CRTIMP extern char *tzname[2];
224 void __cdecl tzset(void);
225 #endif
226
227 #ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
228 #define _TIMEVAL_DEFINED
229 struct timeval {
230 long tv_sec;
231 long tv_usec;
232 };
233 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
234 #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)
235 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
236 #endif /* _TIMEVAL_DEFINED */
237
238 #ifdef __cplusplus
239 }
240 #endif
241
242 #pragma pack(pop)
243
244 #include <sec_api/time_s.h>
245
246 /* Adding timespec definition. */
247 #include <sys/timeb.h>
248
249 #endif /* End _TIME_H_ */
250