winecoreaudio: Remove GetAudioSessionWrapper.
[wine.git] / dlls / msvcrt / msvcrt.h
blob155db86bf023a526f299c28a7ee4beeaebf66532
1 /*
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
23 #include <errno.h>
24 #include <stdarg.h>
25 #include <stdint.h>
26 #define _NO_CRT_STDIO_INLINE
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <wchar.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #undef strncpy
34 #undef wcsncpy
36 extern BOOL sse2_supported DECLSPEC_HIDDEN;
38 #define DBL80_MAX_10_EXP 4932
39 #define DBL80_MIN_10_EXP -4951
41 typedef void (__cdecl *terminate_function)(void);
42 typedef void (__cdecl *unexpected_function)(void);
43 typedef void (__cdecl *_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
44 void __cdecl terminate(void);
46 typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
48 typedef struct {ULONG x80[3];} MSVCRT__LDOUBLE; /* Intel 80 bit FP format has sizeof() 12 */
50 typedef struct __lc_time_data {
51 union {
52 const char *str[43];
53 struct {
54 const char *short_wday[7];
55 const char *wday[7];
56 const char *short_mon[12];
57 const char *mon[12];
58 const char *am;
59 const char *pm;
60 const char *short_date;
61 const char *date;
62 const char *time;
63 } names;
64 } str;
65 #if _MSVCR_VER < 110
66 LCID lcid;
67 #endif
68 int unk;
69 LONG refcount;
70 #if _MSVCR_VER == 0 || _MSVCR_VER >= 100
71 union {
72 const wchar_t *wstr[43];
73 struct {
74 const wchar_t *short_wday[7];
75 const wchar_t *wday[7];
76 const wchar_t *short_mon[12];
77 const wchar_t *mon[12];
78 const wchar_t *am;
79 const wchar_t *pm;
80 const wchar_t *short_date;
81 const wchar_t *date;
82 const wchar_t *time;
83 } names;
84 } wstr;
85 #endif
86 #if _MSVCR_VER >= 110
87 const wchar_t *locname;
88 #endif
89 char data[1];
90 } __lc_time_data;
92 typedef struct threadmbcinfostruct {
93 LONG refcount;
94 int mbcodepage;
95 int ismbcodepage;
96 int mblcid;
97 unsigned short mbulinfo[6];
98 unsigned char mbctype[257];
99 unsigned char mbcasemap[256];
100 } threadmbcinfo;
102 typedef struct _frame_info
104 void *object;
105 struct _frame_info *next;
106 } frame_info;
108 typedef struct
110 frame_info frame_info;
111 EXCEPTION_RECORD *rec;
112 CONTEXT *context;
113 } cxx_frame_info;
115 frame_info* __cdecl _CreateFrameInfo(frame_info *fi, void *obj);
116 BOOL __cdecl __CxxRegisterExceptionObject(EXCEPTION_POINTERS*, cxx_frame_info*);
117 void __cdecl __CxxUnregisterExceptionObject(cxx_frame_info*, BOOL);
118 void CDECL __DestructExceptionObject(EXCEPTION_RECORD*);
120 #if defined(__x86_64__) && _MSVCR_VER>=140
121 void** __cdecl __current_exception(void);
122 int* __cdecl __processing_throw(void);
123 void __cdecl terminate(void);
125 BOOL msvcrt_init_handler4(void);
126 void msvcrt_attach_handler4(void);
127 void msvcrt_free_handler4(void);
128 #endif
130 /* TLS data */
131 extern DWORD msvcrt_tls_index DECLSPEC_HIDDEN;
133 #define LOCALE_FREE 0x1
134 #define LOCALE_THREAD 0x2
136 /* Keep in sync with msvcr90/tests/msvcr90.c */
137 struct __thread_data {
138 DWORD tid;
139 HANDLE handle;
140 int thread_errno;
141 __msvcrt_ulong thread_doserrno;
142 int unk1;
143 unsigned int random_seed; /* seed for rand() */
144 char *strtok_next; /* next ptr for strtok() */
145 wchar_t *wcstok_next; /* next ptr for wcstok() */
146 unsigned char *mbstok_next; /* next ptr for mbstok() */
147 char *strerror_buffer; /* buffer for strerror */
148 wchar_t *wcserror_buffer; /* buffer for wcserror */
149 char *tmpnam_buffer; /* buffer for tmpname() */
150 wchar_t *wtmpnam_buffer; /* buffer for wtmpname() */
151 void *unk2[2];
152 char *asctime_buffer; /* buffer for asctime */
153 wchar_t *wasctime_buffer; /* buffer for wasctime */
154 struct tm *time_buffer; /* buffer for localtime/gmtime */
155 char *efcvt_buffer; /* buffer for ecvt/fcvt */
156 int unk3[2];
157 void *unk4[3];
158 EXCEPTION_POINTERS *xcptinfo;
159 int fpecode;
160 pthreadmbcinfo mbcinfo;
161 pthreadlocinfo locinfo;
162 int locale_flags;
163 int unk5[1];
164 terminate_function terminate_handler;
165 unexpected_function unexpected_handler;
166 _se_translator_function se_translator; /* preserve offset to exc_record and processing_throw */
167 void *unk6;
168 EXCEPTION_RECORD *exc_record;
169 CONTEXT *ctx_record;
170 int processing_throw;
171 frame_info *frame_info_head;
172 void *unk8[6];
173 BOOL cached_sname_match;
174 WCHAR cached_sname[LOCALE_NAME_MAX_LENGTH];
175 int unk9[2];
176 DWORD cached_cp;
177 char cached_locale[131];
178 void *unk10[100];
179 #if _MSVCR_VER >= 140
180 _invalid_parameter_handler invalid_parameter_handler;
181 HMODULE module;
182 #endif
185 typedef struct __thread_data thread_data_t;
187 extern thread_data_t *CDECL msvcrt_get_thread_data(void) DECLSPEC_HIDDEN;
189 BOOL locale_to_sname(const char*, unsigned short*, BOOL*, WCHAR*, int) DECLSPEC_HIDDEN;
190 extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN;
191 extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN;
192 extern unsigned int MSVCRT___lc_codepage;
193 extern int MSVCRT___lc_collate_cp;
194 extern WORD MSVCRT__ctype [257];
195 extern BOOL initial_locale DECLSPEC_HIDDEN;
196 extern WORD *MSVCRT__pwctype;
198 void msvcrt_set_errno(int) DECLSPEC_HIDDEN;
199 #if _MSVCR_VER >= 80
200 void throw_bad_alloc(void) DECLSPEC_HIDDEN;
201 #endif
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_concurrency(void*) DECLSPEC_HIDDEN;
247 extern void msvcrt_free_concurrency(void) DECLSPEC_HIDDEN;
248 extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN;
249 #endif
251 extern BOOL msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
253 /* run-time error codes */
254 #define _RT_STACK 0
255 #define _RT_NULLPTR 1
256 #define _RT_FLOAT 2
257 #define _RT_INTDIV 3
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
263 #define _RT_ABORT 10
264 #define _RT_NPTR 12
265 #define _RT_FPTR 13
266 #define _RT_BREAK 14
267 #define _RT_INT 15
268 #define _RT_THREAD 16
269 #define _RT_LOCK 17
270 #define _RT_HEAP 18
271 #define _RT_OPENCON 19
272 #define _RT_QWIN 20
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
282 #define _RT_SING 121
283 #define _RT_TLOSS 122
284 #define _RT_CRNL 252
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;
311 enum fpmod {
312 FP_ROUND_ZERO, /* only used when dropped part contains only zeros */
313 FP_ROUND_DOWN,
314 FP_ROUND_EVEN,
315 FP_ROUND_UP,
316 FP_VAL_INFINITY,
317 FP_VAL_NAN
320 struct fpnum {
321 int sign;
322 int exp;
323 ULONGLONG m;
324 enum fpmod mod;
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
333 * any information
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
345 void *get_ptr;
346 int get_int;
347 LONGLONG get_longlong;
348 double get_double;
349 } printf_arg;
350 typedef printf_arg (*args_clbk)(void*, int, int, va_list*);
351 int pf_printf_a(puts_clbk_a, void*, const char*, _locale_t,
352 DWORD, args_clbk, void*, va_list*) DECLSPEC_HIDDEN;
353 int pf_printf_w(puts_clbk_w, void*, const wchar_t*, _locale_t,
354 DWORD, args_clbk, void*, va_list*) DECLSPEC_HIDDEN;
355 int create_positional_ctx_a(void*, const char*, va_list) DECLSPEC_HIDDEN;
356 int create_positional_ctx_w(void*, const wchar_t*, va_list) DECLSPEC_HIDDEN;
357 printf_arg arg_clbk_valist(void*, int, int, va_list*) DECLSPEC_HIDDEN;
358 printf_arg arg_clbk_positional(void*, int, int, 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 */