aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/miscfuncs.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-12-07 16:10:55 +0100
committerCorinna Vinschen <corinna@vinschen.de>2015-12-07 16:10:55 +0100
commite753e4129ad0843859e97a4c56962b5395f390b6 (patch)
treebd5d582009d7bb9af51487e6ac811fea52b55bb2 /winsup/cygwin/miscfuncs.cc
parent5aa8817e3a56da2b4177329e2d523f54eae7e142 (diff)
downloadnewlib-e753e4129ad0843859e97a4c56962b5395f390b6.zip
newlib-e753e4129ad0843859e97a4c56962b5395f390b6.tar.gz
newlib-e753e4129ad0843859e97a4c56962b5395f390b6.tar.bz2
Always allocate main thread stack from pthread stack area on x86_64.
* dcrt0.cc: Semi-revert commit 12743c2d5d2721f3a80b4d7671a349be03c1f520. (dll_crt0_0): Drop setting wow64_needs_stack_adjustment on 64 bit. (_dll_crt0): Split out 64 bit code again and always create new main thread stack, unless forked off from the non main thread in the parent. Call create_new_main_thread_stack with parent stack commitsize if started from the parent's main thread. Only call child_info_fork::alloc_stack for the latter case on 64 bit. Slightly rearrange moving rsp and rbp to new stack and document how. Revert 32 bit wow64 handling to its former self. * miscfunc.cc (create_new_main_thread_stack): Take a commitsize parameter and use it if it's not 0. Don't set _main_tls here, it's done in the caller _dll_crt0 anyway. Return stackbase - 16 bytes, rather than stacklimit (which was very wrong anyway). * miscfuncs.h (create_new_main_thread_stack): Accommodate declaration to aforementioned change. * wincap.h (wincaps::has_3264_stack_broken): Remove element. * wincap.cc: Ditto, throughout. * wow64.cc: Semi-revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520 but keep architecture-agnostic type changes intact. Fix formatting. * wow64.h: Revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r--winsup/cygwin/miscfuncs.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 320a3c2..7964941 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -765,13 +765,13 @@ thread_allocator thr_alloc NO_COPY;
maintained by the thr_alloc class. See the description in the x86_64-only
code in _dll_crt0 to understand why we have to do this. */
PVOID
-create_new_main_thread_stack (PVOID &allocationbase)
+create_new_main_thread_stack (PVOID &allocationbase, SIZE_T parent_commitsize)
{
PIMAGE_DOS_HEADER dosheader;
PIMAGE_NT_HEADERS ntheader;
SIZE_T stacksize;
ULONG guardsize;
- ULONG commitsize;
+ SIZE_T commitsize;
PBYTE stacklimit;
dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
@@ -783,7 +783,10 @@ create_new_main_thread_stack (PVOID &allocationbase)
allocationbase
= thr_alloc.alloc (ntheader->OptionalHeader.SizeOfStackReserve);
guardsize = wincap.def_guard_page_size ();
- commitsize = ntheader->OptionalHeader.SizeOfStackCommit;
+ if (parent_commitsize)
+ commitsize = (SIZE_T) parent_commitsize;
+ else
+ commitsize = ntheader->OptionalHeader.SizeOfStackCommit;
commitsize = roundup2 (commitsize, wincap.page_size ());
if (commitsize > stacksize - guardsize - wincap.page_size ())
commitsize = stacksize - guardsize - wincap.page_size ();
@@ -798,8 +801,7 @@ create_new_main_thread_stack (PVOID &allocationbase)
return NULL;
NtCurrentTeb()->Tib.StackBase = ((PBYTE) allocationbase + stacksize);
NtCurrentTeb()->Tib.StackLimit = stacklimit;
- _main_tls = &_my_tls;
- return stacklimit - 64;
+ return ((PBYTE) allocationbase + stacksize - 16);
}
#endif