From 6b89a541db56d6f5bb6ff7746ce36d1fded2ed3a Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 22 Mar 2004 18:30:38 +0000 Subject: [PATCH] Christopher Faylor * init.cc (munge_threadfunc): Handle all instances of search_for. (prime_threads): Test threadfunc_ix[0]. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/init.cc | 34 ++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8c53e4885..4bd05f9ed 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2004-03-19 Pierre Humblet + Christopher Faylor + + * init.cc (munge_threadfunc): Handle all instances of search_for. + (prime_threads): Test threadfunc_ix[0]. + 2004-03-21 Christopher Faylor * cygheap.cc (init_cheap): Set initial_sz to something or suffer diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 58556d80b..af8c0ea39 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -17,7 +17,7 @@ details. */ int NO_COPY dynamically_loaded; static char *search_for = (char *) cygthread::stub; -unsigned threadfunc_ix __attribute__((section ("cygwin_dll_common"), shared)) = 0; +unsigned threadfunc_ix[8] __attribute__((section ("cygwin_dll_common"), shared)); DWORD tls_func; HANDLE sync_startup; @@ -45,7 +45,7 @@ calibration_thread (VOID *arg) void prime_threads () { - if (!threadfunc_ix) + if (!threadfunc_ix[0]) { DWORD id; search_for = (char *) calibration_thread; @@ -58,32 +58,30 @@ prime_threads () static void munge_threadfunc () { + int i; char **ebp = (char **) __builtin_frame_address (0); - if (!threadfunc_ix) + if (!threadfunc_ix[0]) { - for (char **peb = ebp; peb < (char **) _tlsbase; peb++) + char **peb; + char **top = (char **) _tlsbase; + for (peb = ebp, i = 0; peb < top && i < 7; peb++) if (*peb == search_for) - { - threadfunc_ix = peb - ebp; - goto foundit; - } -#ifdef DEBUGGING_HARD - system_printf ("non-fatal warning: unknown thread! search_for %p, cygthread::stub %p, calibration_thread %p, possible func offset %p", - search_for, cygthread::stub, calibration_thread, ebp[137]); -#endif - try_to_debug (); - return; + threadfunc_ix[i++] = peb - ebp; + if (!threadfunc_ix[0]) + { + try_to_debug (); + return; + } } -foundit: - char *threadfunc = ebp[threadfunc_ix]; + char *threadfunc = ebp[threadfunc_ix[0]]; if (threadfunc == (char *) calibration_thread) /* no need for the overhead */; else { - ebp[threadfunc_ix] = (char *) threadfunc_fe; + for (i = 0; threadfunc_ix[i]; i++) + ebp[threadfunc_ix[i]] = (char *) threadfunc_fe; ((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc; - // TlsSetValue (tls_func, (void *) threadfunc); } }