1 /* globals.cc - Define global variables here.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
12 #include "perprocess.h"
15 #include <cygwin/version.h>
17 HANDLE NO_COPY hMainThread
;
18 HANDLE NO_COPY hProcToken
;
19 HANDLE NO_COPY hProcImpToken
;
20 HANDLE my_wr_proc_pipe
;
21 HMODULE NO_COPY cygwin_hmodule
;
22 HMODULE NO_COPY hntdll
;
23 LONG NO_COPY sigExeced
;
24 WCHAR windows_system_directory
[MAX_PATH
];
25 UINT windows_system_directory_length
;
26 WCHAR windows_directory_buf
[MAX_PATH
];
27 PWCHAR windows_directory
= windows_directory_buf
+ 4;
28 UINT windows_directory_length
;
29 UNICODE_STRING windows_directory_path
;
30 WCHAR global_progname
[NT_MAX_PATH
];
32 /* program exit the program */
50 /* The type of symlink to create. The value is set depending on the
51 "winsymlinks" setting of the CYGWIN environment variable. */
62 exit_states NO_COPY exit_state
;
64 /* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */
65 int NO_COPY dynamically_loaded
;
67 /* Some CYGWIN environment variable variables. */
68 bool allow_glob
= true;
69 bool ignore_case_with_glob
;
70 bool pipe_byte
= true; /* Default to byte mode so that C# programs work. */
73 winsym_t allow_winsymlinks
= WSYM_default
;
75 bool winjitdebug
= false;
77 /* Taken from BSD libc:
78 This variable is zero until a process has created a pthread. It is used
79 to avoid calling locking functions in libc when they are not required.
80 Note that this is moderately dangerous. Do not rely on it if the public
81 API is also used from a non-pthread thread like the signal thread. */
82 int NO_COPY __isthreaded
= 0;
87 /* Set via setproctitle */
90 _cygtls NO_COPY
*_main_tls
/* !globals.h */;
92 bool NO_COPY cygwin_finished_initializing
;
94 bool NO_COPY _cygwin_testing
;
96 char NO_COPY almost_null
[1];
100 /* Heavily-used const UNICODE_STRINGs are defined here once. The idea is a
101 speed improvement by not having to initialize a UNICODE_STRING every time
102 we make a string comparison. The _RDATA trick allows defining the strings
103 as const (so we get a SEGV if some code erroneously tries to overwrite
104 them), while declaring them as non-const in the auto-generated globals.h.
105 The strings are usually used in NT functions which don't take const
106 arguments. We avoid a lot of extra casts here...
107 Note: The "extern" is required, otherwise either the variables are dropped
108 entirely, or C++ name mangling is applied despite the extern "C"
109 bracket, depending on the compiler version */
111 # define _RDATA const
115 { Length: sizeof (_s) - sizeof (WCHAR), \
116 MaximumLength: sizeof (_s), \
117 Buffer: (PWSTR) (_s) }
118 extern UNICODE_STRING _RDATA ro_u_empty
= _ROU (L
"");
119 extern UNICODE_STRING _RDATA ro_u_lnk
= _ROU (L
".lnk");
120 extern UNICODE_STRING _RDATA ro_u_exe
= _ROU (L
".exe");
121 extern UNICODE_STRING _RDATA ro_u_scr
= _ROU (L
".scr");
122 extern UNICODE_STRING _RDATA ro_u_sys
= _ROU (L
".sys");
123 extern UNICODE_STRING _RDATA ro_u_proc
= _ROU (L
"proc");
124 extern UNICODE_STRING _RDATA ro_u_dev
= _ROU (L
"dev");
125 extern UNICODE_STRING _RDATA ro_u_natp
= _ROU (L
"\\??\\");
126 extern UNICODE_STRING _RDATA ro_u_uncp
= _ROU (L
"\\??\\UNC\\");
127 extern UNICODE_STRING _RDATA ro_u_mtx
= _ROU (L
"mtx");
128 extern UNICODE_STRING _RDATA ro_u_csc
= _ROU (L
"CSC-CACHE");
129 extern UNICODE_STRING _RDATA ro_u_fat
= _ROU (L
"FAT");
130 extern UNICODE_STRING _RDATA ro_u_exfat
= _ROU (L
"exFAT");
131 extern UNICODE_STRING _RDATA ro_u_mvfs
= _ROU (L
"MVFS");
132 extern UNICODE_STRING _RDATA ro_u_nfs
= _ROU (L
"NFS");
133 extern UNICODE_STRING _RDATA ro_u_ntfs
= _ROU (L
"NTFS");
134 /* No typo! It's actually "SF", not "FS", and the trailing NUL is counted
135 in the reply from the filesystem. */
136 extern UNICODE_STRING _RDATA ro_u_prlfs
= _ROU (L
"PrlSF\0");
137 extern UNICODE_STRING _RDATA ro_u_refs
= _ROU (L
"ReFS");
138 extern UNICODE_STRING _RDATA ro_u_udf
= _ROU (L
"UDF");
139 extern UNICODE_STRING _RDATA ro_u_unixfs
= _ROU (L
"UNIXFS");
140 extern UNICODE_STRING _RDATA ro_u_nwfs
= _ROU (L
"NWFS");
141 extern UNICODE_STRING _RDATA ro_u_ncfsd
= _ROU (L
"NcFsd");
142 extern UNICODE_STRING _RDATA ro_u_afs
= _ROU (L
"AFSRDRFsd");
143 extern UNICODE_STRING _RDATA ro_u_volume
= _ROU (L
"\\??\\Volume{");
144 extern UNICODE_STRING _RDATA ro_u_pipedir
= _ROU (L
"\\\\?\\PIPE\\");
145 extern UNICODE_STRING _RDATA ro_u_globalroot
= _ROU (L
"\\\\.\\GLOBALROOT");
146 extern UNICODE_STRING _RDATA ro_u_null
= _ROU (L
"\\Device\\Null");
147 extern UNICODE_STRING _RDATA ro_u_natdir
= _ROU (L
"Directory");
148 extern UNICODE_STRING _RDATA ro_u_natsyml
= _ROU (L
"SymbolicLink");
149 extern UNICODE_STRING _RDATA ro_u_natdev
= _ROU (L
"Device");
150 extern UNICODE_STRING _RDATA ro_u_npfs
= _ROU (L
"\\Device\\NamedPipe\\");
151 extern UNICODE_STRING _RDATA ro_u_mq_suffix
= _ROU (L
":mqueue");
155 /* __progname used in getopt error message is an alias of
156 program_invocation_short_name. */
157 char *program_invocation_short_name
;
158 char *program_invocation_name
;
159 static MTinterface _mtinterf
;
160 struct per_process __cygwin_user_data
=
161 {/* initial_sp */ 0, /* magic_biscuit */ 0,
162 /* dll_major */ CYGWIN_VERSION_DLL_MAJOR
,
163 /* dll_major */ CYGWIN_VERSION_DLL_MINOR
,
164 /* impure_ptr_ptr */ NULL
,
165 /* malloc */ malloc
, /* free */ free
,
166 /* realloc */ realloc
,
167 /* fmode_ptr */ NULL
, /* main */ NULL
, /* ctors */ NULL
,
168 /* dtors */ NULL
, /* data_start */ NULL
, /* data_end */ NULL
,
169 /* bss_start */ NULL
, /* bss_end */ NULL
,
171 /* premain */ {NULL
, NULL
, NULL
, NULL
},
174 /* cxx_malloc */ &default_cygwin_cxx_malloc
,
179 /* posix_memalign */ posix_memalign
,
180 /* pseudo_reloc_start */ NULL
,
181 /* pseudo_reloc_end */ NULL
,
182 /* image_base */ NULL
,
183 /* threadinterface */ &_mtinterf
,
184 /* impure_ptr */ _GLOBAL_REENT
,
186 int _check_for_executable
= true;
188 /* This was a bool initially, just indicating if we're in the forked
189 child during fork(2). However, we need an indicator accessible from
190 plain C we can ask if we're in a forked child even after fork(2)
191 finished. Therefore redefined how we use this variable. */
197 int NO_COPY __in_forkee
;
200 int NO_COPY __api_fatal_exit_val
= 1;
202 EXPORT_ALIAS (program_invocation_short_name
, __progname
)