Update crt headers and mingw lib from mingw64. Update crt a bit. 4 msvcrt time tests...
[reactos.git] / reactos / lib / 3rdparty / mingw / internal.h
1 #ifndef _INC_INTERNAL
2 #define _INC_INTERNAL
3
4 #include <_mingw.h>
5 #include <stdint.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #include <limits.h>
12 #include <windows.h>
13
14 #define _CRTALLOC(x) __attribute__ ((section (x) ))
15
16 #pragma pack(push,_CRT_PACKING)
17
18 typedef void (__cdecl *_PVFV)(void);
19 typedef int (__cdecl *_PIFV)(void);
20 typedef void (__cdecl *_PVFI)(int);
21
22 #if defined (SPECIAL_CRTEXE) && defined (_DLL)
23 extern int _commode;
24 #else
25 _CRTIMP extern int _commode;
26 #endif
27
28 #define __IOINFO_TM_ANSI 0
29 #define __IOINFO_TM_UTF8 1
30 #define __IOINFO_TM_UTF16LE 2
31
32 typedef struct {
33 intptr_t osfhnd;
34 char osfile;
35 char pipech;
36 int lockinitflag;
37 CRITICAL_SECTION lock;
38 char textmode : 7;
39 char unicode : 1;
40 char pipech2[2];
41 } ioinfo;
42
43 #define IOINFO_ARRAY_ELTS (1 << 5)
44
45 #define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
46 #define _osfile(i) (_pioinfo(i)->osfile)
47 #define _pipech2(i) (_pioinfo(i)->pipech2)
48 #define _textmode(i) (_pioinfo(i)->textmode)
49 #define _tm_unicode(i) (_pioinfo(i)->unicode)
50 #define _pioinfo_safe(i) ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
51 #define _osfhnd_safe(i) (_pioinfo_safe(i)->osfhnd)
52 #define _osfile_safe(i) (_pioinfo_safe(i)->osfile)
53 #define _pipech_safe(i) (_pioinfo_safe(i)->pipech)
54 #define _pipech2_safe(i) (_pioinfo_safe(i)->pipech2)
55 #define _textmode_safe(i) (_pioinfo_safe(i)->textmode)
56 #define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
57
58 #ifndef __badioinfo
59 extern ioinfo ** _imp____badioinfo[];
60 #define __badioinfo (*_imp____badioinfo)
61 #endif
62
63 #ifndef __pioinfo
64 extern ioinfo ** _imp____pioinfo[];
65 #define __pioinfo (*_imp____pioinfo)
66 #endif
67
68 #define _NO_CONSOLE_FILENO (intptr_t)-2
69
70 #ifndef _FILE_DEFINED
71 #define _FILE_DEFINED
72 struct _iobuf {
73 char *_ptr;
74 int _cnt;
75 char *_base;
76 int _flag;
77 int _file;
78 int _charbuf;
79 int _bufsiz;
80 char *_tmpfname;
81 };
82 typedef struct _iobuf FILE;
83 #endif
84
85 #if !defined (_FILEX_DEFINED) && defined (_WINDOWS_)
86 #define _FILEX_DEFINED
87 typedef struct {
88 FILE f;
89 CRITICAL_SECTION lock;
90 } _FILEX;
91 #endif
92
93 extern int _dowildcard;
94 extern int _newmode;
95
96 #ifndef __winitenv
97 extern wchar_t ***_imp____winitenv;
98 #define __winitenv (*_imp____winitenv)
99 #endif
100
101 #ifndef __initenv
102 extern char ***_imp____initenv;
103 #define __initenv (*_imp____initenv)
104 #endif
105
106 #ifndef _acmdln
107 extern char **_imp___acmdln;
108 #define _acmdln (*_imp___acmdln)
109 /* _CRTIMP extern char *_acmdln; */
110 #endif
111
112 #ifndef _wcmdln
113 extern char **_imp___wcmdln;
114 #define _wcmdln (*_imp___wcmdln)
115 /* __CRTIMP extern wchar_t *_wcmdln; */
116 #endif
117
118 _CRTIMP void __cdecl _amsg_exit(int);
119
120 int __CRTDECL _setargv(void);
121 int __CRTDECL __setargv(void);
122 int __CRTDECL _wsetargv(void);
123 int __CRTDECL __wsetargv(void);
124
125 int __CRTDECL main(int _Argc, char **_Argv, char **_Env);
126 int __CRTDECL wmain(int _Argc, wchar_t **_Argv, wchar_t **_Env);
127
128 #ifndef _STARTUP_INFO_DEFINED
129 #define _STARTUP_INFO_DEFINED
130 typedef struct {
131 int newmode;
132 } _startupinfo;
133 #endif
134
135 _CRTIMP int __cdecl __getmainargs(int * _Argc, char *** _Argv, char ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
136 _CRTIMP int __cdecl __wgetmainargs(int * _Argc, wchar_t ***_Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
137
138 #define _CONSOLE_APP 1
139 #define _GUI_APP 2
140
141 typedef enum __enative_startup_state {
142 __uninitialized, __initializing, __initialized
143 } __enative_startup_state;
144
145 extern volatile __enative_startup_state __native_startup_state;
146 extern volatile void *__native_startup_lock;
147
148 extern volatile unsigned int __native_dllmain_reason;
149 extern volatile unsigned int __native_vcclrit_reason;
150
151 _CRTIMP void __cdecl __set_app_type (int);
152
153 typedef LONG NTSTATUS;
154
155 #include <crtdbg.h>
156 #include <errno.h>
157
158 void * __cdecl _encode_pointer(void *);
159 void * __cdecl _encoded_null();
160 void * __cdecl _decode_pointer(void *);
161
162 BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
163 PIMAGE_SECTION_HEADER __cdecl _FindPESection (PBYTE pImageBase, DWORD_PTR rva);
164 BOOL __cdecl _IsNonwritableInCurrentImage (PBYTE pTarget);
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #pragma pack(pop)
171 #endif