2 * Copyright 2001 Jon Griffiths
3 * Copyright 2004 Dimitrie O. Paun
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_MSVCRT_H
21 #define __WINE_MSVCRT_H
26 #define _NO_CRT_STDIO_INLINE
35 extern BOOL sse2_supported DECLSPEC_HIDDEN
;
37 #define DBL80_MAX_10_EXP 4932
38 #define DBL80_MIN_10_EXP -4951
40 typedef void (__cdecl
*terminate_function
)(void);
41 typedef void (__cdecl
*unexpected_function
)(void);
42 typedef void (__cdecl
*_se_translator_function
)(unsigned int code
, struct _EXCEPTION_POINTERS
*info
);
43 void __cdecl
terminate(void);
45 typedef void (__cdecl
*MSVCRT_security_error_handler
)(int, void *);
47 typedef struct {ULONG x80
[3];} MSVCRT__LDOUBLE
; /* Intel 80 bit FP format has sizeof() 12 */
49 typedef struct __lc_time_data
{
53 const char *short_wday
[7];
55 const char *short_mon
[12];
59 const char *short_date
;
69 #if _MSVCR_VER == 0 || _MSVCR_VER >= 100
71 const wchar_t *wstr
[43];
73 const wchar_t *short_wday
[7];
74 const wchar_t *wday
[7];
75 const wchar_t *short_mon
[12];
76 const wchar_t *mon
[12];
79 const wchar_t *short_date
;
86 const wchar_t *locname
;
91 typedef struct threadmbcinfostruct
{
96 unsigned short mbulinfo
[6];
97 unsigned char mbctype
[257];
98 unsigned char mbcasemap
[256];
101 typedef struct _frame_info
104 struct _frame_info
*next
;
109 frame_info frame_info
;
110 EXCEPTION_RECORD
*rec
;
114 frame_info
* __cdecl
_CreateFrameInfo(frame_info
*fi
, void *obj
);
115 BOOL __cdecl
__CxxRegisterExceptionObject(EXCEPTION_POINTERS
*, cxx_frame_info
*);
116 void __cdecl
__CxxUnregisterExceptionObject(cxx_frame_info
*, BOOL
);
117 void CDECL
__DestructExceptionObject(EXCEPTION_RECORD
*);
120 extern DWORD msvcrt_tls_index DECLSPEC_HIDDEN
;
122 #define LOCALE_FREE 0x1
123 #define LOCALE_THREAD 0x2
125 /* Keep in sync with msvcr90/tests/msvcr90.c */
126 struct __thread_data
{
130 __msvcrt_ulong thread_doserrno
;
132 unsigned int random_seed
; /* seed for rand() */
133 char *strtok_next
; /* next ptr for strtok() */
134 wchar_t *wcstok_next
; /* next ptr for wcstok() */
135 unsigned char *mbstok_next
; /* next ptr for mbstok() */
136 char *strerror_buffer
; /* buffer for strerror */
137 wchar_t *wcserror_buffer
; /* buffer for wcserror */
138 char *tmpnam_buffer
; /* buffer for tmpname() */
139 wchar_t *wtmpnam_buffer
; /* buffer for wtmpname() */
141 char *asctime_buffer
; /* buffer for asctime */
142 wchar_t *wasctime_buffer
; /* buffer for wasctime */
143 struct tm
*time_buffer
; /* buffer for localtime/gmtime */
144 char *efcvt_buffer
; /* buffer for ecvt/fcvt */
147 EXCEPTION_POINTERS
*xcptinfo
;
149 pthreadmbcinfo mbcinfo
;
150 pthreadlocinfo locinfo
;
153 terminate_function terminate_handler
;
154 unexpected_function unexpected_handler
;
155 _se_translator_function se_translator
; /* preserve offset to exc_record and processing_throw */
157 EXCEPTION_RECORD
*exc_record
;
159 int processing_throw
;
160 frame_info
*frame_info_head
;
166 char cached_locale
[131];
168 #if _MSVCR_VER >= 140
169 _invalid_parameter_handler invalid_parameter_handler
;
173 typedef struct __thread_data thread_data_t
;
175 extern thread_data_t
*CDECL
msvcrt_get_thread_data(void) DECLSPEC_HIDDEN
;
177 LCID
locale_to_LCID(const char*, unsigned short*, BOOL
*) DECLSPEC_HIDDEN
;
178 extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN
;
179 extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN
;
180 extern unsigned int MSVCRT___lc_codepage
;
181 extern int MSVCRT___lc_collate_cp
;
182 extern WORD MSVCRT__ctype
[257];
183 extern BOOL initial_locale DECLSPEC_HIDDEN
;
184 extern WORD
*MSVCRT__pwctype
;
186 void msvcrt_set_errno(int) DECLSPEC_HIDDEN
;
190 #if _MSVCR_VER >= 100
191 EXCEPTION_SCHEDULER_RESOURCE_ALLOCATION_ERROR
,
192 EXCEPTION_IMPROPER_LOCK
,
193 EXCEPTION_INVALID_SCHEDULER_POLICY_KEY
,
194 EXCEPTION_INVALID_SCHEDULER_POLICY_VALUE
,
195 EXCEPTION_INVALID_SCHEDULER_POLICY_THREAD_SPECIFICATION
,
196 EXCEPTION_IMPROPER_SCHEDULER_ATTACH
,
197 EXCEPTION_IMPROPER_SCHEDULER_DETACH
,
200 void throw_exception(exception_type
, HRESULT
, const char*) DECLSPEC_HIDDEN
;
203 void __cdecl
_purecall(void);
204 void __cdecl
_amsg_exit(int errnum
);
206 extern char **MSVCRT__environ
;
207 extern wchar_t **MSVCRT__wenviron
;
209 extern char ** msvcrt_SnapshotOfEnvironmentA(char **) DECLSPEC_HIDDEN
;
210 extern wchar_t ** msvcrt_SnapshotOfEnvironmentW(wchar_t **) DECLSPEC_HIDDEN
;
212 wchar_t *msvcrt_wstrdupa(const char *) DECLSPEC_HIDDEN
;
214 extern unsigned int MSVCRT__commode
;
216 /* FIXME: This should be declared in new.h but it's not an extern "C" so
217 * it would not be much use anyway. Even for Winelib applications.
219 void* __cdecl
operator_new(size_t);
220 void __cdecl
operator_delete(void*);
221 int __cdecl
_set_new_mode(int mode
);
223 typedef void* (__cdecl
*malloc_func_t
)(size_t);
224 typedef void (__cdecl
*free_func_t
)(void*);
226 /* Setup and teardown multi threaded locks */
227 extern void msvcrt_init_mt_locks(void) DECLSPEC_HIDDEN
;
228 extern void msvcrt_free_locks(void) DECLSPEC_HIDDEN
;
230 extern void msvcrt_init_exception(void*) DECLSPEC_HIDDEN
;
231 extern BOOL
msvcrt_init_locale(void) DECLSPEC_HIDDEN
;
232 extern void msvcrt_init_math(void*) DECLSPEC_HIDDEN
;
233 extern void msvcrt_init_io(void) DECLSPEC_HIDDEN
;
234 extern void msvcrt_free_io(void) DECLSPEC_HIDDEN
;
235 extern void msvcrt_free_console(void) DECLSPEC_HIDDEN
;
236 extern void msvcrt_init_args(void) DECLSPEC_HIDDEN
;
237 extern void msvcrt_free_args(void) DECLSPEC_HIDDEN
;
238 extern void msvcrt_init_signals(void) DECLSPEC_HIDDEN
;
239 extern void msvcrt_free_signals(void) DECLSPEC_HIDDEN
;
240 extern void msvcrt_free_popen_data(void) DECLSPEC_HIDDEN
;
241 extern BOOL
msvcrt_init_heap(void) DECLSPEC_HIDDEN
;
242 extern void msvcrt_destroy_heap(void) DECLSPEC_HIDDEN
;
243 extern void msvcrt_init_clock(void) DECLSPEC_HIDDEN
;
245 #if _MSVCR_VER >= 100
246 extern void msvcrt_init_scheduler(void*) DECLSPEC_HIDDEN
;
247 extern void msvcrt_free_scheduler(void) DECLSPEC_HIDDEN
;
248 extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN
;
251 extern unsigned msvcrt_create_io_inherit_block(WORD
*, BYTE
**) DECLSPEC_HIDDEN
;
253 /* run-time error codes */
255 #define _RT_NULLPTR 1
258 #define _RT_EXECMEM 5
259 #define _RT_EXECFORM 6
260 #define _RT_EXECENV 7
261 #define _RT_SPACEARG 8
262 #define _RT_SPACEENV 9
268 #define _RT_THREAD 16
271 #define _RT_OPENCON 19
273 #define _RT_NOMAIN 21
274 #define _RT_NONCONT 22
275 #define _RT_INVALDISP 23
276 #define _RT_ONEXIT 24
277 #define _RT_PUREVIRT 25
278 #define _RT_STDIOINIT 26
279 #define _RT_LOWIOINIT 27
280 #define _RT_HEAPINIT 28
281 #define _RT_DOMAIN 120
283 #define _RT_TLOSS 122
285 #define _RT_BANNER 255
287 extern FILE MSVCRT__iob
[];
289 #define MSVCRT_NO_CONSOLE_FD (-2)
290 #define MSVCRT_NO_CONSOLE ((HANDLE)MSVCRT_NO_CONSOLE_FD)
292 #define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
293 #define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
294 #define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
296 /* internal file._flag flags */
297 #define MSVCRT__USERBUF 0x0100
298 #define MSVCRT__IOCOMMIT 0x4000
300 #define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
302 _locale_t CDECL
get_current_locale_noalloc(_locale_t locale
) DECLSPEC_HIDDEN
;
303 void CDECL
free_locale_noalloc(_locale_t locale
) DECLSPEC_HIDDEN
;
304 pthreadlocinfo CDECL
get_locinfo(void) DECLSPEC_HIDDEN
;
305 pthreadmbcinfo CDECL
get_mbcinfo(void) DECLSPEC_HIDDEN
;
306 threadmbcinfo
* create_mbcinfo(int, LCID
, threadmbcinfo
*) DECLSPEC_HIDDEN
;
307 void free_locinfo(pthreadlocinfo
) DECLSPEC_HIDDEN
;
308 void free_mbcinfo(pthreadmbcinfo
) DECLSPEC_HIDDEN
;
309 int __cdecl
__crtLCMapStringA(LCID
, DWORD
, const char*, int, char*, int, unsigned int, int) DECLSPEC_HIDDEN
;
312 FP_ROUND_ZERO
, /* only used when dropped part contains only zeros */
326 struct fpnum
fpnum_parse(wchar_t (*)(void*), void (*)(void*),
327 void*, pthreadlocinfo
, BOOL
) DECLSPEC_HIDDEN
;
328 int fpnum_double(struct fpnum
*, double*) DECLSPEC_HIDDEN
;
329 /* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
330 * #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
331 * #define MSVCRT_CHECK_PMT(x) ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
332 * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
334 * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around _invalid_parameter in order
335 * to do the Ansi to Unicode transformation
337 #define MSVCRT_INVALID_PMT(x,err) (*_errno() = (err), _invalid_parameter(NULL, NULL, NULL, 0, 0))
338 #define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
339 #define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), EINVAL)
341 typedef int (*puts_clbk_a
)(void*, int, const char*);
342 typedef int (*puts_clbk_w
)(void*, int, const wchar_t*);
343 typedef union _printf_arg
347 LONGLONG get_longlong
;
350 typedef printf_arg (*args_clbk
)(void*, int, int, __ms_va_list
*);
351 int pf_printf_a(puts_clbk_a
, void*, const char*, _locale_t
,
352 DWORD
, args_clbk
, void*, __ms_va_list
*) DECLSPEC_HIDDEN
;
353 int pf_printf_w(puts_clbk_w
, void*, const wchar_t*, _locale_t
,
354 DWORD
, args_clbk
, void*, __ms_va_list
*) DECLSPEC_HIDDEN
;
355 int create_positional_ctx_a(void*, const char*, __ms_va_list
) DECLSPEC_HIDDEN
;
356 int create_positional_ctx_w(void*, const wchar_t*, __ms_va_list
) DECLSPEC_HIDDEN
;
357 printf_arg
arg_clbk_valist(void*, int, int, __ms_va_list
*) DECLSPEC_HIDDEN
;
358 printf_arg
arg_clbk_positional(void*, int, int, __ms_va_list
*) DECLSPEC_HIDDEN
;
360 extern char* __cdecl
__unDName(char *,const char*,int,malloc_func_t
,free_func_t
,unsigned short int);
362 /* __unDName/__unDNameEx flags */
363 #define UNDNAME_COMPLETE (0x0000)
364 #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */
365 #define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */
366 #define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */
367 #define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
368 #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
369 #define UNDNAME_NO_MS_THISTYPE (0x0020)
370 #define UNDNAME_NO_CV_THISTYPE (0x0040)
371 #define UNDNAME_NO_THISTYPE (0x0060)
372 #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */
373 #define UNDNAME_NO_THROW_SIGNATURES (0x0100)
374 #define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */
375 #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
376 #define UNDNAME_32_BIT_DECODE (0x0800)
377 #define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */
378 #define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */
379 #define UNDNAME_NO_SPECIAL_SYMS (0x4000)
380 #define UNDNAME_NO_COMPLEX_TYPE (0x8000)
382 #define UCRTBASE_PRINTF_MASK ( \
383 _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION | \
384 _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR | \
385 _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | \
386 _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | \
387 _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | \
388 _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING )
390 #define MSVCRT_PRINTF_POSITIONAL_PARAMS (0x0100)
391 #define MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER (0x0200)
393 #define UCRTBASE_SCANF_MASK ( \
394 _CRT_INTERNAL_SCANF_SECURECRT | \
395 _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS | \
396 _CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY )
398 #define COOPERATIVE_TIMEOUT_INFINITE ((unsigned int)-1)
399 #define COOPERATIVE_WAIT_TIMEOUT ~0
401 #define INHERIT_THREAD_PRIORITY 0xF000
403 #endif /* __WINE_MSVCRT_H */