Merge MSVC fixes from cmake branch
[reactos.git] / reactos / include / crt / crtdefs.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 #include <_mingw.h>
7
8 #ifndef _INC_CRTDEFS
9 #define _INC_CRTDEFS
10
11 #ifdef _USE_32BIT_TIME_T
12 #ifdef _WIN64
13 #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
14 #undef _USE_32BIT_TIME_T
15 #endif
16 #else
17 #if _INTEGRAL_MAX_BITS < 64
18 #define _USE_32BIT_TIME_T
19 #endif
20 #endif
21
22 /* Disable non-ANSI C definitions if compiling with __STDC__ */
23 //HACK: Disabled
24 //#if __STDC__
25 //#define NO_OLDNAMES
26 //#endif
27
28
29 /** Properties ***************************************************************/
30
31 #undef _CRT_PACKING
32 #define _CRT_PACKING 8
33 #pragma pack(push,_CRT_PACKING)
34
35 #ifndef _CRT_STRINGIZE
36 #define __CRT_STRINGIZE(_Value) #_Value
37 #define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
38 #endif
39
40 #ifndef _CRT_WIDE
41 #define __CRT_WIDE(_String) L ## _String
42 #define _CRT_WIDE(_String) __CRT_WIDE(_String)
43 #endif
44
45 #ifndef _W64
46 #if !defined(_midl) && defined(_X86_) && _MSC_VER >= 1300
47 #define _W64 __w64
48 #else
49 #define _W64
50 #endif
51 #endif
52
53 #ifndef _CRTIMP
54 #ifdef CRTDLL /* Defined for ntdll, crtdll, msvcrt, etc */
55 #define _CRTIMP __declspec(dllexport)
56 #elif defined(_DLL)
57 #define _CRTIMP __declspec(dllimport)
58 #else /* !CRTDLL && !_DLL */
59 #define _CRTIMP
60 #endif /* CRTDLL || _DLL */
61 #endif /* !_CRTIMP */
62
63 //#define _CRT_ALTERNATIVE_INLINES
64
65 #ifndef _CRTIMP_ALT
66 #ifdef _DLL
67 #ifdef _CRT_ALTERNATIVE_INLINES
68 #define _CRTIMP_ALT
69 #else
70 #define _CRTIMP_ALT _CRTIMP
71 #define _CRT_ALTERNATIVE_IMPORTED
72 #endif
73 #else
74 #define _CRTIMP_ALT
75 #endif
76 #endif
77
78 #ifndef _CRTDATA
79 #ifdef _M_CEE_PURE
80 #define _CRTDATA(x) x
81 #else
82 #define _CRTDATA(x) _CRTIMP x
83 #endif
84 #endif
85
86 #ifndef _CRTIMP2
87 #define _CRTIMP2 _CRTIMP
88 #endif
89
90 #ifndef _CRTIMP_PURE
91 #define _CRTIMP_PURE _CRTIMP
92 #endif
93
94 #ifndef _CRTIMP_ALTERNATIVE
95 #define _CRTIMP_ALTERNATIVE _CRTIMP
96 #define _CRT_ALTERNATIVE_IMPORTED
97 #endif
98
99 #ifndef _CRTIMP_NOIA64
100 #ifdef __ia64__
101 #define _CRTIMP_NOIA64
102 #else
103 #define _CRTIMP_NOIA64 _CRTIMP
104 #endif
105 #endif
106
107 #ifndef _MRTIMP2
108 #define _MRTIMP2 _CRTIMP
109 #endif
110
111 #ifndef _MCRTIMP
112 #define _MCRTIMP _CRTIMP
113 #endif
114
115 #ifndef _PGLOBAL
116 #define _PGLOBAL
117 #endif
118
119 #ifndef _AGLOBAL
120 #define _AGLOBAL
121 #endif
122
123 #ifndef _CONST_RETURN
124 #define _CONST_RETURN
125 #endif
126
127 #ifndef UNALIGNED
128 #if defined(__ia64__) || defined(__x86_64)
129 #define UNALIGNED __unaligned
130 #else
131 #define UNALIGNED
132 #endif
133 #endif
134
135 #ifndef _CRT_ALIGN
136 #if defined (__midl) || defined(__WIDL__)
137 #define _CRT_ALIGN(x)
138 #elif defined(_MSC_VER)
139 #define _CRT_ALIGN(x) __declspec(align(x))
140 #else
141 #define _CRT_ALIGN(x) __attribute__ ((aligned(x)))
142 #endif
143 #endif
144
145 #ifndef _CRTNOALIAS
146 #define _CRTNOALIAS
147 #endif
148
149 #ifndef _CRTRESTRICT
150 #define _CRTRESTRICT
151 #endif
152
153 #ifndef __CRTDECL
154 #define __CRTDECL __cdecl
155 #endif
156
157 #ifndef _CRT_UNUSED
158 #define _CRT_UNUSED(x) (void)x
159 #endif
160
161 #ifndef _CONST_RETURN
162 #ifdef __cplusplus
163 #define _CONST_RETURN const
164 #define _CRT_CONST_CORRECT_OVERLOADS
165 #else
166 #define _CONST_RETURN
167 #endif
168 #endif
169
170 #define __crt_typefix(ctype)
171
172
173 /** Deprecated ***************************************************************/
174
175 #ifdef __GNUC__
176 #define _CRT_DEPRECATE_TEXT(_Text) __attribute__ ((deprecated))
177 #elif defined(_MSC_VER)
178 #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
179 #else
180 #define _CRT_DEPRECATE_TEXT(_Text)
181 #endif
182
183 #ifndef __STDC_WANT_SECURE_LIB__
184 #define __STDC_WANT_SECURE_LIB__ 1
185 #endif
186
187 #ifndef _CRT_INSECURE_DEPRECATE
188 # ifdef _CRT_SECURE_NO_DEPRECATE
189 # define _CRT_INSECURE_DEPRECATE(_Replacement)
190 # else
191 # define _CRT_INSECURE_DEPRECATE(_Replacement) \
192 _CRT_DEPRECATE_TEXT("This may be unsafe, Try " #_Replacement " instead!")
193 # endif
194 #endif
195
196 #ifndef _CRT_INSECURE_DEPRECATE_CORE
197 # ifdef _CRT_SECURE_NO_DEPRECATE_CORE
198 # define _CRT_INSECURE_DEPRECATE_CORE(_Replacement)
199 # else
200 # define _CRT_INSECURE_DEPRECATE_CORE(_Replacement) \
201 _CRT_DEPRECATE_TEXT("This may be unsafe, Try " #_Replacement " instead! Enable _CRT_SECURE_NO_DEPRECATE to avoid thie warning.")
202 # endif
203 #endif
204
205 #ifndef _CRT_NONSTDC_DEPRECATE
206 # ifdef _CRT_NONSTDC_NO_DEPRECATE
207 # define _CRT_NONSTDC_DEPRECATE(_Replacement)
208 # else
209 # define _CRT_NONSTDC_DEPRECATE(_Replacement) \
210 _CRT_DEPRECATE_TEXT("Deprecated POSIX name, Try " #_Replacement " instead!")
211 # endif
212 #endif
213
214 #ifndef _CRT_INSECURE_DEPRECATE_MEMORY
215 #define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
216 #endif
217
218 #ifndef _CRT_INSECURE_DEPRECATE_GLOBALS
219 #define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
220 #endif
221
222 #ifndef _CRT_MANAGED_HEAP_DEPRECATE
223 #define _CRT_MANAGED_HEAP_DEPRECATE
224 #endif
225
226 #ifndef _CRT_OBSOLETE
227 #define _CRT_OBSOLETE(_NewItem)
228 #endif
229
230
231 /** Constants ****************************************************************/
232
233 #define _ARGMAX 100
234
235 #ifndef _TRUNCATE
236 #define _TRUNCATE ((size_t)-1)
237 #endif
238
239 #define __STDC_SECURE_LIB__ 200411L
240 #define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__
241 #define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
242
243
244 /** Type definitions *********************************************************/
245
246 #ifdef __cplusplus
247 extern "C" {
248 #endif
249
250 #ifndef _SIZE_T_DEFINED
251 #define _SIZE_T_DEFINED
252 #undef size_t
253 #ifdef _WIN64
254 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
255 typedef unsigned int size_t __attribute__ ((mode (DI)));
256 #else
257 __MINGW_EXTENSION typedef unsigned __int64 size_t;
258 #endif
259 #else
260 typedef unsigned int size_t;
261 #endif
262 #endif
263
264 #ifndef _INTPTR_T_DEFINED
265 #define _INTPTR_T_DEFINED
266 #ifndef __intptr_t_defined
267 #define __intptr_t_defined
268 #undef intptr_t
269 #ifdef _WIN64
270 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
271 typedef int intptr_t __attribute__ ((mode (DI)));
272 #else
273 __MINGW_EXTENSION typedef __int64 intptr_t;
274 #endif
275 #else
276 typedef int intptr_t;
277 #endif
278 #endif
279 #endif
280
281 #ifndef _UINTPTR_T_DEFINED
282 #define _UINTPTR_T_DEFINED
283 #ifndef __uintptr_t_defined
284 #define __uintptr_t_defined
285 #undef uintptr_t
286 #ifdef _WIN64
287 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
288 typedef unsigned int uintptr_t __attribute__ ((mode (DI)));
289 #else
290 __MINGW_EXTENSION typedef unsigned __int64 uintptr_t;
291 #endif
292 #else
293 typedef unsigned int uintptr_t;
294 #endif
295 #endif
296 #endif
297
298 #ifndef _PTRDIFF_T_DEFINED
299 #define _PTRDIFF_T_DEFINED
300 #ifndef _PTRDIFF_T_
301 #undef ptrdiff_t
302 #ifdef _WIN64
303 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
304 typedef int ptrdiff_t __attribute__ ((mode (DI)));
305 #else
306 __MINGW_EXTENSION typedef __int64 ptrdiff_t;
307 #endif
308 #else
309 typedef int ptrdiff_t;
310 #endif
311 #endif
312 #endif
313
314 #ifndef _WCHAR_T_DEFINED
315 #define _WCHAR_T_DEFINED
316 #ifndef __cplusplus
317 typedef unsigned short wchar_t;
318 #endif
319 #endif
320
321 #ifndef _WCTYPE_T_DEFINED
322 #define _WCTYPE_T_DEFINED
323 typedef unsigned short wint_t;
324 typedef unsigned short wctype_t;
325 #endif
326
327 #ifndef _ERRCODE_DEFINED
328 #define _ERRCODE_DEFINED
329 typedef int errcode;
330 typedef int errno_t;
331 #endif
332
333 #ifndef _TIME32_T_DEFINED
334 #define _TIME32_T_DEFINED
335 typedef long __time32_t;
336 #endif
337
338 #ifndef _TIME64_T_DEFINED
339 #define _TIME64_T_DEFINED
340 #if _INTEGRAL_MAX_BITS >= 64
341 __MINGW_EXTENSION typedef __int64 __time64_t;
342 #endif
343 #endif
344
345 #ifndef _TIME_T_DEFINED
346 #define _TIME_T_DEFINED
347 #ifdef _USE_32BIT_TIME_T
348 typedef __time32_t time_t;
349 #else
350 typedef __time64_t time_t;
351 #endif
352 #endif
353
354 struct threadlocaleinfostruct;
355 typedef struct threadlocaleinfostruct *pthreadlocinfo;
356
357 struct threadmbcinfostruct;
358 typedef struct threadmbcinfostruct *pthreadmbcinfo;
359
360 struct __lc_time_data;
361
362 typedef struct localeinfo_struct {
363 pthreadlocinfo locinfo;
364 pthreadmbcinfo mbcinfo;
365 } _locale_tstruct,*_locale_t;
366
367 #ifndef _TAGLC_ID_DEFINED
368 #define _TAGLC_ID_DEFINED
369 typedef struct tagLC_ID {
370 unsigned short wLanguage;
371 unsigned short wCountry;
372 unsigned short wCodePage;
373 } LC_ID,*LPLC_ID;
374 #endif
375
376 #ifndef _THREADLOCALEINFO
377 #define _THREADLOCALEINFO
378 typedef struct threadlocaleinfostruct {
379 int refcount;
380 unsigned int lc_codepage;
381 unsigned int lc_collate_cp;
382 unsigned long lc_handle[6];
383 LC_ID lc_id[6];
384 struct {
385 char *locale;
386 wchar_t *wlocale;
387 int *refcount;
388 int *wrefcount;
389 } lc_category[6];
390 int lc_clike;
391 int mb_cur_max;
392 int *lconv_intl_refcount;
393 int *lconv_num_refcount;
394 int *lconv_mon_refcount;
395 struct lconv *lconv;
396 int *ctype1_refcount;
397 unsigned short *ctype1;
398 const unsigned short *pctype;
399 const unsigned char *pclmap;
400 const unsigned char *pcumap;
401 struct __lc_time_data *lc_time_curr;
402 } threadlocinfo;
403 #endif
404
405
406 #ifdef __cplusplus
407 }
408 #endif
409
410 #pragma pack(pop)
411
412 #endif /* !_INC_CRTDEFS */