diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-12-21 09:38:25 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-12-21 09:38:25 +0000 |
commit | 1b71ce005c0c57d94d74d8eb5b889d0676112f5d (patch) | |
tree | a1a2e75841061de20ec67d5c0e39c4ab7b5a34ac /winsup | |
parent | 57a2873a5daa68a1ae3d4f4c3750d67d5223082e (diff) | |
download | newlib-1b71ce005c0c57d94d74d8eb5b889d0676112f5d.zip newlib-1b71ce005c0c57d94d74d8eb5b889d0676112f5d.tar.gz newlib-1b71ce005c0c57d94d74d8eb5b889d0676112f5d.tar.bz2 |
Throughout, revert ill-conceived replacement of hMainThread with
GetCurrentThread/NtCurrentThread.
* dcrt0.cc (dll_crt0_0): Duplicate main thread handle to hMainThread
again.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/globals.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 2 |
5 files changed, 17 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6889978..93c87ce 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2009-12-21 Corinna Vinschen <corinna@vinschen.de> + + Throughout, revert ill-conceived replacement of hMainThread with + GetCurrentThread/NtCurrentThread. + * dcrt0.cc (dll_crt0_0): Duplicate main thread handle to hMainThread + again. + 2009-12-19 Corinna Vinschen <corinna@vinschen.de> * fhandler_console.cc (__vt100_conv): Minor formatting change. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 021703e..dfdc7d0 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -695,6 +695,10 @@ dll_crt0_0 () user_data->impure_ptr = _impure_ptr; user_data->impure_ptr_ptr = &_impure_ptr; + DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), + GetCurrentProcess (), &hMainThread, + 0, false, DUPLICATE_SAME_ACCESS); + OpenProcessToken (GetCurrentProcess (), MAXIMUM_ALLOWED, &hProcToken); set_cygwin_privileges (hProcToken); @@ -781,6 +785,8 @@ dll_crt0_1 (void *) small_printf ("cmalloc returns %p\n", cmalloc (HEAP_STR, n)); #endif + ProtectHandle (hMainThread); + cygheap->cwd.init (); /* Initialize pthread mainthread when not forked and it is safe to call new, diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 2e5a83b..e1bb705 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -484,7 +484,7 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT if (debugging && ++debugging < 500000) { - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL); + SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL); return 0; } @@ -1307,7 +1307,7 @@ exit_sig: { CONTEXT c; c.ContextFlags = CONTEXT_FULL; - GetThreadContext (GetCurrentThread (), &c); + GetThreadContext (hMainThread, &c); use_tls->copy_context (&c); si.si_signo |= 0x80; } diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index 04d7564..9554ac8 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -18,6 +18,7 @@ details. */ #include <malloc.h> #include <cygwin/version.h> +HANDLE NO_COPY hMainThread; HANDLE NO_COPY hProcToken; HANDLE NO_COPY hProcImpToken; HMODULE NO_COPY cygwin_hmodule; diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 8602761..29b8159 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -253,7 +253,7 @@ low_priority_sleep (DWORD secs) if (GetCurrentThreadId () == cygthread::main_thread_id) new_prio = THREAD_PRIORITY_LOWEST; else - new_prio = GetThreadPriority (GetCurrentThread ()); + new_prio = GetThreadPriority (hMainThread); if (curr_prio != new_prio) /* Force any threads in normal priority to be scheduled */ |