diff options
author | Christopher Faylor <me@cgf.cx> | 2002-06-15 21:59:32 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-06-15 21:59:32 +0000 |
commit | 6ea3e429df9c98b850e3a4bf906da06f1c447bd9 (patch) | |
tree | 44e991f12dde60a88b0e2223dc9ba18bc22abe61 /winsup/cygwin | |
parent | 5ae611458b5e107705f414c782afc53ce0bd4b59 (diff) | |
download | newlib-6ea3e429df9c98b850e3a4bf906da06f1c447bd9.zip newlib-6ea3e429df9c98b850e3a4bf906da06f1c447bd9.tar.gz newlib-6ea3e429df9c98b850e3a4bf906da06f1c447bd9.tar.bz2 |
* child_info.h (child_proc_info): Declare as base class.
(spawn_info): Declare as alias of child_proc_info to aid debugging.
(fork_info): Ditto.
* cygheap.cc (cygheap_fixup_in_child): Use child_proc_info global rather than
parameter.
* cygheap.h (cygheap_fixup_in_child): Reflect above change in declaration.
* dcrt0.cc (_dll_crt0): Move 'si' definition here. Assign child_proc_info.
(dll_crt0_1): Accommodate cygheap_fixup_in_child and *_info changes.
* environ.cc (spenv::retrieve): Make regparm.
* environ.h (environ_init): Ditto.
(win_env::add_cache): Ditto.
(build_env): Ditto.
(getwinenv): Ditto.
* fork.cc (sync_with_parent): Use fork_info global.
(fork_child): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 20 | ||||
-rw-r--r-- | winsup/cygwin/child_info.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 12 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 46 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/environ.h | 12 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 18 |
8 files changed, 71 insertions, 46 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 42c0604..ea8b866 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +2002-06-15 Christopher Faylor <cgf@redhat.com> + + * child_info.h (child_proc_info): Declare as base class. + (spawn_info): Declare as alias of child_proc_info to aid debugging. + (fork_info): Ditto. + * cygheap.cc (cygheap_fixup_in_child): Use child_proc_info global + rather than parameter. + * cygheap.h (cygheap_fixup_in_child): Reflect above change in + declaration. + * dcrt0.cc (_dll_crt0): Move 'si' definition here. Assign + child_proc_info. + (dll_crt0_1): Accommodate cygheap_fixup_in_child and *_info changes. + * environ.cc (spenv::retrieve): Make regparm. + * environ.h (environ_init): Ditto. + (win_env::add_cache): Ditto. + (build_env): Ditto. + (getwinenv): Ditto. + * fork.cc (sync_with_parent): Use fork_info global. + (fork_child): Ditto. + 2002-06-14 Christopher Faylor <cgf@redhat.com> * uinfo.cc (cygheap_user::ontherange): Don't set HOMEDRIVE or HOMEPATH diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index fdfaa28..4b68e42 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -108,4 +108,6 @@ public: void __stdcall init_child_info (DWORD, child_info *, int, HANDLE); -extern child_info_fork *child_proc_info; +extern child_info *child_proc_info; +extern child_info_spawn *spawn_info __attribute__ ((alias ("child_proc_info"))); +extern child_info_fork *fork_info __attribute__ ((alias ("child_proc_info"))); diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 8f76b5b..aba80c6 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -110,18 +110,18 @@ cygheap_setup_for_child_cleanup (void *newcygheap, child_info *ci, /* Called by fork or spawn to reallocate cygwin heap */ void __stdcall -cygheap_fixup_in_child (child_info *ci, bool execed) +cygheap_fixup_in_child (bool execed) { - cygheap = ci->cygheap; - cygheap_max = ci->cygheap_max; + cygheap = child_proc_info->cygheap; + cygheap_max = child_proc_info->cygheap_max; void *addr = !wincap.map_view_of_file_ex_sucks () ? cygheap : NULL; void *newaddr; - newaddr = MapViewOfFileEx (ci->cygheap_h, MVMAP_OPTIONS, 0, 0, 0, addr); + newaddr = MapViewOfFileEx (child_proc_info->cygheap_h, MVMAP_OPTIONS, 0, 0, 0, addr); if (newaddr != cygheap) { if (!newaddr) - newaddr = MapViewOfFileEx (ci->cygheap_h, MVMAP_OPTIONS, 0, 0, 0, NULL); + newaddr = MapViewOfFileEx (child_proc_info->cygheap_h, MVMAP_OPTIONS, 0, 0, 0, NULL); DWORD n = (DWORD) cygheap_max - (DWORD) cygheap; /* Reserve cygwin heap in same spot as parent */ if (!VirtualAlloc (cygheap, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS)) @@ -144,7 +144,7 @@ cygheap_fixup_in_child (child_info *ci, bool execed) UnmapViewOfFile (newaddr); } - ForceCloseHandle1 (ci->cygheap_h, passed_cygheap_h); + ForceCloseHandle1 (child_proc_info->cygheap_h, passed_cygheap_h); cygheap_init (); diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index f8777cc..7687ab7 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -276,7 +276,7 @@ class cygheap_fdget : public cygheap_fdmanip class child_info; void *__stdcall cygheap_setup_for_child (child_info *ci, bool dup_later) __attribute__ ((regparm(2))); void __stdcall cygheap_setup_for_child_cleanup (void *, child_info *, bool) __attribute__ ((regparm(3))); -void __stdcall cygheap_fixup_in_child (child_info *, bool); +void __stdcall cygheap_fixup_in_child (bool); extern "C" { void __stdcall cfree (void *) __attribute__ ((regparm(1))); void *__stdcall cmalloc (cygheap_types, DWORD) __attribute__ ((regparm(2))); diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 7776e40..4f4f9c3 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -451,10 +451,7 @@ check_sanity_and_sync (per_process *p) signal_shift_subtract = 0; } -static NO_COPY STARTUPINFO si; -# define fork_info ((struct child_info_fork *)(si.lpReserved2)) -# define spawn_info ((struct child_info_spawn *)(si.lpReserved2)) -child_info_fork NO_COPY *child_proc_info = NULL; +child_info NO_COPY *child_proc_info = NULL; static MEMORY_BASIC_INFORMATION sm; #define CYGWIN_GUARD ((wincap.has_page_guard ()) ? PAGE_GUARD : PAGE_NOACCESS) @@ -588,10 +585,10 @@ dll_crt0_1 () switch (child_proc_info->type) { case _PROC_FORK: - cygheap_fixup_in_child (child_proc_info, 0); + cygheap_fixup_in_child (0); alloc_stack (fork_info); set_myself (mypid); - ProtectHandle (child_proc_info->forker_finished); + ProtectHandle (fork_info->forker_finished); break; case _PROC_SPAWN: if (spawn_info->hexec_proc) @@ -601,7 +598,7 @@ dll_crt0_1 () hexec_proc = spawn_info->hexec_proc; around: HANDLE h; - cygheap_fixup_in_child (spawn_info, 1); + cygheap_fixup_in_child (1); if (!spawn_info->moreinfo->myself_pinfo || !DuplicateHandle (hMainProc, spawn_info->moreinfo->myself_pinfo, hMainProc, &h, 0, 0, @@ -805,6 +802,7 @@ _dll_crt0 () DECLARE_TLS_STORAGE; initial_env (); char zeros[sizeof (fork_info->zero)] = {0}; + static NO_COPY STARTUPINFO si; #ifdef DEBUGGING strace.microseconds (); #endif @@ -822,42 +820,42 @@ _dll_crt0 () &hMainThread, 0, false, DUPLICATE_SAME_ACCESS); GetStartupInfo (&si); + child_proc_info = (child_info *) si.lpReserved2; if (si.cbReserved2 >= EXEC_MAGIC_SIZE && - memcmp (fork_info->zero, zeros, sizeof (zeros)) == 0) + memcmp (child_proc_info->zero, zeros, sizeof (zeros)) == 0) { - if ((fork_info->intro & OPROC_MAGIC_MASK) == OPROC_MAGIC_GENERIC) - multiple_cygwin_problem ("proc", fork_info->intro, 0); - else if (fork_info->intro == PROC_MAGIC_GENERIC - && fork_info->magic != CHILD_INFO_MAGIC) - multiple_cygwin_problem ("proc", fork_info->magic, CHILD_INFO_MAGIC); + if ((child_proc_info->intro & OPROC_MAGIC_MASK) == OPROC_MAGIC_GENERIC) + multiple_cygwin_problem ("proc", child_proc_info->intro, 0); + else if (child_proc_info->intro == PROC_MAGIC_GENERIC + && child_proc_info->magic != CHILD_INFO_MAGIC) + multiple_cygwin_problem ("proc", child_proc_info->magic, CHILD_INFO_MAGIC); unsigned should_be_cb = 0; - switch (fork_info->type) + switch (child_proc_info->type) { case _PROC_FORK: - user_data->forkee = fork_info->cygpid; + user_data->forkee = child_proc_info->cygpid; should_be_cb = sizeof (child_info_fork); /* fall through */; case _PROC_SPAWN: - if (fork_info->pppid_handle) - CloseHandle (fork_info->pppid_handle); + if (child_proc_info->pppid_handle) + CloseHandle (child_proc_info->pppid_handle); /* fall through */; case _PROC_EXEC: if (!should_be_cb) should_be_cb = sizeof (child_info); - if (should_be_cb != fork_info->cb) - multiple_cygwin_problem ("proc size", fork_info->cb, should_be_cb); - else if (sizeof (fhandler_union) != fork_info->fhandler_union_cb) - multiple_cygwin_problem ("fhandler size", fork_info->fhandler_union_cb, sizeof (fhandler_union)); + if (should_be_cb != child_proc_info->cb) + multiple_cygwin_problem ("proc size", child_proc_info->cb, should_be_cb); + else if (sizeof (fhandler_union) != child_proc_info->fhandler_union_cb) + multiple_cygwin_problem ("fhandler size", child_proc_info->fhandler_union_cb, sizeof (fhandler_union)); else { - child_proc_info = fork_info; cygwin_mount_h = child_proc_info->mount_h; mypid = child_proc_info->cygpid; break; } default: - system_printf ("unknown exec type %d", fork_info->type); - fork_info = NULL; + system_printf ("unknown exec type %d", child_proc_info->type); + child_proc_info = NULL; break; } } diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 9ed6e41..50da31c 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -754,7 +754,8 @@ struct spenv { const char *name; const char * (cygheap_user::*from_cygheap) (); - char *retrieve (bool, const char * const = NULL, int = 0); + char *retrieve (bool, const char * const = NULL, int = 0) + __attribute__ ((regparm (3))); }; /* Keep this list in upper case and sorted */ diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h index 3f372b1..ebccc53 100644 --- a/winsup/cygwin/environ.h +++ b/winsup/cygwin/environ.h @@ -9,7 +9,8 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ /* Initialize the environment */ -void environ_init (char **, int); +void environ_init (char **, int) + __attribute__ ((regparm (2))); /* The structure below is used to control conversion to/from posix-style file specs. Currently, only PATH and HOME are converted, but PATH @@ -26,15 +27,18 @@ struct win_env int (*towin32) (const char *, char *); int (*posix_len) (const char *); int (*win32_len) (const char *); - void add_cache (const char *in_posix, const char *in_native = NULL); + void add_cache (const char *in_posix, const char *in_native = NULL) + __attribute__ ((regparm (3))); const char * get_native () const {return native ? native + namelen : NULL;} const char * get_posix () const {return posix ? posix : NULL;} }; -win_env * __stdcall getwinenv (const char *name, const char *posix = NULL); +win_env * __stdcall getwinenv (const char *name, const char *posix = NULL) + __attribute__ ((regparm (3))); void __stdcall update_envptrs (); extern char **__cygwin_environ, ***main_environ; extern "C" char __stdcall **cur_environ (); char ** __stdcall build_env (const char * const *envp, char *&envblock, - int &envc, bool need_envblock); + int &envc, bool need_envblock) + __attribute__ ((regparm (3))); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index ff464f0..7a7cac0 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -196,11 +196,11 @@ sync_with_parent(const char *s, bool hang_self) { debug_printf ("signalling parent: %s", s); /* Tell our parent we're waiting. */ - if (!SetEvent (child_proc_info->subproc_ready)) + if (!SetEvent (fork_info->subproc_ready)) api_fatal ("fork child - SetEvent for %s failed, %E", s); if (hang_self) { - HANDLE h = child_proc_info->forker_finished; + HANDLE h = fork_info->forker_finished; /* Wait for the parent to fill in our stack and heap. Don't wait forever here. If our parent dies we don't want to clog the system. If the wait fails, we really can't continue so exit. */ @@ -213,10 +213,10 @@ sync_with_parent(const char *s, bool hang_self) break; case WAIT_FAILED: if (GetLastError () == ERROR_INVALID_HANDLE && - WaitForSingleObject (child_proc_info->forker_finished, 1) != WAIT_FAILED) + WaitForSingleObject (fork_info->forker_finished, 1) != WAIT_FAILED) break; api_fatal ("WFSO failed for %s, fork_finished %p, %E", s, - child_proc_info->forker_finished); + fork_info->forker_finished); break; default: debug_printf ("no problems"); @@ -265,10 +265,10 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls) fork() was invoked from other than the main thread. Make sure that when the "main" thread exits it calls do_exit, like a normal process. Exit with a status code of 0. */ - if (child_proc_info->stacksize) + if (fork_info->stacksize) { - ((DWORD *)child_proc_info->stackbottom)[-17] = (DWORD)do_exit; - ((DWORD *)child_proc_info->stackbottom)[-15] = (DWORD)0; + ((DWORD *)fork_info->stackbottom)[-17] = (DWORD)do_exit; + ((DWORD *)fork_info->stackbottom)[-15] = (DWORD)0; } set_file_api_mode (current_codepage); @@ -298,8 +298,8 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls) } ForceCloseHandle (hParent); - (void) ForceCloseHandle (child_proc_info->subproc_ready); - (void) ForceCloseHandle (child_proc_info->forker_finished); + (void) ForceCloseHandle (fork_info->subproc_ready); + (void) ForceCloseHandle (fork_info->forker_finished); if (fixup_shms_after_fork ()) api_fatal ("recreate_shm areas after fork failed"); |