diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3ead72e5d..7d9a24d31 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,29 @@ +2006-03-12 Christopher Faylor + + * cygtls.h (CYGTLS_INITIALIZED): Change to a little more unlikely value. + (CYGTLSMAGIC): Delete. + * dcrt0.cc (dll_crt0_0): Call sigproc_init during init startup. + (_dll_crt0): Don't worry about sync_startup. Just wait for sigthread here. + * dll_init.cc (cygwin_detach_dll): Only pick up tls version of retaddr + if we have a valid tls. + * fork.cc (frok::child): Remove sigproc_init initialization since it + happens much earlier now. + * gendef: Recognize SIGFE_MAYBE. + (fefunc): Generate calls to _sigfe_maybe, if appropriate. + (_sigfe_maybe): New function. + * init.cc (search_for): Always initialize search_for, even on fork. + (calibration_thread): Delete. + (calibration_id): Delete. + (prime_threads): Delete. + (munge_threadfunc): Remove calibration_thread special case. Avoid + calling thread function if we haven't yet hit the "search_for" thread. + (dll_entry): Remove prime_threads call. Only call munge_threadfunc + when hwait_sig is active. Ditto. for _my_tls.remove (); + * sigproc.cc (hwait_sig): Make global. + (sigproc_init): Don't bother with sync_startup. + (sig_send): Treat flush as a no-op when signals are held. + (wait_sig): Cause signals to be held after fork. + 2006-03-09 Corinna Vinschen * syscalls.cc (rename): Move existance check for oldpath further up diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 5e3155a76..c21201434 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -23,8 +23,7 @@ details. */ typedef unsigned int SOCKET; #endif -#define CYGTLS_INITIALIZED 0x43227 -#define CYGTLSMAGIC "D0Ub313v31nm&G1c?"; +#define CYGTLS_INITIALIZED 0xc763173f #ifndef CYG_MAX_PATH # define CYG_MAX_PATH 260 diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index ae91911cd..9fc71162a 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -301,8 +301,8 @@ cygwin_conv_to_posix_path SIGFE cygwin32_conv_to_posix_path = cygwin_conv_to_posix_path SIGFE cygwin_conv_to_win32_path SIGFE cygwin32_conv_to_win32_path = cygwin_conv_to_win32_path SIGFE -cygwin_detach_dll SIGFE -cygwin32_detach_dll = cygwin_detach_dll SIGFE +cygwin_detach_dll SIGFE_MAYBE +cygwin32_detach_dll = cygwin_detach_dll SIGFE_MAYBE cygwin_dll_init NOSIGFE endprotoent = cygwin_endprotoent SIGFE endservent = cygwin_endservent SIGFE diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 8122939b6..9da090f30 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -750,6 +750,8 @@ dll_crt0_0 () DuplicateTokenEx (hProcToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenImpersonation, &hProcImpToken); + /* Initialize signal/subprocess handling. */ + sigproc_init (); debug_printf ("finished dll_crt0_0 initialization"); } @@ -835,9 +837,6 @@ dll_crt0_1 (char *) /* Initialize user info. */ uinfo_init (); - /* Initialize signal/subprocess handling. */ - sigproc_init (); - /* Connect to tty. */ tty_init (); @@ -924,7 +923,6 @@ dll_crt0_1 (char *) /* Flush signals and ensure that signal thread is up and running. Can't do this for noncygwin case since the signal thread is blocked due to LoadLibrary serialization. */ - wait_for_sigthread (); ld_preload (); if (user_data->main) cygwin_exit (user_data->main (__argc, __argv, *user_data->envptr)); @@ -950,14 +948,8 @@ initialize_main_tls (char *padding) extern "C" void __stdcall _dll_crt0 () { - extern HANDLE sync_startup; extern DWORD threadfunc_ix; - if (sync_startup != INVALID_HANDLE_VALUE) - { - WaitForSingleObject (sync_startup, INFINITE); - CloseHandle (sync_startup); - } - + wait_for_sigthread (); if (!threadfunc_ix) system_printf ("internal error: couldn't determine location of thread function on stack. Expect signal problems."); diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 7d35c1633..7c7fc6407 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -404,7 +404,12 @@ dll_noncygwin_dllcrt0 (HMODULE h, per_process *p) extern "C" void cygwin_detach_dll (dll *) { - dlls.detach ((HANDLE) _my_tls.retaddr ()); + HANDLE retaddr; + if (_my_tls.isinitialized ()) + retaddr = (HANDLE) _my_tls.retaddr (); + else + retaddr = __builtin_return_address (0); + dlls.detach (retaddr); } extern "C" void diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index e4c3c31bb..244bb71db 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -171,8 +171,6 @@ frok::child (void *) ForceCloseHandle1 (fork_info->forker_finished, forker_finished); - sigproc_init (); - pthread::atforkchild (); fixup_timers_after_fork (); cygbench ("fork-child"); diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef index c6b6a7909..40796f094 100755 --- a/winsup/cygwin/gendef +++ b/winsup/cygwin/gendef @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2003, 2004, 2005 Red Hat, Inc. +# Copyright 2003, 2004, 2005, 2006 Red Hat, Inc. # # This file is part of Cygwin. # @@ -43,12 +43,14 @@ for (@in) { chomp; if (/=/o) { if (s/\s+NOSIGFE\s*$//) { - } elsif (s/ SIGFE$//) { - my $func = (split(' '))[2]; - $sigfe{$func} = '_sigfe_' . $func; + # nothing + } elsif (s/ SIGFE(_MAYBE)?$//) { + my $func = (split(' '))[2]; + my $maybe = lc $1 . '_'; + $sigfe{$func} = '_sigfe' . $maybe . $func; } } else { - my ($func, $sigfe) = m%^\s*(\S+)(?:\s+((?:NO)?SIGR?FE))?$%o; + my ($func, $sigfe) = m%^\s*(\S+)(?:\s+((?:NO)?SIGFE(?:_MAYBE)?))?$%o; if (defined($sigfe) && $sigfe =~ /^NO/o) { $_ = $func; } else { @@ -83,13 +85,14 @@ close SIGFE; sub fefunc { my $func = '_' . shift; my $fe = '_' . shift; + my $sigfe_func = ($fe =~ /^(.*)$func/)[0]; my $extra; my $res = <zap_h (); @@ -523,6 +521,8 @@ sig_send (_pinfo *p, int sig) #endif return -1; } + else if (sig == __SIGFLUSH || sig == __SIGFLUSHFAST) + return 0; else { SetEvent (sigCONT); @@ -1091,8 +1091,12 @@ wait_sig (VOID *) readsig, myself->sendsig); sigpacket pack; + if (in_forkee) + pack.si.si_signo = __SIGHOLD; for (;;) { + if (pack.si.si_signo == __SIGHOLD) + WaitForSingleObject (sigCONT, INFINITE); DWORD nb; pack.tls = NULL; if (!ReadFile (readsig, &pack, sizeof (pack), &nb, NULL)) @@ -1194,8 +1198,6 @@ wait_sig (VOID *) sigproc_printf ("signalling pack.wakeup %p", pack.wakeup); SetEvent (pack.wakeup); } - if (pack.si.si_signo == __SIGHOLD) - WaitForSingleObject (sigCONT, INFINITE); if (pack.si.si_signo == __SIGEXIT) break; }