From d795119cbe7e421ef84df059d5cd26ddc73c31b3 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 19 Jan 2004 23:03:43 +0000 Subject: * sigproc.cc (sigproc_terminate): Don't close sendsig handle when execing since we're not closing what we think we're closing. (sig_send): Improve debugging when exiting due to no_signals_available. * wincap.h (wincaps::cant_debug_dll_entry): New element. * wincap.cc: Implement above element throughout. * dcrt0.cc (initial_env): Accommodate changes necessary to allow initial debugging for systems which do not allow debugging in dll_entry. (dll_crt0_0): Add initial_env call back here. * Makefile.in (install-man): Use mandir as target for installation. * include/cygwin/version.h: Bump DLL minor number to 7 (should have been done earlier). --- winsup/cygwin/init.cc | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'winsup/cygwin/init.cc') diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index a85a8a270..7ad38f11b 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -28,9 +28,6 @@ static void WINAPI threadfunc_fe (VOID *arg) { _threadinfo::call ((DWORD (*) (void *, void *)) (((char **) _tlsbase)[OLDFUNC_OFFSET]), arg); - // void *threadfunc = (void *) TlsGetValue (tls_func); - // TlsFree (tls_func); - // _threadinfo::call ((DWORD (*) (void *, void *)) (threadfunc), arg); } static DWORD WINAPI @@ -39,6 +36,25 @@ calibration_thread (VOID *arg) ExitThread (0); } +/* We need to know where the OS stores the address of the thread function + on the stack so that we can intercept the call and insert some tls + stuff on the stack. This function starts a known calibration thread. + When it starts, a call will be made to dll_entry which will call munge_threadfunc + looking for the calibration thread offset on the stack. This offset will + be stored and used by all executing cygwin processes. */ +void +prime_threads () +{ + if (!threadfunc_ix) + { + DWORD id; + search_for = (char *) calibration_thread; + sync_startup = CreateThread (NULL, 0, calibration_thread, 0, 0, &id); + } +} + +/* If possible, redirect the thread entry point to a cygwin routine which + adds tls stuff to the stack. */ static void munge_threadfunc (HANDLE cygwin_hmodule) { @@ -71,18 +87,6 @@ foundit: } } -void -prime_threads () -{ - // tls_func = TlsAlloc (); - if (!threadfunc_ix) - { - DWORD id; - search_for = (char *) calibration_thread; - sync_startup = CreateThread (NULL, 0, calibration_thread, 0, 0, &id); - } -} - extern void __stdcall dll_crt0_0 (); extern "C" int WINAPI @@ -93,15 +97,12 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) case DLL_PROCESS_ATTACH: prime_threads (); dynamically_loaded = (static_load == NULL); - // __cygwin_user_data.impure_ptr = &_my_tls.local_clib; dll_crt0_0 (); - // small_printf ("%u, %p, %p\n", cygwin_pid (GetCurrentProcessId ()), _tlstop, _tlsbase); break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: munge_threadfunc (h); - // small_printf ("%u, %p, %p\n", cygwin_pid (GetCurrentProcessId ()), _tlstop, _tlsbase); break; case DLL_THREAD_DETACH: _my_tls.remove (0); -- cgit v1.2.3