[MINGW]
[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 typedef struct {
39 intptr_t osfhnd;
40 char osfile;
41 char pipech;
42 int lockinitflag;
43 CRITICAL_SECTION lock;
44 char textmode : 7;
45 char unicode : 1;
46 char pipech2[2];
47 } ioinfo;
48
49 #define IOINFO_ARRAY_ELTS (1 << 5)
50
51 #define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
52 #define _osfile(i) (_pioinfo(i)->osfile)
53 #define _pipech2(i) (_pioinfo(i)->pipech2)
54 #define _textmode(i) (_pioinfo(i)->textmode)
55 #define _tm_unicode(i) (_pioinfo(i)->unicode)
56 #define _pioinfo_safe(i) ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
57 #define _osfhnd_safe(i) (_pioinfo_safe(i)->osfhnd)
58 #define _osfile_safe(i) (_pioinfo_safe(i)->osfile)
59 #define _pipech_safe(i) (_pioinfo_safe(i)->pipech)
60 #define _pipech2_safe(i) (_pioinfo_safe(i)->pipech2)
61 #define _textmode_safe(i) (_pioinfo_safe(i)->textmode)
62 #define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
63
64 #ifndef __badioinfo
65 extern ioinfo ** __MINGW_IMP_SYMBOL(__badioinfo)[];
66 #define __badioinfo (* __MINGW_IMP_SYMBOL(__badioinfo))
67 #endif
68
69 #ifndef __pioinfo
70 extern ioinfo ** __MINGW_IMP_SYMBOL(__pioinfo)[];
71 #define __pioinfo (* __MINGW_IMP_SYMBOL(__pioinfo))
72 #endif
73
74 #define _NO_CONSOLE_FILENO (intptr_t)-2
75
76 #ifndef _FILE_DEFINED
77 #define _FILE_DEFINED
78 struct _iobuf {
79 char *_ptr;
80 int _cnt;
81 char *_base;
82 int _flag;
83 int _file;
84 int _charbuf;
85 int _bufsiz;
86 char *_tmpfname;
87 };
88 typedef struct _iobuf FILE;
89 #endif
90
91 #if !defined (_FILEX_DEFINED) && defined (_WINDOWS_)
92 #define _FILEX_DEFINED
93 typedef struct {
94 FILE f;
95 CRITICAL_SECTION lock;
96 } _FILEX;
97 #endif
98
99 extern int _dowildcard;
100 extern int _newmode;
101
102 #ifndef __winitenv
103 extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
104 #define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
105 #endif
106
107 #ifndef __initenv
108 extern char *** __MINGW_IMP_SYMBOL(__initenv);
109 #define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
110 #endif
111
112 #ifndef _acmdln
113 extern char ** __MINGW_IMP_SYMBOL(_acmdln);
114 #define _acmdln (* __MINGW_IMP_SYMBOL(_acmdln))
115 /* _CRTIMP extern char *_acmdln; */
116 #endif
117
118 #ifndef _wcmdln
119 extern char ** __MINGW_IMP_SYMBOL(_wcmdln);
120 #define _wcmdln (* __MINGW_IMP_SYMBOL(_wcmdln))
121 /* __CRTIMP extern wchar_t *_wcmdln; */
122 #endif
123
124 _CRTIMP void __cdecl _amsg_exit(int);
125
126 int __CRTDECL _setargv(void);
127 int __CRTDECL __setargv(void);
128 int __CRTDECL _wsetargv(void);
129 int __CRTDECL __wsetargv(void);
130
131 int __CRTDECL main(int _Argc, char **_Argv, char **_Env);
132 int __CRTDECL wmain(int _Argc, wchar_t **_Argv, wchar_t **_Env);
133
134 #ifndef _STARTUP_INFO_DEFINED
135 #define _STARTUP_INFO_DEFINED
136 typedef struct {
137 int newmode;
138 } _startupinfo;
139 #endif
140
141 _CRTIMP int __cdecl __getmainargs(int * _Argc, char *** _Argv, char ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
142 _CRTIMP int __cdecl __wgetmainargs(int * _Argc, wchar_t ***_Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
143
144 #define _CONSOLE_APP 1
145 #define _GUI_APP 2
146
147 typedef enum __enative_startup_state {
148 __uninitialized, __initializing, __initialized
149 } __enative_startup_state;
150
151 extern volatile __enative_startup_state __native_startup_state;
152 extern volatile void *__native_startup_lock;
153
154 extern volatile unsigned int __native_dllmain_reason;
155 extern volatile unsigned int __native_vcclrit_reason;
156
157 _CRTIMP void __cdecl __set_app_type (int);
158
159 typedef LONG NTSTATUS;
160
161 #include <crtdbg.h>
162 #include <errno.h>
163
164 void * __cdecl _encode_pointer(void *);
165 void * __cdecl _encoded_null();
166 void * __cdecl _decode_pointer(void *);
167
168 BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
169 PIMAGE_SECTION_HEADER __cdecl _FindPESection (PBYTE pImageBase, DWORD_PTR rva);
170 BOOL __cdecl _IsNonwritableInCurrentImage (PBYTE pTarget);
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #pragma pack(pop)
177 #endif