From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id 6AE963870870; Mon, 30 May 2022 15:07:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AE963870870 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: remove some 32-bit only environment code X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: 3e917daec121ae5fd5cdcbb25d0d4e9d1cfd0a2a X-Git-Newrev: f6bb8bfaa055ddf5efee422290e034b463aa154b Message-Id: <20220530150700.6AE963870870@sourceware.org> Date: Mon, 30 May 2022 15:07:00 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2022 15:07:00 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Df6bb8bfaa05= 5ddf5efee422290e034b463aa154b commit f6bb8bfaa055ddf5efee422290e034b463aa154b Author: Ken Brown Date: Tue May 24 10:23:39 2022 -0400 Cygwin: remove some 32-bit only environment code Diff: --- winsup/cygwin/dcrt0.cc | 18 ------------------ winsup/cygwin/dll_init.cc | 25 ------------------------- winsup/cygwin/dll_init.h | 6 ------ winsup/cygwin/environ.cc | 21 --------------------- winsup/cygwin/environ.h | 7 ------- winsup/cygwin/globals.cc | 6 ------ winsup/cygwin/include/sys/cygwin.h | 3 --- 7 files changed, 86 deletions(-) diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 5fb34d7e8..b846cc5bb 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1019,11 +1019,7 @@ dll_crt0_1 (void *) sig_dispatch_pending (false); _my_tls.call_signal_handler (); _my_tls.incyg--; /* Not in Cygwin anymore */ -#ifdef __x86_64__ cygwin_exit (user_data->main (__argc, newargv, __cygwin_environ)); -#else - cygwin_exit (user_data->main (__argc, newargv, *user_data->envptr)); -#endif } __asm__ (" \n\ .global _cygwin_exit_return \n\ @@ -1037,7 +1033,6 @@ __cygwin_exit_return: \n\ extern "C" void __stdcall _dll_crt0 () { -#ifdef __x86_64__ /* Starting with Windows 10 rel 1511, the main stack of an application is not reproducible if a 64 bit process has been started from a 32 bit process. Given that we have enough virtual address space on 64 bit @@ -1070,11 +1065,6 @@ _dll_crt0 () else fork_info->alloc_stack (); } -#else - main_environ =3D user_data->envptr; - if (in_forkee) - fork_info->alloc_stack (); -#endif =20 fesetenv (FE_DFL_ENV); _main_tls =3D &_my_tls; @@ -1104,18 +1094,10 @@ dll_crt0 (per_process *uptr) extern "C" void cygwin_dll_init () { -#ifdef __i386__ - static char **envp; -#endif static int _fmode; =20 user_data->magic_biscuit =3D sizeof (per_process); - -#ifdef __i386__ - user_data->envptr =3D &envp; -#endif user_data->fmode_ptr =3D &_fmode; - _dll_crt0 (); } =20 diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 6a4ed269e..24e3b8764 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -204,14 +204,6 @@ dll::init () { int ret =3D 1; =20 -#ifdef __i386__ - /* This should be a no-op. Why didn't we just import this variable? */ - if (!p.envptr) - p.envptr =3D &__cygwin_environ; - else if (*(p.envptr) !=3D __cygwin_environ) - *(p.envptr) =3D __cygwin_environ; -#endif - /* Don't run constructors or the "main" if we've forked. */ if (!in_forkee) { @@ -387,9 +379,6 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type = type) loaded_dlls++; } guard (false); -#ifdef __i386__ - assert (p->envptr !=3D NULL); -#endif return d; } =20 @@ -911,17 +900,3 @@ dlfork (int val) { dlls.reload_on_fork =3D val; } - -#ifdef __i386__ -/* Called from various places to update all of the individual - ideas of the environ block. Explain to me again why we didn't - just import __cygwin_environ? */ -void __stdcall -update_envptrs () -{ - for (dll *d =3D dlls.istart (DLL_ANY); d; d =3D dlls.inext ()) - if (*(d->p.envptr) !=3D __cygwin_environ) - *(d->p.envptr) =3D __cygwin_environ; - *main_environ =3D __cygwin_environ; -} -#endif diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h index 3c274cf35..65f4213db 100644 --- a/winsup/cygwin/dll_init.h +++ b/winsup/cygwin/dll_init.h @@ -8,9 +8,6 @@ details. */ =20 struct per_module { -#ifdef __i386__ - char ***envptr; -#endif void (**ctors)(void); void (**dtors)(void); void *data_start; @@ -20,9 +17,6 @@ struct per_module int (*main)(int, char **, char **); per_module &operator =3D (per_process *p) { -#ifdef __i386__ - envptr =3D p->envptr; -#endif ctors =3D p->ctors; dtors =3D p->dtors; data_start =3D p->data_start; diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 99b220d55..ab593ab64 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -626,7 +626,6 @@ _addenv (const char *name, const char *value, int overw= rite) } =20 __cygwin_environ[offset + 1] =3D NULL; /* NULL terminate. */ - update_envptrs (); /* Update any local copies of 'environ'. */ } =20 char *envhere; @@ -742,7 +741,6 @@ clearenv (void) lastenviron =3D NULL; } __cygwin_environ =3D NULL; - update_envptrs (); return 0; } __except (EFAULT) {} @@ -845,7 +843,6 @@ environ_init (char **envp, int envc) out: findenv_func =3D (char * (*)(const char*, int*)) my_findenv; __cygwin_environ =3D envp; - update_envptrs (); if (envp_passed_in) { p =3D getenv ("CYGWIN"); @@ -1311,21 +1308,3 @@ build_env (const char * const *envp, PWCHAR &envbloc= k, int &envc, debug_printf ("envp %p, envc %d", newenv, envc); return newenv; } - -#ifdef __i386__ -/* This idiocy is necessary because the early implementers of cygwin - did not seem to know about importing data variables from the DLL. - So, we have to synchronize cygwin's idea of the environment with the - main program's with each reference to the environment. */ -extern "C" char ** __stdcall -cur_environ () -{ - if (*main_environ !=3D __cygwin_environ) - { - __cygwin_environ =3D *main_environ; - update_envptrs (); - } - - return __cygwin_environ; -} -#endif diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h index fc34f1e91..3980d6b5a 100644 --- a/winsup/cygwin/environ.h +++ b/winsup/cygwin/environ.h @@ -33,15 +33,8 @@ struct win_env win_env *getwinenv (const char *name, const char *posix =3D NULL, win_env = * =3D NULL); char *getwinenveq (const char *name, size_t len, int); =20 -#ifdef __x86_64__ -#define update_envptrs() extern "C" char **__cygwin_environ; #define cur_environ() __cygwin_environ -#else -void __stdcall update_envptrs (); -extern "C" char **__cygwin_environ, ***main_environ; -extern "C" char __stdcall **cur_environ (); -#endif char **build_env (const char * const *envp, PWCHAR &envblock, int &envc, bool need_envblock, HANDLE new_token); =20 diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index aad5d4259..294a67fe8 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -158,9 +158,6 @@ const int __collate_load_error =3D 0; /* This is an exported copy of environ which can be used by DLLs which use cygwin.dll. */ char **__cygwin_environ; -#ifdef __i386__ - char ***main_environ =3D &__cygwin_environ; -#endif /* __progname used in getopt error message */ char *__progname; char *program_invocation_name; @@ -171,9 +168,6 @@ const int __collate_load_error =3D 0; /* dll_major */ CYGWIN_VERSION_DLL_MAJOR, /* dll_major */ CYGWIN_VERSION_DLL_MINOR, /* impure_ptr_ptr */ NULL, -#ifdef __i386__ - /* envptr */ NULL, -#endif /* malloc */ malloc, /* free */ free, /* realloc */ realloc, /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL, diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys= /cygwin.h index 4923caacb..5532cb683 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -293,9 +293,6 @@ struct per_process uint32_t dll_minor; =20 struct _reent **impure_ptr_ptr; -#ifdef __i386__ - char ***envptr; -#endif =20 /* Used to point to the memory machine we should use. Usually these point back into the dll, but they can be overridden by the user. */