msvcrt: Import log1pf implementation from musl.
[wine.git] / include / msvcrt / corecrt.h
blob4adbe0920f6155e53591328b173a6cfd095ef3e7
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 #ifndef _MSVCR_VER
37 # define _MSVCR_VER 140
38 #endif
40 #if !defined(_UCRT) && _MSVCR_VER >= 140
41 # define _UCRT
42 #endif
44 #if !defined(_MSC_VER) && !defined(__int64)
45 # if defined(_WIN64) && !defined(__MINGW64__)
46 # define __int64 long
47 # else
48 # define __int64 long long
49 # endif
50 #endif
52 #ifndef NULL
53 #ifdef __cplusplus
54 #define NULL 0
55 #else
56 #define NULL ((void *)0)
57 #endif
58 #endif
60 #ifndef __has_attribute
61 #define __has_attribute(x) 0
62 #endif
64 #ifndef _MSC_VER
65 # undef __stdcall
66 # ifdef __i386__
67 # ifdef __GNUC__
68 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
69 # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
70 # else
71 # define __stdcall __attribute__((__stdcall__))
72 # endif
73 # else
74 # error You need to define __stdcall for your compiler
75 # endif
76 # elif defined(__x86_64__) && defined (__GNUC__)
77 # if __has_attribute(__force_align_arg_pointer__)
78 # define __stdcall __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
79 # else
80 # define __stdcall __attribute__((ms_abi))
81 # endif
82 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__) && !defined(_WIN32)
83 # define __stdcall __attribute__((pcs("aapcs-vfp")))
84 # elif defined(__aarch64__) && defined (__GNUC__) && __has_attribute(ms_abi)
85 # define __stdcall __attribute__((ms_abi))
86 # else /* __i386__ */
87 # define __stdcall
88 # endif /* __i386__ */
89 #endif /* __stdcall */
91 #ifndef _MSC_VER
92 # undef __cdecl
93 # if defined(__i386__) && defined(__GNUC__)
94 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
95 # define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
96 # else
97 # define __cdecl __attribute__((__cdecl__))
98 # endif
99 # else
100 # define __cdecl __stdcall
101 # endif
102 #endif
104 #ifndef __ms_va_list
105 # if (defined(__x86_64__) || (defined(__aarch64__) && __has_attribute(ms_abi))) && defined (__GNUC__)
106 # define __ms_va_list __builtin_ms_va_list
107 # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
108 # define __ms_va_end(list) __builtin_ms_va_end(list)
109 # define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
110 # else
111 # define __ms_va_list va_list
112 # define __ms_va_start(list,arg) va_start(list,arg)
113 # define __ms_va_end(list) va_end(list)
114 # ifdef va_copy
115 # define __ms_va_copy(dest,src) va_copy(dest,src)
116 # else
117 # define __ms_va_copy(dest,src) ((dest) = (src))
118 # endif
119 # endif
120 #endif
122 #ifndef WINAPIV
123 # if defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__) && !defined(_WIN32)
124 # define WINAPIV __attribute__((pcs("aapcs")))
125 # else
126 # define WINAPIV __cdecl
127 # endif
128 #endif
130 #ifndef DECLSPEC_NORETURN
131 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
132 # define DECLSPEC_NORETURN __declspec(noreturn)
133 # elif defined(__GNUC__)
134 # define DECLSPEC_NORETURN __attribute__((noreturn))
135 # else
136 # define DECLSPEC_NORETURN
137 # endif
138 #endif
140 #ifndef DECLSPEC_ALIGN
141 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
142 # define DECLSPEC_ALIGN(x) __declspec(align(x))
143 # elif defined(__GNUC__)
144 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
145 # else
146 # define DECLSPEC_ALIGN(x)
147 # endif
148 #endif
150 #ifndef _ACRTIMP
151 # ifdef _CRTIMP
152 # define _ACRTIMP _CRTIMP
153 # elif defined(_MSC_VER)
154 # define _ACRTIMP __declspec(dllimport)
155 # elif defined(__MINGW32__) || defined(__CYGWIN__)
156 # define _ACRTIMP __attribute__((dllimport))
157 # else
158 # define _ACRTIMP
159 # endif
160 #endif
162 #define _ARGMAX 100
163 #define _CRT_INT_MAX 0x7fffffff
165 #ifndef _MSVCRT_LONG_DEFINED
166 #define _MSVCRT_LONG_DEFINED
167 /* we need 32-bit longs even on 64-bit */
168 #ifdef __LP64__
169 typedef int __msvcrt_long;
170 typedef unsigned int __msvcrt_ulong;
171 #else
172 typedef long __msvcrt_long;
173 typedef unsigned long __msvcrt_ulong;
174 #endif
175 #endif
177 #ifndef _INTPTR_T_DEFINED
178 #ifdef _WIN64
179 typedef __int64 intptr_t;
180 #else
181 typedef int intptr_t;
182 #endif
183 #define _INTPTR_T_DEFINED
184 #endif
186 #ifndef _UINTPTR_T_DEFINED
187 #ifdef _WIN64
188 typedef unsigned __int64 uintptr_t;
189 #else
190 typedef unsigned int uintptr_t;
191 #endif
192 #define _UINTPTR_T_DEFINED
193 #endif
195 #ifndef _PTRDIFF_T_DEFINED
196 #ifdef _WIN64
197 typedef __int64 ptrdiff_t;
198 #else
199 typedef int ptrdiff_t;
200 #endif
201 #define _PTRDIFF_T_DEFINED
202 #endif
204 #ifndef _SIZE_T_DEFINED
205 #ifdef _WIN64
206 typedef unsigned __int64 size_t;
207 #else
208 typedef unsigned int size_t;
209 #endif
210 #define _SIZE_T_DEFINED
211 #endif
213 #ifndef _TIME32_T_DEFINED
214 typedef __msvcrt_long __time32_t;
215 #define _TIME32_T_DEFINED
216 #endif
218 #ifndef _TIME64_T_DEFINED
219 typedef __int64 DECLSPEC_ALIGN(8) __time64_t;
220 #define _TIME64_T_DEFINED
221 #endif
223 #ifdef _USE_32BIT_TIME_T
224 # ifdef _WIN64
225 # error You cannot use 32-bit time_t in Win64
226 # endif
227 #elif !defined(_WIN64)
228 # define _USE_32BIT_TIME_T
229 #endif
231 #ifndef _TIME_T_DEFINED
232 #ifdef _USE_32BIT_TIME_T
233 typedef __time32_t time_t;
234 #else
235 typedef __time64_t time_t;
236 #endif
237 #define _TIME_T_DEFINED
238 #endif
240 #ifndef _WCHAR_T_DEFINED
241 #ifndef __cplusplus
242 typedef unsigned short wchar_t;
243 #endif
244 #define _WCHAR_T_DEFINED
245 #endif
247 #ifndef _WCTYPE_T_DEFINED
248 typedef unsigned short wint_t;
249 typedef unsigned short wctype_t;
250 #define _WCTYPE_T_DEFINED
251 #endif
253 #ifndef _ERRNO_T_DEFINED
254 typedef int errno_t;
255 #define _ERRNO_T_DEFINED
256 #endif
258 struct threadlocaleinfostruct;
259 struct threadmbcinfostruct;
260 typedef struct threadlocaleinfostruct *pthreadlocinfo;
261 typedef struct threadmbcinfostruct *pthreadmbcinfo;
263 typedef struct localeinfo_struct
265 pthreadlocinfo locinfo;
266 pthreadmbcinfo mbcinfo;
267 } _locale_tstruct, *_locale_t;
269 #ifndef _TAGLC_ID_DEFINED
270 typedef struct tagLC_ID {
271 unsigned short wLanguage;
272 unsigned short wCountry;
273 unsigned short wCodePage;
274 } LC_ID, *LPLC_ID;
275 #define _TAGLC_ID_DEFINED
276 #endif
278 #ifndef _THREADLOCALEINFO
279 typedef struct threadlocaleinfostruct {
280 #if _MSVCR_VER >= 140
281 unsigned short *pctype;
282 int mb_cur_max;
283 unsigned int lc_codepage;
284 #endif
286 int refcount;
287 #if _MSVCR_VER < 140
288 unsigned int lc_codepage;
289 #endif
290 unsigned int lc_collate_cp;
291 __msvcrt_ulong lc_handle[6];
292 LC_ID lc_id[6];
293 struct {
294 char *locale;
295 wchar_t *wlocale;
296 int *refcount;
297 int *wrefcount;
298 } lc_category[6];
299 int lc_clike;
300 #if _MSVCR_VER < 140
301 int mb_cur_max;
302 #endif
303 int *lconv_intl_refcount;
304 int *lconv_num_refcount;
305 int *lconv_mon_refcount;
306 struct lconv *lconv;
307 int *ctype1_refcount;
308 unsigned short *ctype1;
309 #if _MSVCR_VER < 140
310 unsigned short *pctype;
311 #endif
312 const unsigned char *pclmap;
313 const unsigned char *pcumap;
314 struct __lc_time_data *lc_time_curr;
315 #if _MSVCR_VER >= 110
316 wchar_t *lc_name[6];
317 #endif
318 } threadlocinfo;
319 #define _THREADLOCALEINFO
320 #endif
322 #endif /* __WINE_CORECRT_H */