OSDN Git Service

* path.cc (conv_path_list): Take cygwin_conv_path_t as third parameter.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / globals.cc
1 /* globals.cc - Define global variables here.
2
3    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4    2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
5
6 This file is part of Cygwin.
7
8 This software is a copyrighted work licensed under the terms of the
9 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
10 details. */
11
12 #define _GLOBALS_H 1
13 #include "winsup.h"
14 #include "cygtls.h"
15 #include "perprocess.h"
16 #include "cygprops.h"
17 #include "thread.h"
18 #include <malloc.h>
19 #include <cygwin/version.h>
20
21 HANDLE NO_COPY hMainThread;
22 HANDLE NO_COPY hProcToken;
23 HANDLE NO_COPY hProcImpToken;
24 HMODULE NO_COPY cygwin_hmodule;
25 int NO_COPY sigExeced;
26 WCHAR NO_COPY windows_system_directory[MAX_PATH];
27 UINT NO_COPY windows_system_directory_length;
28
29 /* program exit the program */
30
31 enum exit_states
32   {
33     ES_NOT_EXITING = 0,
34     ES_EXIT_STARTING,
35     ES_PROCESS_LOCKED,
36     ES_EVENTS_TERMINATE,
37     ES_SIGNAL,
38     ES_CLOSEALL,
39     ES_THREADTERM,
40     ES_HUP_PGRP,
41     ES_HUP_SID,
42     ES_EXEC_EXIT,
43     ES_TTY_TERMINATE,
44     ES_FINAL
45   };
46
47 exit_states NO_COPY exit_state;
48
49 /* Set in init.cc.  Used to check if Cygwin DLL is dynamically loaded. */
50 int NO_COPY dynamically_loaded;
51
52 /* Some CYGWIN environment variable variables. */
53 bool allow_glob = true;
54
55 bool NO_COPY in_forkee;
56
57 int __argc_safe;
58 int __argc;
59 char **__argv;
60 #ifdef NEWVFORK
61 vfork_save NO_COPY *main_vfork;
62 #endif
63
64 _cygtls NO_COPY *_main_tls /* !globals.h */;
65
66 bool NO_COPY cygwin_finished_initializing;
67
68 bool NO_COPY _cygwin_testing;
69
70 char NO_COPY almost_null[1];
71
72 /* Heavily-used const UNICODE_STRINGs are defined here once.  The idea is a
73    speed improvement by not having to initialize a UNICODE_STRING every time
74    we make a string comparison.  The strings are not defined as const,
75    because the respective NT functions are not taking const arguments
76    and doing so here results in lots of extra casts for no good reason.
77    Rather, the strings are placed in the R/O section .rdata, so we get
78    a SEGV if some code erroneously tries to overwrite these strings. */
79 #define _ROU(_s) \
80         { Length: sizeof (_s) - sizeof (WCHAR), \
81           MaximumLength: sizeof (_s), \
82           Buffer: (PWSTR) (_s) }
83 UNICODE_STRING _RDATA ro_u_empty = _ROU (L"");
84 UNICODE_STRING _RDATA ro_u_lnk = _ROU (L".lnk");
85 UNICODE_STRING _RDATA ro_u_exe = _ROU (L".exe");
86 UNICODE_STRING _RDATA ro_u_dll = _ROU (L".dll");
87 UNICODE_STRING _RDATA ro_u_com = _ROU (L".com");
88 UNICODE_STRING _RDATA ro_u_scr = _ROU (L".scr");
89 UNICODE_STRING _RDATA ro_u_sys = _ROU (L".sys");
90 UNICODE_STRING _RDATA ro_u_proc = _ROU (L"proc");
91 UNICODE_STRING _RDATA ro_u_pmem = _ROU (L"\\Device\\PhysicalMemory");
92 UNICODE_STRING _RDATA ro_u_natp = _ROU (L"\\??\\");
93 UNICODE_STRING _RDATA ro_u_uncp = _ROU (L"\\??\\UNC\\");
94 UNICODE_STRING _RDATA ro_u_mtx = _ROU (L"mtx");
95 UNICODE_STRING _RDATA ro_u_csc = _ROU (L"CSC-CACHE");
96 UNICODE_STRING _RDATA ro_u_fat = _ROU (L"FAT");
97 UNICODE_STRING _RDATA ro_u_mvfs = _ROU (L"MVFS");
98 UNICODE_STRING _RDATA ro_u_nfs = _ROU (L"NFS");
99 UNICODE_STRING _RDATA ro_u_ntfs = _ROU (L"NTFS");
100 UNICODE_STRING _RDATA ro_u_sunwnfs = _ROU (L"SUNWNFS");
101 UNICODE_STRING _RDATA ro_u_udf = _ROU (L"UDF");
102 UNICODE_STRING _RDATA ro_u_unixfs = _ROU (L"UNIXFS");
103 UNICODE_STRING _RDATA ro_u_nwfs = _ROU (L"NWFS");
104 UNICODE_STRING _RDATA ro_u_ncfsd = _ROU (L"NcFsd");
105 UNICODE_STRING _RDATA ro_u_volume = _ROU (L"\\??\\Volume{");
106 UNICODE_STRING _RDATA ro_u_pipedir = _ROU (L"\\\\?\\PIPE\\");
107 UNICODE_STRING _RDATA ro_u_globalroot = _ROU (L"\\\\.\\GLOBALROOT");
108 #undef _ROU
109
110 /* Cygwin properties are meant to be readonly data placed in the DLL, but
111    which can be changed by external tools to make adjustments to the
112    behaviour of a DLL based on the binary of the DLL itself.  This is
113    different from $CYGWIN since it only affects that very DLL, not all
114    DLLs which have access to the $CYGWIN environment variable. */
115 cygwin_props_t _RDATA cygwin_props =
116 {
117   CYGWIN_PROPS_MAGIC,
118   sizeof (cygwin_props_t),
119   0
120 };
121
122 extern "C"
123 {
124   /* This is an exported copy of environ which can be used by DLLs
125      which use cygwin.dll.  */
126   char **__cygwin_environ;
127   char ***main_environ = &__cygwin_environ;
128   /* __progname used in getopt error message */
129   char *__progname;
130   char *program_invocation_name;
131   char *program_invocation_short_name;
132   static MTinterface _mtinterf;
133   struct per_process __cygwin_user_data =
134   {/* initial_sp */ 0, /* magic_biscuit */ 0,
135    /* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
136    /* dll_major */ CYGWIN_VERSION_DLL_MINOR,
137    /* impure_ptr_ptr */ NULL, /* envptr */ NULL,
138    /* malloc */ malloc, /* free */ free,
139    /* realloc */ realloc,
140    /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL,
141    /* dtors */ NULL, /* data_start */ NULL, /* data_end */ NULL,
142    /* bss_start */ NULL, /* bss_end */ NULL,
143    /* calloc */ calloc,
144    /* premain */ {NULL, NULL, NULL, NULL},
145    /* run_ctors_p */ 0,
146    /* unused */ {},
147    /* cxx_malloc */ &default_cygwin_cxx_malloc,
148    /* hmodule */ NULL,
149    /* api_major */ 0,
150    /* api_minor */ 0,
151    /* unused2 */ {},
152    /* pseudo_reloc_start */ NULL,
153    /* pseudo_reloc_end */ NULL,
154    /* image_base */ NULL,
155    /* threadinterface */ &_mtinterf,
156    /* impure_ptr */ _GLOBAL_REENT,
157   };
158   bool ignore_case_with_glob;
159   int _check_for_executable = true;
160 };
161
162 int NO_COPY __api_fatal_exit_val = 1;