aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/dcrt0.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2010-09-19 20:18:36 +0000
committerChristopher Faylor <me@cgf.cx>2010-09-19 20:18:36 +0000
commitb64733135ad678a80e14a64a54af0b8538fb8fcf (patch)
treed5a5d3879ea683eebae366e8a002614f820c304d /winsup/cygwin/dcrt0.cc
parent392397f46cab7f09e9e3b6214cacbd2d8354d620 (diff)
downloadnewlib-b64733135ad678a80e14a64a54af0b8538fb8fcf.zip
newlib-b64733135ad678a80e14a64a54af0b8538fb8fcf.tar.gz
newlib-b64733135ad678a80e14a64a54af0b8538fb8fcf.tar.bz2
* wincap.h (wincaps::has_buggy_thread_startup): Declare.
(wincapc::has_buggy_thread_startup): Ditto. * wincap.cc::wincap_*): Accommodate has_buggy_thread_startup. (wincapc::init): Explicitly turn off has_buggy_thread_startup if not WOW64. * cygthread.h (cygthread::thread_handle): Declare/define new method. * dcrt0.cc (_dll_crt0): Don't call __sinit here. (dll_crt0_0): Don't call sigproc_init during initialization if wincap.has_buggy_thread_startup(). (dll_crt0_1): Defer sigproc_init to here when wincap.has_buggy_thread_startup(). Call __sinit after we've determined that we're not forking. (__main): Rework comments. Add potential future reminder.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index b539e4b..2d848ec 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -774,7 +774,7 @@ dll_crt0_0 ()
/* Initialize signal processing here, early, in the hopes that the creation
of a thread early in the process will cause more predictability in memory
layout for the main thread. */
- if (!dynamically_loaded)
+ if (!wincap.has_buggy_thread_startup () && !dynamically_loaded)
sigproc_init ();
debug_printf ("finished dll_crt0_0 initialization");
@@ -789,7 +789,7 @@ dll_crt0_1 (void *)
{
extern void initial_setlocale ();
- if (dynamically_loaded)
+ if (wincap.has_buggy_thread_startup () || dynamically_loaded)
sigproc_init ();
check_sanity_and_sync (user_data);
@@ -853,6 +853,8 @@ dll_crt0_1 (void *)
longjmp (fork_info->jmp, true);
}
+ __sinit (_impure_ptr);
+
#ifdef DEBUGGING
{
extern void fork_init ();
@@ -968,16 +970,9 @@ _dll_crt0 ()
{
main_environ = user_data->envptr;
if (in_forkee)
- {
- fork_info->alloc_stack ();
- _main_tls = &_my_tls;
- }
- else
- {
- _main_tls = &_my_tls;
- __sinit (_impure_ptr);
- }
+ fork_info->alloc_stack ();
+ _main_tls = &_my_tls;
_main_tls->call ((DWORD (*) (void *, void *)) dll_crt0_1, NULL);
}
@@ -1023,12 +1018,16 @@ __main (void)
queued call to DLL dtors now. */
atexit (dll_global_dtors);
do_global_ctors (user_data->ctors, false);
- /* Now we have run global ctors, register their dtors. */
- atexit (do_global_dtors);
- /* At exit, global dtors will run first, so the app can still
+ /* Now we have run global ctors, register their dtors.
+
+ At exit, global dtors will run first, so the app can still
use shared library functions while terminating; then the
DLLs will be destroyed; finally newlib will shut down stdio
and terminate itself. */
+ atexit (do_global_dtors);
+#if 0 /* Don't enable for now. See if we really need this. */
+ sig_dispatch_pending (true);
+#endif
}
void __stdcall