diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-05-23 20:10:35 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-05-23 20:10:35 +0000 |
commit | c6696a3426628761a201c12af68325b12ec6f0b8 (patch) | |
tree | 830a7155ce623e0fa95ac94d1b49f99d6fb51279 /winsup/cygwin/fork.cc | |
parent | df7a7e2e825ce3ca99a1605fed7fd2814568e671 (diff) | |
download | newlib-c6696a3426628761a201c12af68325b12ec6f0b8.zip newlib-c6696a3426628761a201c12af68325b12ec6f0b8.tar.gz newlib-c6696a3426628761a201c12af68325b12ec6f0b8.tar.bz2 |
* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fix datatype of
stacksize to SIZE_T. Cast to SIZE_T in pointer arithmetic. Slightly
enhance output in case of a fatal error.
* fork.cc (frok::parent): Always set ch.stackaddr to DeallocationStack
value of current thread to help stack reservation in
child_info_fork::alloc_stack_hard_way along. Simplify subsequent code
storing stack values in ch. Print guardsize in hex, too.
Diffstat (limited to 'winsup/cygwin/fork.cc')
-rw-r--r-- | winsup/cygwin/fork.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 6346213..7d5f710 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -302,17 +302,17 @@ frok::parent (volatile char * volatile stack_here) ch.forker_finished = forker_finished; + PTEB teb = NtCurrentTeb (); ch.stackbottom = _tlsbase; ch.stacktop = (void *) _tlstop; - ch.stackaddr = 0; + ch.stackaddr = teb->DeallocationStack; ch.guardsize = 0; if (&_my_tls != _main_tls) { /* We have not been started from the main thread. Fetch the information required to set up the thread stack identically in the child. */ - PTEB teb = NtCurrentTeb (); - if (!teb->DeallocationStack) + if (!ch.stackaddr) { /* Pthread with application-provided stack. Don't set up a PAGE_GUARD page. guardsize == -1 is used in alloc_stack_hard_way @@ -320,15 +320,11 @@ frok::parent (volatile char * volatile stack_here) ch.stackaddr = _my_tls.tid->attr.stackaddr; ch.guardsize = (size_t) -1; } - else - { - ch.stackaddr = teb->DeallocationStack; - /* If it's a pthread, fetch guardsize from thread attributes. */ - if (_my_tls.tid) - ch.guardsize = _my_tls.tid->attr.guardsize; - } + else if (_my_tls.tid) + /* If it's a pthread, fetch guardsize from thread attributes. */ + ch.guardsize = _my_tls.tid->attr.guardsize; } - debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %lu", + debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %ly", ch.stackbottom, ch.stacktop, ch.stackaddr, ch.guardsize); PROCESS_INFORMATION pi; |