OSDN Git Service

2003-04-28 Mohan Embar <gnustuff@thisiscool.com>
[pf3gnuchains/gcc-fork.git] / boehm-gc / win32_threads.c
index 980faf3..954b18d 100644 (file)
@@ -134,9 +134,6 @@ void GC_push_all_stacks()
                                (LPCONTEXT)&thread_table[i].context))
          ABORT("GetThreadContext failed");
 #      ifdef I386
-         if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
-             || thread_table[i].context.Esp < (DWORD)bottom)
-             ABORT("Thread stack pointer out of range");
          GC_push_one ((word) thread_table[i].context.Edi);
          GC_push_one ((word) thread_table[i].context.Esi);
          GC_push_one ((word) thread_table[i].context.Ebp);
@@ -144,8 +141,15 @@ void GC_push_all_stacks()
          GC_push_one ((word) thread_table[i].context.Edx);
          GC_push_one ((word) thread_table[i].context.Ecx);
          GC_push_one ((word) thread_table[i].context.Eax);
-         GC_push_all_stack((char *) thread_table[i].context.Esp,
-                           thread_table[i].stack);
+         if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
+             || thread_table[i].context.Esp < (DWORD)bottom) {
+             WARN("Thread stack pointer 0x%lx out of range, pushing everything",
+                  thread_table[i].context.Esp);
+             GC_push_all_stack((char *) bottom, thread_table[i].stack);
+         } else {
+             GC_push_all_stack((char *) thread_table[i].context.Esp,
+                               thread_table[i].stack);
+         }
 #       else
 #       ifdef ARM32
          if (thread_table[i].context.Sp >= (DWORD)thread_table[i].stack
@@ -447,16 +451,22 @@ static DWORD WINAPI thread_start(LPVOID arg)
     /* Clear the thread entry even if we exit with an exception.       */
     /* This is probably pointless, since an uncaught exception is      */
     /* supposed to result in the process being killed.                 */
+#ifndef __GNUC__
     __try {
+#endif /* __GNUC__ */
        ret = args.start (args.param);
+#ifndef __GNUC__
     } __finally {
+#endif /* __GNUC__ */
        LOCK();
        args.entry->stack = 0;
        args.entry->in_use = FALSE;
              /* cast away volatile qualifier */
        BZERO((void *) &args.entry->context, sizeof(CONTEXT));
        UNLOCK();
+#ifndef __GNUC__
     }
+#endif /* __GNUC__ */
 
     return ret;
 }
@@ -517,6 +527,8 @@ DWORD WINAPI main_thread_start(LPVOID arg)
 
 LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info);
 
+#ifdef GC_DLL
+
 /*
  * This isn't generally safe, since DllMain is not premptible.
  * If another thread holds the lock while this runs we're in trouble.
@@ -625,6 +637,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
   return TRUE;
 }
 
+#   endif /* GC_DLL */
+
 # endif /* !MSWINCE */
 
 #endif /* GC_WIN32_THREADS */