diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-05-15 22:49:40 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-05-15 22:49:40 +0400 |
commit | cdb4231369f4c06795e170f9cb003d8de1581f5b (patch) | |
tree | dd008237ecd92aa1101affbc9577809aa49b8dd5 /winsup/cygwin/init.cc | |
parent | 2922c6c4aaa754fee3fcaecddd618ec9dff84cc5 (diff) |
* cygwin.din (pthread_attr_getguardsize): Export.
(pthread_attr_setguardsize): Export.
(pthread_attr_setstack): Export.
(pthread_attr_setstackaddr): Export.
* init.cc (dll_entry): Remove wow64_test_stack_marker. Check for
unusual stack address by testing stack addresses from current TEB.
Check validity of _my_tls by testing if it's within the stack as
given in current TEB.
* miscfuncs.cc (struct thread_wrapper_arg): New structure used to
push all required information to thread_wrapper function.
(thread_wrapper): Wrapper function for actual thread function.
If an application stack has been given, change %ebp and %esp so that
the thread function runs on that stack. If the thread has been created
by CygwinCreateThread, set up the POSIX guard pages if necessary.
(CygwinCreateThread): New function.
* miscfuncs.h (CygwinCreateThread): Declare.
* ntdll.h (struct _TEB): Define all members up to Peb.
* posix.sgml (std-susv4): Move pthread_attr_getguardsize,
pthread_attr_setguardsize and pthread_attr_setstack here.
(std-deprec): Add pthread_attr_setstackaddr.
* sysconf.cc (sca): Set _SC_THREAD_ATTR_STACKADDR to
_POSIX_THREAD_ATTR_STACKADDR.
* thread.cc (pthread::precreate): Copy pthread_attr stackaddr and
guardsize members.
(pthread::create): Call CygwinCreateThread.
(pthread_attr::pthread_attr): Initialize guardsize.
(pthread_attr_setstack): New function.
(pthread_attr_setstackaddr): New function.
(pthread_attr_setguardsize): New function.
(pthread_attr_getguardsize): New function.
(pthread_getattr_np): Copy attr.guardsize.
* thread.h (pthread_attr): Add member guardsize.
* include/pthread.h (pthread_attr_getguardsize): Declare.
(pthread_attr_setguardsize): Declare.
* include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/init.cc')
-rw-r--r-- | winsup/cygwin/init.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index fab71ba27..5404ed15a 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -1,7 +1,7 @@ /* init.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. + 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -115,7 +115,7 @@ extern void __stdcall dll_crt0_0 (); extern "C" BOOL WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load) { - BOOL wow64_test_stack_marker; + PNT_TIB tib; switch (reason) { @@ -131,9 +131,10 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) the auto load address of DLLs? Check if we're running in WOW64 on a 64 bit machine *and* are spawned by a genuine 64 bit process. If so, respawn. */ + tib = &NtCurrentTeb ()->Tib; if (wincap.is_wow64 () - && &wow64_test_stack_marker >= (PBOOL) 0x400000 - && &wow64_test_stack_marker <= (PBOOL) 0x10000000) + && tib->StackLimit >= (PBOOL) 0x400000 + && tib->StackBase <= (PBOOL) 0x10000000) respawn_wow64_process (); dll_crt0_0 (); @@ -149,7 +150,10 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) munge_threadfunc (); break; case DLL_THREAD_DETACH: - if (dll_finished_loading && (void *) &_my_tls > (void *) &wow64_test_stack_marker + tib = &NtCurrentTeb ()->Tib; + if (dll_finished_loading + && (PVOID) &_my_tls >= tib->StackLimit + && (PVOID) &_my_tls < tib->StackBase && _my_tls.isinitialized ()) _my_tls.remove (0); break; |