From 57c89867f5d355d62917f0c1db4d0cd02741cc9a Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 6 Sep 2001 05:17:22 +0000 Subject: [PATCH] Move appropriate variables to NO_COPY segment, throughout. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/dcrt0.cc | 2 +- winsup/cygwin/dll_init.cc | 2 +- winsup/cygwin/dtable.cc | 2 +- winsup/cygwin/environ.cc | 12 ++++++------ winsup/cygwin/errno.cc | 6 +++--- winsup/cygwin/fhandler.cc | 2 +- winsup/cygwin/fhandler_clipboard.cc | 2 +- winsup/cygwin/fhandler_console.cc | 2 +- winsup/cygwin/localtime.cc | 4 ++-- winsup/cygwin/miscfuncs.cc | 4 ++-- winsup/cygwin/net.cc | 4 ++-- winsup/cygwin/path.cc | 2 +- winsup/cygwin/registry.cc | 2 +- winsup/cygwin/tz_posixrules.h | 2 +- winsup/cygwin/window.cc | 2 +- winsup/cygwin/winsup.h | 4 ++-- 17 files changed, 31 insertions(+), 27 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 69bdb99a8..ee455caf9 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +Thu Sep 6 01:16:44 2001 Christopher Faylor + + Move appropriate variables to NO_COPY segment, throughout. + Thu Sep 6 00:40:35 2001 Christopher Faylor Remove initialization of static or global values to zero, throughout. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 43940b435..ae95c8b4f 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -67,7 +67,7 @@ int cygwin_finished_initializing; bit for masking. So, we'll temporarily detect this and set it to zero for programs that are linked using older cygwins. This is just a stopgap measure to allow an orderly transfer to the new, correct sigmask method. */ -unsigned int signal_shift_subtract = 1; +unsigned NO_COPY int signal_shift_subtract = 1; ResourceLocks _reslock NO_COPY; MTinterface _mtinterf NO_COPY; diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 74bec0769..265ebf85a 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -18,7 +18,7 @@ extern void __stdcall check_sanity_and_sync (per_process *); dll_list NO_COPY dlls; -static NO_COPY int in_forkee; +static NO_COPY int in_forkee = 0; static int dll_global_dtors_recorded; /* Run destructors for all DLLs on exit. */ diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 8e4d40bed..0b3ad2575 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -32,7 +32,7 @@ details. */ #include "dtable.h" #include "cygheap.h" -static DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, +static const NO_COPY DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE}; /* Set aside space for the table of fds */ diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index ab5766375..cc127ad29 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -53,7 +53,7 @@ static char **lastenviron; CreateProcess. HOME is here because most shells use it and would be confused by Windows style path names. */ static int return_MAX_PATH (const char *) {return MAX_PATH;} -static win_env conv_envvars[] = +static NO_COPY win_env conv_envvars[] = { {"PATH=", 5, NULL, NULL, cygwin_win32_to_posix_path_list, cygwin_posix_to_win32_path_list, @@ -110,7 +110,7 @@ getwinenv (const char *env, const char *in_posix) for (int i = 0; conv_envvars[i].name != NULL; i++) if (strncmp (env, conv_envvars[i].name, conv_envvars[i].namelen) == 0) { - win_env *we = conv_envvars + i; + win_env * const we = conv_envvars + i; const char *val; if (!cur_environ () || !(val = in_posix ?: getenv(we->name))) debug_printf ("can't set native for %s since no environ yet", @@ -477,7 +477,7 @@ subauth_id_init (const char *buf) /* The structure below is used to set up an array which is used to parse the CYGWIN environment variable or, if enabled, options from the registry. */ -struct parse_thing +static struct parse_thing { const char *name; union parse_setting @@ -495,7 +495,7 @@ struct parse_thing DWORD i; const char *s; } values[2]; - } known[] = + } known[] NO_COPY = { {"binmode", {x: &binmode}, justset, NULL, {{O_TEXT}, {O_BINARY}}}, {"check_case", {func: &check_case_init}, isfunc, NULL, {{0}, {0}}}, @@ -639,7 +639,7 @@ environ_init (char **envp, int envc) char *newp; int sawTERM = 0; bool envp_passed_in; - static char cygterm[] = "TERM=cygwin"; + static char NO_COPY cygterm[] = "TERM=cygwin"; static int initted; if (!initted) @@ -743,7 +743,7 @@ env_sort (const void *a, const void *b) } /* Keep this list in upper case and sorted */ -const char* forced_winenv_vars [] = +static const NO_COPY char* forced_winenv_vars [] = { "SYSTEMDRIVE", "SYSTEMROOT", diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index f9a3ca15c..540951c56 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -21,7 +21,7 @@ details. */ #define X(w, e) {ERROR_##w, #w, e} -static const struct +static const NO_COPY struct { DWORD w; /* windows version of error */ const char *s; /* text of windows version */ @@ -145,7 +145,7 @@ seterrno (const char *file, int line) extern char *_user_strerror _PARAMS ((int)); -extern const char __declspec(dllexport) * const _sys_errlist[]= +extern const NO_COPY char __declspec(dllexport) * const _sys_errlist[]= { /* NOERROR 0 */ "No error", /* EPERM 1 */ "Not super-user", @@ -287,7 +287,7 @@ extern const char __declspec(dllexport) * const _sys_errlist[]= /* ECASECLASH 137 */ "Filename exists with different case" }; -int __declspec(dllexport) _sys_nerr = +int NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]); /* FIXME: Why is strerror() a long switch and not just: diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 6dd65bd59..88b80afe5 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -28,7 +28,7 @@ details. */ static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */ -static char fhandler_disk_dummy_name[] = "some disk file"; +static NO_COPY char fhandler_disk_dummy_name[] = "some disk file"; struct __cygwin_perfile *perfile_table; diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc index 97aaad884..6a22855aa 100644 --- a/winsup/cygwin/fhandler_clipboard.cc +++ b/winsup/cygwin/fhandler_clipboard.cc @@ -28,7 +28,7 @@ details. */ * changed? How does /dev/clipboard operate under (say) linux? */ -static const char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD"; +static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD"; /* this is MT safe because windows format id's are atomic */ static UINT cygnativeformat; diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 9bb6c0911..98155c9c1 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1646,7 +1646,7 @@ fhandler_console::write (const void *vsrc, size_t len) static struct { int vk; const char *val[4]; -} keytable[] = { +} const keytable[] NO_COPY = { /* NORMAL */ /* SHIFT */ /* CTRL */ /* ALT */ {VK_LEFT, {"\033[D", "\033[D", "\033[D", "\033\033[D"}}, {VK_RIGHT, {"\033[C", "\033[C", "\033[C", "\033\033[C"}}, diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc index daf888a04..43c64ce3c 100644 --- a/winsup/cygwin/localtime.cc +++ b/winsup/cygwin/localtime.cc @@ -499,9 +499,9 @@ struct tzhead { #define WILDABBR " " #endif /* !defined WILDABBR */ -static char wildabbr[] = WILDABBR; +static char wildabbr[] NO_COPY = WILDABBR; -static const char gmt[] = "GMT"; +static const char gmt[] NO_COPY = "GMT"; struct ttinfo { /* time type information */ long tt_gmtoff; /* UTC offset in seconds */ diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 49e7cebd9..1dfff73a2 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -14,7 +14,7 @@ details. */ /********************** String Helper Functions ************************/ -char case_folded_lower[] = { +const char case_folded_lower[] NO_COPY = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, '!', '"', '#', '$', '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', @@ -33,7 +33,7 @@ char case_folded_lower[] = { 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; -char case_folded_upper[] = { +const char case_folded_upper[] NO_COPY = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, '!', '"', '#', '$', '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 34489da8e..18ff29be5 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -286,7 +286,7 @@ struct tl int e; }; -static struct tl errmap[] = +static NO_COPY struct tl errmap[] = { {WSAEINTR, "WSAEINTR", EINTR}, {WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK}, @@ -356,7 +356,7 @@ __set_winsock_errno (const char *fn, int ln) * Since the member `s' isn't used for debug output we can use it * for the error text returned by herror and hstrerror. */ -static struct tl host_errmap[] = +const static NO_COPY struct tl host_errmap[] = { {WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND}, {WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN}, diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 7e32ae8ec..57e4e2c12 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -740,7 +740,7 @@ digits (const char *name) return p > name && !*p ? n : -1; } -const char *windows_device_names[] = +const char *windows_device_names[] NO_COPY = { NULL, "\\dev\\console", diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc index 1d3cce54e..9e91d1a12 100644 --- a/winsup/cygwin/registry.cc +++ b/winsup/cygwin/registry.cc @@ -14,7 +14,7 @@ details. */ #include "security.h" #include -char cygnus_class[] = "cygnus"; +static char NO_COPY cygnus_class[] = "cygnus"; reg_key::reg_key (HKEY top, REGSAM access, ...) { diff --git a/winsup/cygwin/tz_posixrules.h b/winsup/cygwin/tz_posixrules.h index 6059d67f7..dea668e2f 100644 --- a/winsup/cygwin/tz_posixrules.h +++ b/winsup/cygwin/tz_posixrules.h @@ -1,6 +1,6 @@ /* generated with bin2h from zoneinfo/posixrules */ -static unsigned char _posixrules_data[] = { +static NO_COPY unsigned char _posixrules_data[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0, 0,1,16,0,0,0,2,0,0,0,8,0,151,254,240,1,135,225,224,2,119,224,240,3,112,254,96,4,96,253,112,5,80, 224,96,6,64,223,112,7,48,194,96,7,141,25,112,9,16,164,96,9,173,148,240,10,240,134,96,11,224,133,112,12,217,162, diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc index 761db2500..4e6ddc914 100644 --- a/winsup/cygwin/window.cc +++ b/winsup/cygwin/window.cc @@ -74,7 +74,7 @@ Winmain (VOID *) { MSG msg; WNDCLASS wc; - static char classname[] = "CygwinWndClass"; + static const NO_COPY char classname[] = "CygwinWndClass"; /* Register the window class for the main window. */ diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 1b73a2f52..1b8c15579 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -35,9 +35,9 @@ details. */ #include #include -extern char case_folded_lower[]; +extern const char case_folded_lower[]; #define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)]) -extern char case_folded_upper[]; +extern const char case_folded_upper[]; #define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)]) #ifndef MALLOC_DEBUG