diff options
author | Christopher Faylor <me@cgf.cx> | 2005-09-28 15:18:49 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-09-28 15:18:49 +0000 |
commit | 280fdd0b67c3dbd3cee12bf6dbe363f222d98342 (patch) | |
tree | 483b37f8f41a0ce565559a2a5340f2fe5c3c9e57 /winsup/cygwin/dcrt0.cc | |
parent | 9edadc960e8bd94cbfd812156fed35557309e2f5 (diff) | |
download | cygnal-280fdd0b67c3dbd3cee12bf6dbe363f222d98342.tar.gz cygnal-280fdd0b67c3dbd3cee12bf6dbe363f222d98342.tar.bz2 cygnal-280fdd0b67c3dbd3cee12bf6dbe363f222d98342.zip |
* dcrt0.cc (getstack): New function.
(alloc_stack): Use tls stuff for stack info rather than calling VirtualQuery.
(dll_crt0_0): Initialize _impure_ptr stuff much earlier. Move
init_console_handler here.
* fork.cc (class frok): New class renamed from local fork() struct.
(stack_base): Change argument type. Use tls stuff to determine stack info
rather than calling VirtualQuery.
(frok::child): Rename from fork_child. Eliminate now unneeded arguments.
(frok::parent): Rename from fork_parent and ditto. Set error and errno as
appropriate. Fixup impersonation in cleanup, if needed. Try harder to set
errno appropriately.
(fork): Define "grouped" as a frok type. Deal with errors from fork_parent
here.
* init.cc (dll_entry): Remove init_console_handler call.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index ca8b601c9..953c93ec0 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -502,22 +502,29 @@ alloc_stack_hard_way (child_info_fork *ci, volatile char *b) b[0] = '\0'; } +void *getstack (void *) __attribute__ ((noinline)); +volatile char * +getstack (volatile char *p) +{ + *p |= 0; + return p - 4096; +} + /* extend the stack prior to fork longjmp */ static void alloc_stack (child_info_fork *ci) { - /* FIXME: adding 16384 seems to avoid a stack copy problem during - fork on Win95, but I don't know exactly why yet. DJ */ - volatile char b[ci->stacksize + 16384]; - - if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm)) - api_fatal ("fork: couldn't get stack info, %E"); - - if (sm.AllocationBase == ci->stacktop) - ci->stacksize = 0; + volatile char *esp; + __asm__ volatile ("movl %%esp,%0": "=r" (esp)); + if (_tlsbase != ci->stackbottom) + alloc_stack_hard_way (ci, esp); else - alloc_stack_hard_way (ci, b + sizeof (b) - 1); + { + while (_tlstop > ci->stacktop) + esp = getstack (esp); + ci->stacksize = 0; + } } #ifdef DEBUGGING @@ -629,6 +636,12 @@ get_cygwin_startup_info () void __stdcall dll_crt0_0 () { + init_console_handler (TRUE); + _impure_ptr = _GLOBAL_REENT; + _impure_ptr->_stdin = &_impure_ptr->__sf[0]; + _impure_ptr->_stdout = &_impure_ptr->__sf[1]; + _impure_ptr->_stderr = &_impure_ptr->__sf[2]; + _impure_ptr->_current_locale = "C"; wincap.init (); initial_env (); @@ -931,11 +944,6 @@ _dll_crt0 () *main_environ = NULL; char padding[CYGTLS_PADSIZE]; - _impure_ptr = _GLOBAL_REENT; - _impure_ptr->_stdin = &_impure_ptr->__sf[0]; - _impure_ptr->_stdout = &_impure_ptr->__sf[1]; - _impure_ptr->_stderr = &_impure_ptr->__sf[2]; - _impure_ptr->_current_locale = "C"; if (child_proc_info && child_proc_info->type == _PROC_FORK) user_data->forkee = true; |