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