• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 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 #if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
22   extern int _commode;
23 #else
24   __declspec(dllimport) extern int _commode;
25 #endif
26 
27 #define __IOINFO_TM_ANSI 0
28 #define __IOINFO_TM_UTF8 1
29 #define __IOINFO_TM_UTF16LE 2
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable:4214)
34 #pragma warning(disable:4820)
35 #endif
36 
37   typedef struct {
38     intptr_t osfhnd;
39     char osfile;
40     char pipech;
41     int lockinitflag;
42     CRITICAL_SECTION lock;
43     char textmode : 7;
44     char unicode : 1;
45     char pipech2[2];
46   } ioinfo;
47 
48 #ifdef _MSC_VER
49 #pragma warning(pop)
50 #endif
51 
52 #define IOINFO_ARRAY_ELTS (1 << 5)
53 
54 #define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
55 #define _osfile(i) (_pioinfo(i)->osfile)
56 #define _pipech2(i) (_pioinfo(i)->pipech2)
57 #define _textmode(i) (_pioinfo(i)->textmode)
58 #define _tm_unicode(i) (_pioinfo(i)->unicode)
59 #define _pioinfo_safe(i) ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
60 #define _osfhnd_safe(i) (_pioinfo_safe(i)->osfhnd)
61 #define _osfile_safe(i) (_pioinfo_safe(i)->osfile)
62 #define _pipech_safe(i) (_pioinfo_safe(i)->pipech)
63 #define _pipech2_safe(i) (_pioinfo_safe(i)->pipech2)
64 #define _textmode_safe(i) (_pioinfo_safe(i)->textmode)
65 #define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
66 
67 #ifndef __badioinfo
68   extern ioinfo ** __MINGW_IMP_SYMBOL(__badioinfo)[];
69 #define __badioinfo (* __MINGW_IMP_SYMBOL(__badioinfo))
70 #endif
71 
72 #ifndef __pioinfo
73   extern ioinfo ** __MINGW_IMP_SYMBOL(__pioinfo)[];
74 #define __pioinfo (* __MINGW_IMP_SYMBOL(__pioinfo))
75 #endif
76 
77 #define _NO_CONSOLE_FILENO (intptr_t)-2
78 
79 #ifndef _FILE_DEFINED
80 #define _FILE_DEFINED
81   struct _iobuf {
82     char *_ptr;
83     int _cnt;
84     char *_base;
85     int _flag;
86     int _file;
87     int _charbuf;
88     int _bufsiz;
89     char *_tmpfname;
90   };
91   typedef struct _iobuf FILE;
92 #endif
93 
94 #if !defined (_FILEX_DEFINED) && defined (_WINDOWS_)
95 #define _FILEX_DEFINED
96   typedef struct {
97     FILE f;
98     CRITICAL_SECTION lock;
99   } _FILEX;
100 #endif
101 
102   extern int _dowildcard;
103   extern int _newmode;
104 
105 #ifndef __winitenv
106 extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
107 #define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
108 #endif
109 
110 #if !defined(__initenv) && !defined(__arm__)
111 extern char *** __MINGW_IMP_SYMBOL(__initenv);
112 #define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
113 #endif
114 
115   _CRTIMP void __cdecl _amsg_exit(int);
116 
117   int __CRTDECL _setargv(void);
118   int __CRTDECL __setargv(void);
119   int __CRTDECL _wsetargv(void);
120   int __CRTDECL __wsetargv(void);
121 
122   int __CRTDECL main(int _Argc, char **_Argv, char **_Env);
123   int __CRTDECL wmain(int _Argc, wchar_t **_Argv, wchar_t **_Env);
124 
125 #ifndef _STARTUP_INFO_DEFINED
126 #define _STARTUP_INFO_DEFINED
127   typedef struct {
128     int newmode;
129   } _startupinfo;
130 #endif
131 
132   _CRTIMP int __cdecl __getmainargs(int * _Argc, char *** _Argv, char ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
133   _CRTIMP int __cdecl __wgetmainargs(int * _Argc, wchar_t ***_Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo);
134 
135 #define _CONSOLE_APP 1
136 #define _GUI_APP 2
137 
138   typedef enum __enative_startup_state {
139     __uninitialized = 0, __initializing, __initialized
140   } __enative_startup_state;
141 
142   extern volatile __enative_startup_state __native_startup_state;
143   extern volatile void *__native_startup_lock;
144 
145   extern volatile unsigned int __native_dllmain_reason;
146   extern volatile unsigned int __native_vcclrit_reason;
147 
148   _CRTIMP void __cdecl __set_app_type (int);
149 
150   typedef LONG NTSTATUS;
151 
152 #include <crtdbg.h>
153 #include <errno.h>
154 
155   BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
156   PIMAGE_SECTION_HEADER __cdecl _FindPESection (PBYTE pImageBase, DWORD_PTR rva);
157   BOOL __cdecl _IsNonwritableInCurrentImage (PBYTE pTarget);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #pragma pack(pop)
164 #endif
165