msvcr90/tests: Added _getptd tests.
[wine] / dlls / msvcrt / msvcrt.h
1 /*
2  * Copyright 2001 Jon Griffiths
3  * Copyright 2004 Dimitrie O. Paun
4  *
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.
9  *
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.
14  *
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
18  *
19  * NOTES
20  *   Naming conventions
21  *      - Symbols are prefixed with MSVCRT_ if they conflict
22  *        with libc symbols
23  *      - Internal symbols are usually prefixed by msvcrt_.
24  *      - Exported symbols that are not present in the public
25  *        headers are usually kept the same as the original.
26  *   Other conventions
27  *      - To avoid conflicts with the standard C library,
28  *        no msvcrt headers are included in the implementation.
29  *      - Instead, symbols are duplicated here, prefixed with 
30  *        MSVCRT_, as explained above.
31  *      - To avoid inconsistencies, a test for each symbol is
32  *        added into tests/headers.c. Please always add a
33  *        corresponding test when you add a new symbol!
34  */
35
36 #ifndef __WINE_MSVCRT_H
37 #define __WINE_MSVCRT_H
38
39 #include <stdarg.h>
40
41 #include "windef.h"
42 #include "winbase.h"
43
44 #define MSVCRT_LONG_MAX    0x7fffffffL
45 #define MSVCRT_ULONG_MAX   0xffffffffUL
46 #define MSVCRT_I64_MAX    (((__int64)0x7fffffff << 32) | 0xffffffff)
47 #define MSVCRT_I64_MIN    (-MSVCRT_I64_MAX-1)
48 #define MSVCRT_UI64_MAX   (((unsigned __int64)0xffffffff << 32) | 0xffffffff)
49
50 #define MSVCRT__MAX_DRIVE  3
51 #define MSVCRT__MAX_DIR    256
52 #define MSVCRT__MAX_FNAME  256
53 #define MSVCRT__MAX_EXT    256
54
55 typedef unsigned short MSVCRT_wchar_t;
56 typedef unsigned short MSVCRT_wint_t;
57 typedef unsigned short MSVCRT_wctype_t;
58 typedef unsigned short MSVCRT__ino_t;
59 typedef unsigned int   MSVCRT__fsize_t;
60 typedef int            MSVCRT_long;
61 typedef unsigned int   MSVCRT_ulong;
62 #ifdef _WIN64
63 typedef unsigned __int64 MSVCRT_size_t;
64 typedef __int64 MSVCRT_intptr_t;
65 typedef unsigned __int64 MSVCRT_uintptr_t;
66 #else
67 typedef unsigned long MSVCRT_size_t;
68 typedef long MSVCRT_intptr_t;
69 typedef unsigned long MSVCRT_uintptr_t;
70 #endif
71 typedef unsigned int   MSVCRT__dev_t;
72 typedef int MSVCRT__off_t;
73 typedef int MSVCRT_clock_t;
74 typedef int MSVCRT___time32_t;
75 typedef __int64 DECLSPEC_ALIGN(8) MSVCRT___time64_t;
76 typedef __int64 DECLSPEC_ALIGN(8) MSVCRT_fpos_t;
77 typedef int MSVCRT_mbstate_t;
78
79 typedef void (*__cdecl MSVCRT_terminate_handler)(void);
80 typedef void (*__cdecl MSVCRT_terminate_function)(void);
81 typedef void (*__cdecl MSVCRT_unexpected_handler)(void);
82 typedef void (*__cdecl MSVCRT_unexpected_function)(void);
83 typedef void (*__cdecl MSVCRT__se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
84 typedef void (*__cdecl MSVCRT__beginthread_start_routine_t)(void *);
85 typedef unsigned int (__stdcall *MSVCRT__beginthreadex_start_routine_t)(void *);
86 typedef int (*__cdecl MSVCRT__onexit_t)(void);
87 typedef void (__cdecl *MSVCRT_invalid_parameter_handler)(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, unsigned, MSVCRT_uintptr_t);
88 typedef void (__cdecl *MSVCRT_purecall_handler)(void);
89 typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
90
91 typedef struct {ULONG x80[3];} MSVCRT__LDOUBLE; /* Intel 80 bit FP format has sizeof() 12 */
92
93 struct MSVCRT_tm {
94     int tm_sec;
95     int tm_min;
96     int tm_hour;
97     int tm_mday;
98     int tm_mon;
99     int tm_year;
100     int tm_wday;
101     int tm_yday;
102     int tm_isdst;
103 };
104
105 typedef struct MSVCRT_tagLC_ID {
106     unsigned short wLanguage;
107     unsigned short wCountry;
108     unsigned short wCodePage;
109 } MSVCRT_LC_ID, *MSVCRT_LPLC_ID;
110
111 typedef struct MSVCRT_threadlocaleinfostruct {
112     int refcount;
113     unsigned int lc_codepage;
114     unsigned int lc_collate_cp;
115     unsigned long lc_handle[6];
116     MSVCRT_LC_ID lc_id[6];
117     struct {
118         char *locale;
119         wchar_t *wlocale;
120         int *refcount;
121         int *wrefcount;
122     } lc_category[6];
123     int lc_clike;
124     int mb_cur_max;
125     int *lconv_intl_refcount;
126     int *lconv_num_refcount;
127     int *lconv_mon_refcount;
128     struct MSVCRT_lconv *lconv;
129     int *ctype1_refcount;
130     unsigned short *ctype1;
131     unsigned short *pctype;
132     unsigned char *pclmap;
133     unsigned char *pcumap;
134     struct MSVCRT___lc_time_data *lc_time_curr;
135 } MSVCRT_threadlocinfo;
136
137 typedef struct MSVCRT_threadmbcinfostruct {
138     int refcount;
139     int mbcodepage;
140     int ismbcodepage;
141     int mblcid;
142     unsigned short mbulinfo[6];
143     char mbctype[257];
144     char mbcasemap[256];
145 } MSVCRT_threadmbcinfo;
146
147 typedef struct MSVCRT_threadlocaleinfostruct *MSVCRT_pthreadlocinfo;
148 typedef struct MSVCRT_threadmbcinfostruct *MSVCRT_pthreadmbcinfo;
149
150 typedef struct MSVCRT_localeinfo_struct
151 {
152     MSVCRT_pthreadlocinfo locinfo;
153     MSVCRT_pthreadmbcinfo mbcinfo;
154 } MSVCRT__locale_tstruct, *MSVCRT__locale_t;
155
156
157 /* TLS data */
158 extern DWORD msvcrt_tls_index;
159
160 /* Keep in sync with msvcr90/tests/msvcr90.c */
161 struct __thread_data {
162     DWORD                           tid;
163     HANDLE                          handle;
164     int                             thread_errno;
165     MSVCRT_ulong                    thread_doserrno;
166     int                             unk1;
167     unsigned int                    random_seed;        /* seed for rand() */
168     char                           *strtok_next;        /* next ptr for strtok() */
169     MSVCRT_wchar_t                 *wcstok_next;        /* next ptr for wcstok() */
170     unsigned char                  *mbstok_next;        /* next ptr for mbstok() */
171     char                           *strerror_buffer;    /* buffer for strerror */
172     MSVCRT_wchar_t                 *wcserror_buffer;    /* buffer for wcserror */
173     char                           *tmpnam_buffer;      /* buffer for tmpname() */
174     MSVCRT_wchar_t                 *wtmpnam_buffer;     /* buffer for wtmpname() */
175     void                           *unk2[2];
176     char                           *asctime_buffer;     /* buffer for asctime */
177     MSVCRT_wchar_t                 *wasctime_buffer;    /* buffer for wasctime */
178     struct MSVCRT_tm               *time_buffer;        /* buffer for localtime/gmtime */
179     char                           *efcvt_buffer;       /* buffer for ecvt/fcvt */
180     int                             unk3[2];
181     void                           *unk4[4];
182     int                             fpecode;
183     MSVCRT_pthreadmbcinfo           mbcinfo;
184     MSVCRT_pthreadlocinfo           locinfo;
185     BOOL                            have_locale;
186     int                             unk5[1];
187     MSVCRT_terminate_function       terminate_handler;
188     MSVCRT_unexpected_function      unexpected_handler;
189     MSVCRT__se_translator_function  se_translator;
190     void                           *unk6[3];
191     int                             unk7;
192     EXCEPTION_RECORD               *exc_record;
193     void                           *unk8[100];
194 };
195
196 typedef struct __thread_data thread_data_t;
197
198 extern thread_data_t *msvcrt_get_thread_data(void);
199
200 extern int MSVCRT___lc_codepage;
201 extern int MSVCRT___lc_collate_cp;
202 extern int MSVCRT___mb_cur_max;
203 extern WORD MSVCRT__ctype [257];
204 extern unsigned short *MSVCRT__pctype;
205
206 void   msvcrt_set_errno(int);
207
208 void __cdecl _purecall(void);
209 void __cdecl _amsg_exit(int errnum);
210
211 extern char **MSVCRT__environ;
212 extern MSVCRT_wchar_t **MSVCRT__wenviron;
213
214 extern char ** msvcrt_SnapshotOfEnvironmentA(char **);
215 extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **);
216
217 MSVCRT_wchar_t *msvcrt_wstrdupa(const char *);
218
219 /* FIXME: This should be declared in new.h but it's not an extern "C" so
220  * it would not be much use anyway. Even for Winelib applications.
221  */
222 int __cdecl MSVCRT__set_new_mode(int mode);
223
224 void* __cdecl MSVCRT_operator_new(MSVCRT_size_t);
225 void __cdecl MSVCRT_operator_delete(void*);
226
227 typedef void* (*__cdecl malloc_func_t)(MSVCRT_size_t);
228 typedef void  (*__cdecl free_func_t)(void*);
229
230 extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);
231 extern char* __cdecl __unDNameEx(char *,const char*,int,malloc_func_t,free_func_t,void *,unsigned short int);
232
233 /* Setup and teardown multi threaded locks */
234 extern void msvcrt_init_mt_locks(void);
235 extern void msvcrt_free_mt_locks(void);
236
237 extern void msvcrt_init_math(void);
238 extern void msvcrt_init_io(void);
239 extern void msvcrt_free_io(void);
240 extern void msvcrt_init_console(void);
241 extern void msvcrt_free_console(void);
242 extern void msvcrt_init_args(void);
243 extern void msvcrt_free_args(void);
244 extern void msvcrt_init_signals(void);
245 extern void msvcrt_free_signals(void);
246
247 extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**);
248
249 extern unsigned int __cdecl _control87(unsigned int, unsigned int);
250
251 /* run-time error codes */
252 #define _RT_STACK       0
253 #define _RT_NULLPTR     1
254 #define _RT_FLOAT       2
255 #define _RT_INTDIV      3
256 #define _RT_EXECMEM     5
257 #define _RT_EXECFORM    6
258 #define _RT_EXECENV     7
259 #define _RT_SPACEARG    8
260 #define _RT_SPACEENV    9
261 #define _RT_ABORT       10
262 #define _RT_NPTR        12
263 #define _RT_FPTR        13
264 #define _RT_BREAK       14
265 #define _RT_INT         15
266 #define _RT_THREAD      16
267 #define _RT_LOCK        17
268 #define _RT_HEAP        18
269 #define _RT_OPENCON     19
270 #define _RT_QWIN        20
271 #define _RT_NOMAIN      21
272 #define _RT_NONCONT     22
273 #define _RT_INVALDISP   23
274 #define _RT_ONEXIT      24
275 #define _RT_PUREVIRT    25
276 #define _RT_STDIOINIT   26
277 #define _RT_LOWIOINIT   27
278 #define _RT_HEAPINIT    28
279 #define _RT_DOMAIN      120
280 #define _RT_SING        121
281 #define _RT_TLOSS       122
282 #define _RT_CRNL        252
283 #define _RT_BANNER      255
284
285 struct MSVCRT___timeb32 {
286     MSVCRT___time32_t  time;
287     unsigned short millitm;
288     short          timezone;
289     short          dstflag;
290 };
291
292 struct MSVCRT___timeb64 {
293     MSVCRT___time64_t time;
294     unsigned short millitm;
295     short          timezone;
296     short          dstflag;
297 };
298
299 struct MSVCRT__iobuf {
300   char* _ptr;
301   int   _cnt;
302   char* _base;
303   int   _flag;
304   int   _file;
305   int   _charbuf;
306   int   _bufsiz;
307   char* _tmpfname;
308 };
309
310 typedef struct MSVCRT__iobuf MSVCRT_FILE;
311
312 struct MSVCRT_lconv {
313     char* decimal_point;
314     char* thousands_sep;
315     char* grouping;
316     char* int_curr_symbol;
317     char* currency_symbol;
318     char* mon_decimal_point;
319     char* mon_thousands_sep;
320     char* mon_grouping;
321     char* positive_sign;
322     char* negative_sign;
323     char int_frac_digits;
324     char frac_digits;
325     char p_cs_precedes;
326     char p_sep_by_space;
327     char n_cs_precedes;
328     char n_sep_by_space;
329     char p_sign_posn;
330     char n_sign_posn;
331 };
332
333 struct MSVCRT__exception {
334   int     type;
335   char*   name;
336   double  arg1;
337   double  arg2;
338   double  retval;
339 };
340
341 struct MSVCRT__complex {
342   double x;      /* Real part */
343   double y;      /* Imaginary part */
344 };
345
346 typedef struct MSVCRT__div_t {
347     int quot;  /* quotient */
348     int rem;   /* remainder */
349 } MSVCRT_div_t;
350
351 typedef struct MSVCRT__ldiv_t {
352     MSVCRT_long quot;  /* quotient */
353     MSVCRT_long rem;   /* remainder */
354 } MSVCRT_ldiv_t;
355
356 struct MSVCRT__heapinfo {
357   int*           _pentry;
358   MSVCRT_size_t  _size;
359   int            _useflag;
360 };
361
362 #ifdef __i386__
363 struct MSVCRT___JUMP_BUFFER {
364     unsigned long Ebp;
365     unsigned long Ebx;
366     unsigned long Edi;
367     unsigned long Esi;
368     unsigned long Esp;
369     unsigned long Eip;
370     unsigned long Registration;
371     unsigned long TryLevel;
372     /* Start of new struct members */
373     unsigned long Cookie;
374     unsigned long UnwindFunc;
375     unsigned long UnwindData[6];
376 };
377 #elif defined(__x86_64__)
378 struct MSVCRT__SETJMP_FLOAT128
379 {
380     unsigned __int64 DECLSPEC_ALIGN(16) Part[2];
381 };
382 struct MSVCRT___JUMP_BUFFER
383 {
384     unsigned __int64 Frame;
385     unsigned __int64 Rbx;
386     unsigned __int64 Rsp;
387     unsigned __int64 Rbp;
388     unsigned __int64 Rsi;
389     unsigned __int64 Rdi;
390     unsigned __int64 R12;
391     unsigned __int64 R13;
392     unsigned __int64 R14;
393     unsigned __int64 R15;
394     unsigned __int64 Rip;
395     unsigned __int64 Spare;
396     struct MSVCRT__SETJMP_FLOAT128 Xmm6;
397     struct MSVCRT__SETJMP_FLOAT128 Xmm7;
398     struct MSVCRT__SETJMP_FLOAT128 Xmm8;
399     struct MSVCRT__SETJMP_FLOAT128 Xmm9;
400     struct MSVCRT__SETJMP_FLOAT128 Xmm10;
401     struct MSVCRT__SETJMP_FLOAT128 Xmm11;
402     struct MSVCRT__SETJMP_FLOAT128 Xmm12;
403     struct MSVCRT__SETJMP_FLOAT128 Xmm13;
404     struct MSVCRT__SETJMP_FLOAT128 Xmm14;
405     struct MSVCRT__SETJMP_FLOAT128 Xmm15;
406 };
407 #endif /* __i386__ */
408
409 struct MSVCRT__diskfree_t {
410   unsigned int total_clusters;
411   unsigned int avail_clusters;
412   unsigned int sectors_per_cluster;
413   unsigned int bytes_per_sector;
414 };
415
416 struct MSVCRT__finddata32_t {
417   unsigned int      attrib;
418   MSVCRT___time32_t time_create;
419   MSVCRT___time32_t time_access;
420   MSVCRT___time32_t time_write;
421   MSVCRT__fsize_t   size;
422   char              name[260];
423 };
424
425 struct MSVCRT__finddata32i64_t {
426   unsigned int      attrib;
427   MSVCRT___time32_t time_create;
428   MSVCRT___time32_t time_access;
429   MSVCRT___time32_t time_write;
430   __int64 DECLSPEC_ALIGN(8) size;
431   char              name[260];
432 };
433
434 struct MSVCRT__finddata64i32_t {
435   unsigned int      attrib;
436   MSVCRT___time64_t time_create;
437   MSVCRT___time64_t time_access;
438   MSVCRT___time64_t time_write;
439   MSVCRT__fsize_t   size;
440   char              name[260];
441 };
442
443 struct MSVCRT__finddata64_t {
444   unsigned int      attrib;
445   MSVCRT___time64_t time_create;
446   MSVCRT___time64_t time_access;
447   MSVCRT___time64_t time_write;
448   __int64 DECLSPEC_ALIGN(8) size;
449   char              name[260];
450 };
451
452 struct MSVCRT__wfinddata32_t {
453   unsigned int      attrib;
454   MSVCRT___time32_t time_create;
455   MSVCRT___time32_t time_access;
456   MSVCRT___time32_t time_write;
457   MSVCRT__fsize_t   size;
458   MSVCRT_wchar_t    name[260];
459 };
460
461 struct MSVCRT__wfinddata32i64_t {
462   unsigned int      attrib;
463   MSVCRT___time32_t time_create;
464   MSVCRT___time32_t time_access;
465   MSVCRT___time32_t time_write;
466   __int64 DECLSPEC_ALIGN(8) size;
467   MSVCRT_wchar_t    name[260];
468 };
469
470 struct MSVCRT__wfinddata64i32_t {
471   unsigned int      attrib;
472   MSVCRT___time64_t time_create;
473   MSVCRT___time64_t time_access;
474   MSVCRT___time64_t time_write;
475   MSVCRT__fsize_t   size;
476   MSVCRT_wchar_t    name[260];
477 };
478
479 struct MSVCRT__wfinddata64_t {
480   unsigned int      attrib;
481   MSVCRT___time64_t time_create;
482   MSVCRT___time64_t time_access;
483   MSVCRT___time64_t time_write;
484   __int64 DECLSPEC_ALIGN(8) size;
485   MSVCRT_wchar_t    name[260];
486 };
487
488 struct MSVCRT___utimbuf32
489 {
490     MSVCRT___time32_t actime;
491     MSVCRT___time32_t modtime;
492 };
493
494 struct MSVCRT___utimbuf64
495 {
496     MSVCRT___time64_t actime;
497     MSVCRT___time64_t modtime;
498 };
499
500 /* for FreeBSD */
501 #undef st_atime
502 #undef st_ctime
503 #undef st_mtime
504
505 struct MSVCRT__stat32 {
506   MSVCRT__dev_t     st_dev;
507   MSVCRT__ino_t     st_ino;
508   unsigned short    st_mode;
509   short             st_nlink;
510   short             st_uid;
511   short             st_gid;
512   MSVCRT__dev_t     st_rdev;
513   MSVCRT__off_t     st_size;
514   MSVCRT___time32_t st_atime;
515   MSVCRT___time32_t st_mtime;
516   MSVCRT___time32_t st_ctime;
517 };
518
519 struct MSVCRT__stat32i64 {
520   MSVCRT__dev_t     st_dev;
521   MSVCRT__ino_t     st_ino;
522   unsigned short    st_mode;
523   short             st_nlink;
524   short             st_uid;
525   short             st_gid;
526   MSVCRT__dev_t     st_rdev;
527   __int64 DECLSPEC_ALIGN(8) st_size;
528   MSVCRT___time32_t st_atime;
529   MSVCRT___time32_t st_mtime;
530   MSVCRT___time32_t st_ctime;
531 };
532
533 struct MSVCRT__stat64i32 {
534   MSVCRT__dev_t     st_dev;
535   MSVCRT__ino_t     st_ino;
536   unsigned short    st_mode;
537   short             st_nlink;
538   short             st_uid;
539   short             st_gid;
540   MSVCRT__dev_t     st_rdev;
541   MSVCRT__off_t     st_size;
542   MSVCRT___time64_t st_atime;
543   MSVCRT___time64_t st_mtime;
544   MSVCRT___time64_t st_ctime;
545 };
546
547 struct MSVCRT__stat64 {
548   MSVCRT__dev_t     st_dev;
549   MSVCRT__ino_t     st_ino;
550   unsigned short    st_mode;
551   short             st_nlink;
552   short             st_uid;
553   short             st_gid;
554   MSVCRT__dev_t     st_rdev;
555   __int64 DECLSPEC_ALIGN(8) st_size;
556   MSVCRT___time64_t st_atime;
557   MSVCRT___time64_t st_mtime;
558   MSVCRT___time64_t st_ctime;
559 };
560
561 #ifdef _WIN64
562 #define MSVCRT__finddata_t     MSVCRT__finddata64i32_t
563 #define MSVCRT__finddatai64_t  MSVCRT__finddata64_t
564 #define MSVCRT__wfinddata_t    MSVCRT__wfinddata64i32_t
565 #define MSVCRT__wfinddatai64_t MSVCRT__wfinddata64_t
566 #define MSVCRT__stat           MSVCRT__stat64i32
567 #define MSVCRT__stati64        MSVCRT__stat64
568 #else
569 #define MSVCRT__finddata_t     MSVCRT__finddata32_t
570 #define MSVCRT__finddatai64_t  MSVCRT__finddata32i64_t
571 #define MSVCRT__wfinddata_t    MSVCRT__wfinddata32_t
572 #define MSVCRT__wfinddatai64_t MSVCRT__wfinddata32i64_t
573 #define MSVCRT__stat           MSVCRT__stat32
574 #define MSVCRT__stati64        MSVCRT__stat32i64
575 #endif
576
577 #define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF)
578 #define MSVCRT_EOF       (-1)
579 #define MSVCRT_TMP_MAX   0x7fff
580 #define MSVCRT_RAND_MAX  0x7fff
581 #define MSVCRT_BUFSIZ    512
582
583 #define MSVCRT_STDIN_FILENO  0
584 #define MSVCRT_STDOUT_FILENO 1
585 #define MSVCRT_STDERR_FILENO 2
586
587 /* more file._flag flags, but these conflict with Unix */
588 #define MSVCRT__IOFBF    0x0000
589 #define MSVCRT__IONBF    0x0004
590 #define MSVCRT__IOLBF    0x0040
591
592 #define MSVCRT_FILENAME_MAX 260
593 #define MSVCRT_DRIVE_MAX    3
594 #define MSVCRT_FNAME_MAX    256
595 #define MSVCRT_DIR_MAX      256
596 #define MSVCRT_EXT_MAX      256
597 #define MSVCRT_PATH_MAX     260
598 #define MSVCRT_stdin       (MSVCRT__iob+MSVCRT_STDIN_FILENO)
599 #define MSVCRT_stdout      (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
600 #define MSVCRT_stderr      (MSVCRT__iob+MSVCRT_STDERR_FILENO)
601
602 #define MSVCRT__P_WAIT    0
603 #define MSVCRT__P_NOWAIT  1
604 #define MSVCRT__P_OVERLAY 2
605 #define MSVCRT__P_NOWAITO 3
606 #define MSVCRT__P_DETACH  4
607
608 #define MSVCRT_EPERM   1
609 #define MSVCRT_ENOENT  2
610 #define MSVCRT_ESRCH   3
611 #define MSVCRT_EINTR   4
612 #define MSVCRT_EIO     5
613 #define MSVCRT_ENXIO   6
614 #define MSVCRT_E2BIG   7
615 #define MSVCRT_ENOEXEC 8
616 #define MSVCRT_EBADF   9
617 #define MSVCRT_ECHILD  10
618 #define MSVCRT_EAGAIN  11
619 #define MSVCRT_ENOMEM  12
620 #define MSVCRT_EACCES  13
621 #define MSVCRT_EFAULT  14
622 #define MSVCRT_EBUSY   16
623 #define MSVCRT_EEXIST  17
624 #define MSVCRT_EXDEV   18
625 #define MSVCRT_ENODEV  19
626 #define MSVCRT_ENOTDIR 20
627 #define MSVCRT_EISDIR  21
628 #define MSVCRT_EINVAL  22
629 #define MSVCRT_ENFILE  23
630 #define MSVCRT_EMFILE  24
631 #define MSVCRT_ENOTTY  25
632 #define MSVCRT_EFBIG   27
633 #define MSVCRT_ENOSPC  28
634 #define MSVCRT_ESPIPE  29
635 #define MSVCRT_EROFS   30
636 #define MSVCRT_EMLINK  31
637 #define MSVCRT_EPIPE   32
638 #define MSVCRT_EDOM    33
639 #define MSVCRT_ERANGE  34
640 #define MSVCRT_EDEADLK 36
641 #define MSVCRT_EDEADLOCK MSVCRT_EDEADLK
642 #define MSVCRT_ENAMETOOLONG 38
643 #define MSVCRT_ENOLCK  39
644 #define MSVCRT_ENOSYS  40
645 #define MSVCRT_ENOTEMPTY 41
646 #define MSVCRT_EILSEQ    42
647 #define MSVCRT_STRUNCATE 80
648
649 #define MSVCRT_LC_ALL          0
650 #define MSVCRT_LC_COLLATE      1
651 #define MSVCRT_LC_CTYPE        2
652 #define MSVCRT_LC_MONETARY     3
653 #define MSVCRT_LC_NUMERIC      4
654 #define MSVCRT_LC_TIME         5
655 #define MSVCRT_LC_MIN          MSVCRT_LC_ALL
656 #define MSVCRT_LC_MAX          MSVCRT_LC_TIME
657
658 #define MSVCRT__HEAPEMPTY      -1
659 #define MSVCRT__HEAPOK         -2
660 #define MSVCRT__HEAPBADBEGIN   -3
661 #define MSVCRT__HEAPBADNODE    -4
662 #define MSVCRT__HEAPEND        -5
663 #define MSVCRT__HEAPBADPTR     -6
664
665 #define MSVCRT__FREEENTRY      0
666 #define MSVCRT__USEDENTRY      1
667
668 #define MSVCRT__OUT_TO_DEFAULT 0
669 #define MSVCRT__OUT_TO_STDERR  1
670 #define MSVCRT__OUT_TO_MSGBOX  2
671 #define MSVCRT__REPORT_ERRMODE 3
672
673 /* ASCII char classification table - binary compatible */
674 #define MSVCRT__UPPER    0x0001  /* C1_UPPER */
675 #define MSVCRT__LOWER    0x0002  /* C1_LOWER */
676 #define MSVCRT__DIGIT    0x0004  /* C1_DIGIT */
677 #define MSVCRT__SPACE    0x0008  /* C1_SPACE */
678 #define MSVCRT__PUNCT    0x0010  /* C1_PUNCT */
679 #define MSVCRT__CONTROL  0x0020  /* C1_CNTRL */
680 #define MSVCRT__BLANK    0x0040  /* C1_BLANK */
681 #define MSVCRT__HEX      0x0080  /* C1_XDIGIT */
682 #define MSVCRT__LEADBYTE 0x8000
683 #define MSVCRT__ALPHA   (0x0100|MSVCRT__UPPER|MSVCRT__LOWER)  /* (C1_ALPHA|_UPPER|_LOWER) */
684
685 #define MSVCRT__IOREAD   0x0001
686 #define MSVCRT__IOWRT    0x0002
687 #define MSVCRT__IOMYBUF  0x0008
688 #define MSVCRT__IOEOF    0x0010
689 #define MSVCRT__IOERR    0x0020
690 #define MSVCRT__IOSTRG   0x0040
691 #define MSVCRT__IORW     0x0080
692
693 #define MSVCRT__S_IEXEC  0x0040
694 #define MSVCRT__S_IWRITE 0x0080
695 #define MSVCRT__S_IREAD  0x0100
696 #define MSVCRT__S_IFIFO  0x1000
697 #define MSVCRT__S_IFCHR  0x2000
698 #define MSVCRT__S_IFDIR  0x4000
699 #define MSVCRT__S_IFREG  0x8000
700 #define MSVCRT__S_IFMT   0xF000
701
702 #define MSVCRT__LK_UNLCK  0
703 #define MSVCRT__LK_LOCK   1
704 #define MSVCRT__LK_NBLCK  2
705 #define MSVCRT__LK_RLCK   3
706 #define MSVCRT__LK_NBRLCK 4
707
708 #define MSVCRT__SH_COMPAT       0x00    /* Compatibility */
709 #define MSVCRT__SH_DENYRW       0x10    /* Deny read/write */
710 #define MSVCRT__SH_DENYWR       0x20    /* Deny write */
711 #define MSVCRT__SH_DENYRD       0x30    /* Deny read */
712 #define MSVCRT__SH_DENYNO       0x40    /* Deny nothing */
713
714 #define MSVCRT__O_RDONLY        0
715 #define MSVCRT__O_WRONLY        1
716 #define MSVCRT__O_RDWR          2
717 #define MSVCRT__O_ACCMODE       (MSVCRT__O_RDONLY|MSVCRT__O_WRONLY|MSVCRT__O_RDWR)
718 #define MSVCRT__O_APPEND        0x0008
719 #define MSVCRT__O_RANDOM        0x0010
720 #define MSVCRT__O_SEQUENTIAL    0x0020
721 #define MSVCRT__O_TEMPORARY     0x0040
722 #define MSVCRT__O_NOINHERIT     0x0080
723 #define MSVCRT__O_CREAT         0x0100
724 #define MSVCRT__O_TRUNC         0x0200
725 #define MSVCRT__O_EXCL          0x0400
726 #define MSVCRT__O_SHORT_LIVED   0x1000
727 #define MSVCRT__O_TEXT          0x4000
728 #define MSVCRT__O_BINARY        0x8000
729 #define MSVCRT__O_RAW           MSVCRT__O_BINARY
730
731 /* _statusfp bit flags */
732 #define MSVCRT__SW_INEXACT      0x00000001 /* inexact (precision) */
733 #define MSVCRT__SW_UNDERFLOW    0x00000002 /* underflow */
734 #define MSVCRT__SW_OVERFLOW     0x00000004 /* overflow */
735 #define MSVCRT__SW_ZERODIVIDE   0x00000008 /* zero divide */
736 #define MSVCRT__SW_INVALID      0x00000010 /* invalid */
737
738 #define MSVCRT__SW_UNEMULATED     0x00000040  /* unemulated instruction */
739 #define MSVCRT__SW_SQRTNEG        0x00000080  /* square root of a neg number */
740 #define MSVCRT__SW_STACKOVERFLOW  0x00000200  /* FP stack overflow */
741 #define MSVCRT__SW_STACKUNDERFLOW 0x00000400  /* FP stack underflow */
742
743 #define MSVCRT__SW_DENORMAL     0x00080000 /* denormal status bit */
744
745 /* fpclass constants */
746 #define MSVCRT__FPCLASS_SNAN 0x0001  /* Signaling "Not a Number" */
747 #define MSVCRT__FPCLASS_QNAN 0x0002  /* Quiet "Not a Number" */
748 #define MSVCRT__FPCLASS_NINF 0x0004  /* Negative Infinity */
749 #define MSVCRT__FPCLASS_NN   0x0008  /* Negative Normal */
750 #define MSVCRT__FPCLASS_ND   0x0010  /* Negative Denormal */
751 #define MSVCRT__FPCLASS_NZ   0x0020  /* Negative Zero */
752 #define MSVCRT__FPCLASS_PZ   0x0040  /* Positive Zero */
753 #define MSVCRT__FPCLASS_PD   0x0080  /* Positive Denormal */
754 #define MSVCRT__FPCLASS_PN   0x0100  /* Positive Normal */
755 #define MSVCRT__FPCLASS_PINF 0x0200  /* Positive Infinity */
756
757 #define MSVCRT__MCW_EM        0x0008001f
758 #define MSVCRT__MCW_IC        0x00040000
759 #define MSVCRT__MCW_RC        0x00000300
760 #define MSVCRT__MCW_PC        0x00030000
761 #define MSVCRT__MCW_DN        0x03000000
762
763 #define MSVCRT__EM_INVALID    0x00000010
764 #define MSVCRT__EM_DENORMAL   0x00080000
765 #define MSVCRT__EM_ZERODIVIDE 0x00000008
766 #define MSVCRT__EM_OVERFLOW   0x00000004
767 #define MSVCRT__EM_UNDERFLOW  0x00000002
768 #define MSVCRT__EM_INEXACT    0x00000001
769 #define MSVCRT__IC_AFFINE     0x00040000
770 #define MSVCRT__IC_PROJECTIVE 0x00000000
771 #define MSVCRT__RC_CHOP       0x00000300
772 #define MSVCRT__RC_UP         0x00000200
773 #define MSVCRT__RC_DOWN       0x00000100
774 #define MSVCRT__RC_NEAR       0x00000000
775 #define MSVCRT__PC_24         0x00020000
776 #define MSVCRT__PC_53         0x00010000
777 #define MSVCRT__PC_64         0x00000000
778 #define MSVCRT__DN_SAVE       0x00000000
779 #define MSVCRT__DN_FLUSH      0x01000000
780 #define MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000
781 #define MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000
782 #define MSVCRT__EM_AMBIGUOUS  0x80000000
783
784 #define MSVCRT_CLOCKS_PER_SEC 1000
785
786 /* signals */
787 #define MSVCRT_SIGINT   2
788 #define MSVCRT_SIGILL   4
789 #define MSVCRT_SIGFPE   8
790 #define MSVCRT_SIGSEGV  11
791 #define MSVCRT_SIGTERM  15
792 #define MSVCRT_SIGBREAK 21
793 #define MSVCRT_SIGABRT  22
794 #define MSVCRT_NSIG     (MSVCRT_SIGABRT + 1)
795
796 typedef void (__cdecl *MSVCRT___sighandler_t)(int);
797
798 #define MSVCRT_SIG_DFL ((MSVCRT___sighandler_t)0)
799 #define MSVCRT_SIG_IGN ((MSVCRT___sighandler_t)1)
800 #define MSVCRT_SIG_ERR ((MSVCRT___sighandler_t)-1)
801
802 #define MSVCRT__FPE_INVALID            0x81
803 #define MSVCRT__FPE_DENORMAL           0x82
804 #define MSVCRT__FPE_ZERODIVIDE         0x83
805 #define MSVCRT__FPE_OVERFLOW           0x84
806 #define MSVCRT__FPE_UNDERFLOW          0x85
807 #define MSVCRT__FPE_INEXACT            0x86
808 #define MSVCRT__FPE_UNEMULATED         0x87
809 #define MSVCRT__FPE_SQRTNEG            0x88
810 #define MSVCRT__FPE_STACKOVERFLOW      0x8a
811 #define MSVCRT__FPE_STACKUNDERFLOW     0x8b
812 #define MSVCRT__FPE_EXPLICITGEN        0x8c
813
814 #define _MS     0x01
815 #define _MP     0x02
816 #define _M1     0x04
817 #define _M2     0x08
818
819 #define _SBUP   0x10
820 #define _SBLOW  0x20
821
822 #define _MBC_SINGLE     0
823 #define _MBC_LEAD       1
824 #define _MBC_TRAIL      2
825 #define _MBC_ILLEGAL    -1
826
827 #define _MB_CP_SBCS     0
828 #define _MB_CP_OEM      -2
829 #define _MB_CP_ANSI     -3
830 #define _MB_CP_LOCALE   -4
831
832 #define MSVCRT__TRUNCATE ((MSVCRT_size_t)-1)
833
834 #define _MAX__TIME64_T    (((MSVCRT___time64_t)0x00000007 << 32) | 0x93406FFF)
835
836 /* _set_abort_behavior codes */
837 #define MSVCRT__WRITE_ABORT_MSG    1
838 #define MSVCRT__CALL_REPORTFAULT   2
839
840 /* _get_output_format return code */
841 #define MSVCRT__TWO_DIGIT_EXPONENT 0x1
842
843 void  __cdecl    MSVCRT_free(void*);
844 void* __cdecl    MSVCRT_malloc(MSVCRT_size_t);
845 void* __cdecl    MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t);
846 void* __cdecl    MSVCRT_realloc(void*,MSVCRT_size_t);
847
848 int __cdecl      MSVCRT_iswalpha(MSVCRT_wint_t);
849 int __cdecl      MSVCRT_iswspace(MSVCRT_wint_t);
850 int __cdecl      MSVCRT_iswdigit(MSVCRT_wint_t);
851 int __cdecl      MSVCRT_isleadbyte(int);
852
853 void __cdecl     MSVCRT__lock_file(MSVCRT_FILE*);
854 void __cdecl     MSVCRT__unlock_file(MSVCRT_FILE*);
855 int __cdecl      MSVCRT_fgetc(MSVCRT_FILE*);
856 int __cdecl      MSVCRT_ungetc(int,MSVCRT_FILE*);
857 MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*);
858 MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*);
859 void __cdecl     MSVCRT__exit(int);
860 void __cdecl     MSVCRT_abort(void);
861 MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);
862 int* __cdecl     MSVCRT__errno(void);
863 char* __cdecl    MSVCRT_getenv(const char*);
864 int __cdecl      MSVCRT_fclose(MSVCRT_FILE*);
865 void __cdecl     MSVCRT_terminate(void);
866 MSVCRT_FILE* __cdecl MSVCRT__iob_func(void);
867 MSVCRT_clock_t __cdecl MSVCRT_clock(void);
868 MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*);
869 MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*);
870 MSVCRT_FILE*   __cdecl MSVCRT__fdopen(int, const char *);
871 MSVCRT_FILE*   __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *);
872 int            __cdecl MSVCRT_vsnprintf(char *str, MSVCRT_size_t len, const char *format, __ms_va_list valist);
873 int            __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
874                                        const MSVCRT_wchar_t *format, __ms_va_list valist );
875 int            __cdecl MSVCRT__snwprintf(MSVCRT_wchar_t*, unsigned int, const MSVCRT_wchar_t*, ...);
876 int            __cdecl MSVCRT_sprintf(char*,const char*,...);
877 int            __cdecl MSVCRT__scprintf(const char*,...);
878 int            __cdecl MSVCRT_raise(int sig);
879
880 #define MSVCRT__ENABLE_PER_THREAD_LOCALE 1
881 #define MSVCRT__DISABLE_PER_THREAD_LOCALE 2
882
883 extern MSVCRT__locale_t MSVCRT_locale;
884 MSVCRT__locale_t MSVCRT__create_locale(int, const char*);
885 MSVCRT_pthreadlocinfo get_locinfo(void);
886 void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
887 void free_locinfo(MSVCRT_pthreadlocinfo);
888 void free_mbcinfo(MSVCRT_pthreadmbcinfo);
889
890 #ifndef __WINE_MSVCRT_TEST
891 int            __cdecl MSVCRT__write(int,const void*,unsigned int);
892 int            __cdecl _getch(void);
893 int            __cdecl _ismbblead(unsigned int);
894 int            __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str);
895 MSVCRT_size_t  __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
896 MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *);
897 MSVCRT_intptr_t __cdecl MSVRT__spawnvpe(int,const char*,const char* const *,const char* const *);
898 MSVCRT_intptr_t __cdecl _wspawnve(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
899 MSVCRT_intptr_t __cdecl _wspawnvpe(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
900 void __cdecl     _searchenv(const char*,const char*,char*);
901 int __cdecl      _getdrive(void);
902 char* __cdecl    _strdup(const char*);
903 char* __cdecl    MSVCRT__strnset(char*,int,MSVCRT_size_t);
904 char* __cdecl    _strset(char*,int);
905 int __cdecl      _ungetch(int);
906 int __cdecl      _cputs(const char*);
907 int __cdecl      _cprintf(const char*,...);
908 int __cdecl      _cwprintf(const MSVCRT_wchar_t*,...);
909 char*** __cdecl  __p__environ(void);
910 int*    __cdecl  __p___mb_cur_max(void);
911 unsigned int*  __cdecl __p__fmode(void);
912 MSVCRT_wchar_t* __cdecl _wcsdup(const MSVCRT_wchar_t*);
913 MSVCRT_wchar_t*** __cdecl __p__wenviron(void);
914 char*   __cdecl _strdate(char* date);
915 char*   __cdecl _strtime(char* date);
916 int     __cdecl _setmbcp(int);
917 int     __cdecl MSVCRT__close(int);
918 int     __cdecl MSVCRT__dup(int);
919 int     __cdecl MSVCRT__dup2(int, int);
920 int     __cdecl MSVCRT__pipe(int *, unsigned int, int);
921 MSVCRT_wchar_t* __cdecl _wgetenv(const MSVCRT_wchar_t*);
922 void __cdecl    _wsearchenv(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_wchar_t*);
923 MSVCRT_intptr_t __cdecl MSVCRT__spawnvpe(int, const char*, const char* const*, const char* const*);
924 void __cdecl MSVCRT__invalid_parameter(const MSVCRT_wchar_t *expr, const MSVCRT_wchar_t *func,
925                                        const MSVCRT_wchar_t *file, unsigned int line, MSVCRT_uintptr_t arg);
926 int __cdecl      MSVCRT__toupper_l(int,MSVCRT__locale_t);
927 int __cdecl      MSVCRT__tolower_l(int,MSVCRT__locale_t);
928
929 /* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
930  *      #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
931  *      #define MSVCRT_CHECK_PMT(x)   ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
932  * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
933  * any information
934  * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around MSVCRT__invalid_parameter in order
935  * to do the Ansi to Unicode transformation
936  */
937 #define MSVCRT_INVALID_PMT(x) MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0)
938 #define MSVCRT_CHECK_PMT(x)   ((x) || (MSVCRT_INVALID_PMT(0),FALSE))
939 #endif
940
941 #define MSVCRT__ARGMAX 100
942 typedef int (*puts_clbk_a)(void*, int, const char*);
943 typedef int (*puts_clbk_w)(void*, int, const MSVCRT_wchar_t*);
944 typedef union _printf_arg
945 {
946     void *get_ptr;
947     int get_int;
948     LONGLONG get_longlong;
949     double get_double;
950 } printf_arg;
951 typedef printf_arg (*args_clbk)(void*, int, int, __ms_va_list*);
952 int pf_printf_a(puts_clbk_a, void*, const char*, MSVCRT__locale_t,
953         BOOL, BOOL, args_clbk, void*, __ms_va_list*);
954 int pf_printf_w(puts_clbk_w, void*, const MSVCRT_wchar_t*, MSVCRT__locale_t,
955         BOOL, BOOL, args_clbk, void*, __ms_va_list*);
956 printf_arg arg_clbk_valist(void*, int, int, __ms_va_list*);
957
958 #define MSVCRT__OVERFLOW  3
959 #define MSVCRT__UNDERFLOW 4
960
961 typedef struct
962 {
963     float f;
964 } MSVCRT__CRT_FLOAT;
965
966 #endif /* __WINE_MSVCRT_H */