This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
[Patch]: Win95
- From: "Pierre A. Humblet" <pierre at phumblet dot no-ip dot org>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 22 Mar 2004 09:36:36 -0500
- Subject: [Patch]: Win95
- Reply-to: Pierre dot Humblet at ieee dot org
This fixes gnuchess on Win95.
There is still a compiler warning, will look at it tonight.
Tested on ME, 95 and NT4.0
Pierre
2004-03-22 Pierre Humblet <pierre.humblet@ieee.org>
* init.cc (munge_threadfunc): Handle all instances of search_for.
(prime_threads): Test threadfunc_ix[0].
Index: init.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/init.cc,v
retrieving revision 1.31
diff -u -p -r1.31 init.cc
--- init.cc 24 Feb 2004 17:13:16 -0000 1.31
+++ init.cc 22 Mar 2004 13:15:56 -0000
@@ -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;
@@ -59,14 +59,15 @@ static void
munge_threadfunc ()
{
char **ebp = (char **) __builtin_frame_address (0);
- if (!threadfunc_ix)
+ int i;
+ if (!threadfunc_ix[0])
{
- for (char **peb = ebp; peb < (char **) _tlsbase; peb++)
+ char **top = (char **) _tlsbase;
+ for (char **peb = ebp, i = 0; peb < top && i < 7; peb++)
if (*peb == search_for)
- {
- threadfunc_ix = peb - ebp;
- goto foundit;
- }
+ threadfunc_ix[i++] = peb - ebp;
+ if (threadfunc_ix[0])
+ 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]);
@@ -76,12 +77,13 @@ munge_threadfunc ()
}
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);
}