Release 4.20.
[wine.git] / include / msvcrt / corecrt.h
blobc88d3e0570d4080a60d8711f35ac1ff49d3671df
1 /*
2 * CRT definitions
4 * Copyright 2000 Francois Gouget.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_CORECRT_H
22 #define __WINE_CORECRT_H
24 #ifndef __WINE_USE_MSVCRT
25 #define __WINE_USE_MSVCRT
26 #endif
28 #ifdef __WINE_WINE_PORT_H
29 # error You cannot use both wine/port.h and msvcrt headers
30 #endif
32 #if (defined(__x86_64__) || defined(__powerpc64__) || defined(__aarch64__)) && !defined(_WIN64)
33 #define _WIN64
34 #endif
36 #if !defined(_MSC_VER) && !defined(__int64)
37 # if defined(_WIN64) && !defined(__MINGW64__)
38 # define __int64 long
39 # else
40 # define __int64 long long
41 # endif
42 #endif
44 #ifndef __stdcall
45 # ifdef __i386__
46 # ifdef __GNUC__
47 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
48 # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
49 # else
50 # define __stdcall __attribute__((__stdcall__))
51 # endif
52 # elif defined(_MSC_VER)
53 /* Nothing needs to be done. __stdcall already exists */
54 # else
55 # error You need to define __stdcall for your compiler
56 # endif
57 # elif defined(__x86_64__) && defined (__GNUC__)
58 # if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
59 # define __stdcall __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
60 # else
61 # define __stdcall __attribute__((ms_abi))
62 # endif
63 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
64 # define __stdcall __attribute__((pcs("aapcs-vfp")))
65 # elif defined(__aarch64__) && defined (__GNUC__)
66 # define __stdcall __attribute__((ms_abi))
67 # else /* __i386__ */
68 # define __stdcall
69 # endif /* __i386__ */
70 #endif /* __stdcall */
72 #ifndef __cdecl
73 # if defined(__i386__) && defined(__GNUC__)
74 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
75 # define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
76 # else
77 # define __cdecl __attribute__((__cdecl__))
78 # endif
79 # elif defined(__x86_64__) && defined (__GNUC__)
80 # if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
81 # define __cdecl __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
82 # else
83 # define __cdecl __attribute__((ms_abi))
84 # endif
85 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
86 # define __cdecl __attribute__((pcs("aapcs-vfp")))
87 # elif defined(__aarch64__) && defined (__GNUC__)
88 # define __cdecl __attribute__((ms_abi))
89 # elif !defined(_MSC_VER)
90 # define __cdecl
91 # endif
92 #endif /* __cdecl */
94 #ifndef __ms_va_list
95 # if (defined(__x86_64__) || defined(__aarch64__)) && defined (__GNUC__)
96 # define __ms_va_list __builtin_ms_va_list
97 # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
98 # define __ms_va_end(list) __builtin_ms_va_end(list)
99 # define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
100 # else
101 # define __ms_va_list va_list
102 # define __ms_va_start(list,arg) va_start(list,arg)
103 # define __ms_va_end(list) va_end(list)
104 # ifdef va_copy
105 # define __ms_va_copy(dest,src) va_copy(dest,src)
106 # else
107 # define __ms_va_copy(dest,src) ((dest) = (src))
108 # endif
109 # endif
110 #endif
112 #ifndef WINAPIV
113 # if defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
114 # define WINAPIV __attribute__((pcs("aapcs")))
115 # else
116 # define WINAPIV __cdecl
117 # endif
118 #endif
120 #ifndef DECLSPEC_NORETURN
121 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
122 # define DECLSPEC_NORETURN __declspec(noreturn)
123 # elif defined(__GNUC__)
124 # define DECLSPEC_NORETURN __attribute__((noreturn))
125 # else
126 # define DECLSPEC_NORETURN
127 # endif
128 #endif
130 #ifndef DECLSPEC_ALIGN
131 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
132 # define DECLSPEC_ALIGN(x) __declspec(align(x))
133 # elif defined(__GNUC__)
134 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
135 # else
136 # define DECLSPEC_ALIGN(x)
137 # endif
138 #endif
140 #define _ARGMAX 100
142 #ifndef _MSVCRT_LONG_DEFINED
143 #define _MSVCRT_LONG_DEFINED
144 /* we need 32-bit longs even on 64-bit */
145 typedef int __msvcrt_long;
146 typedef unsigned int __msvcrt_ulong;
147 #endif
149 #ifndef _INTPTR_T_DEFINED
150 #ifdef _WIN64
151 typedef __int64 intptr_t;
152 #else
153 typedef int intptr_t;
154 #endif
155 #define _INTPTR_T_DEFINED
156 #endif
158 #ifndef _UINTPTR_T_DEFINED
159 #ifdef _WIN64
160 typedef unsigned __int64 uintptr_t;
161 #else
162 typedef unsigned int uintptr_t;
163 #endif
164 #define _UINTPTR_T_DEFINED
165 #endif
167 #ifndef _PTRDIFF_T_DEFINED
168 #ifdef _WIN64
169 typedef __int64 ptrdiff_t;
170 #else
171 typedef int ptrdiff_t;
172 #endif
173 #define _PTRDIFF_T_DEFINED
174 #endif
176 #ifndef _SIZE_T_DEFINED
177 #ifdef _WIN64
178 typedef unsigned __int64 size_t;
179 #else
180 typedef unsigned int size_t;
181 #endif
182 #define _SIZE_T_DEFINED
183 #endif
185 #ifndef _TIME32_T_DEFINED
186 typedef __msvcrt_long __time32_t;
187 #define _TIME32_T_DEFINED
188 #endif
190 #ifndef _TIME64_T_DEFINED
191 typedef __int64 DECLSPEC_ALIGN(8) __time64_t;
192 #define _TIME64_T_DEFINED
193 #endif
195 #ifdef _USE_32BIT_TIME_T
196 # ifdef _WIN64
197 # error You cannot use 32-bit time_t in Win64
198 # endif
199 #elif !defined(_WIN64)
200 # define _USE_32BIT_TIME_T
201 #endif
203 #ifndef _TIME_T_DEFINED
204 #ifdef _USE_32BIT_TIME_T
205 typedef __time32_t time_t;
206 #else
207 typedef __time64_t time_t;
208 #endif
209 #define _TIME_T_DEFINED
210 #endif
212 #ifndef _WCHAR_T_DEFINED
213 #ifndef __cplusplus
214 typedef unsigned short wchar_t;
215 #endif
216 #define _WCHAR_T_DEFINED
217 #endif
219 #ifndef _WCTYPE_T_DEFINED
220 typedef unsigned short wint_t;
221 typedef unsigned short wctype_t;
222 #define _WCTYPE_T_DEFINED
223 #endif
225 #ifndef _ERRNO_T_DEFINED
226 typedef int errno_t;
227 #define _ERRNO_T_DEFINED
228 #endif
230 struct threadlocaleinfostruct;
231 struct threadmbcinfostruct;
232 typedef struct threadlocaleinfostruct *pthreadlocinfo;
233 typedef struct threadmbcinfostruct *pthreadmbcinfo;
235 typedef struct localeinfo_struct
237 pthreadlocinfo locinfo;
238 pthreadmbcinfo mbcinfo;
239 } _locale_tstruct, *_locale_t;
241 #ifndef _TAGLC_ID_DEFINED
242 typedef struct tagLC_ID {
243 unsigned short wLanguage;
244 unsigned short wCountry;
245 unsigned short wCodePage;
246 } LC_ID, *LPLC_ID;
247 #define _TAGLC_ID_DEFINED
248 #endif
250 #ifndef _THREADLOCALEINFO
251 typedef struct threadlocaleinfostruct {
252 int refcount;
253 unsigned int lc_codepage;
254 unsigned int lc_collate_cp;
255 __msvcrt_ulong lc_handle[6];
256 LC_ID lc_id[6];
257 struct {
258 char *locale;
259 wchar_t *wlocale;
260 int *refcount;
261 int *wrefcount;
262 } lc_category[6];
263 int lc_clike;
264 int mb_cur_max;
265 int *lconv_intl_refcount;
266 int *lconv_num_refcount;
267 int *lconv_mon_refcount;
268 struct lconv *lconv;
269 int *ctype1_refcount;
270 unsigned short *ctype1;
271 const unsigned short *pctype;
272 const unsigned char *pclmap;
273 const unsigned char *pcumap;
274 struct __lc_time_data *lc_time_curr;
275 } threadlocinfo;
276 #define _THREADLOCALEINFO
277 #endif
279 #endif /* __WINE_CORECRT_H */