+#include "private/gc_priv.h"
+
#if defined(GC_WIN32_THREADS)
-#include "private/gc_priv.h"
#include <windows.h>
#ifdef CYGWIN32
# undef pthread_create
# undef pthread_sigmask
# undef pthread_join
+# undef pthread_detach
# undef dlopen
# define DEBUG_CYGWIN_THREADS 0
ABORT("DuplicateHandle failed");
}
thread_table[i].stack_base = GC_get_stack_base();
- /* Up until this point, GC_psuh_all_stacks considers this thread */
+ /* Up until this point, GC_push_all_stacks considers this thread */
/* invalid. */
if (thread_table[i].stack_base == NULL)
ABORT("Failed to find stack base in GC_new_thread");
/* Must still be in_use, since nobody else can store our thread_id. */
i++) {}
if (i > my_max) {
- WARN("Removing nonexisiting thread %ld\n", (GC_word)thread_id);
+ WARN("Removing nonexistent thread %ld\n", (GC_word)thread_id);
} else {
GC_delete_gc_thread(thread_table+i);
}
# endif
}
+/* Defined in misc.c */
+extern CRITICAL_SECTION GC_write_cs;
+
void GC_stop_world()
{
DWORD thread_id = GetCurrentThreadId();
if (!GC_thr_initialized) ABORT("GC_stop_world() called before GC_thr_init()");
GC_please_stop = TRUE;
+# ifndef CYGWIN32
+ EnterCriticalSection(&GC_write_cs);
+# endif /* !CYGWIN32 */
for (i = 0; i <= GC_get_max_thread_index(); i++)
if (thread_table[i].stack_base != 0
&& thread_table[i].id != thread_id) {
# endif
thread_table[i].suspended = TRUE;
}
+# ifndef CYGWIN32
+ LeaveCriticalSection(&GC_write_cs);
+# endif /* !CYGWIN32 */
}
void GC_start_world()
return result;
}
+GC_PTR GC_get_thread_stack_base()
+{
+ extern GC_PTR _tlsbase __asm__ ("%fs:4");
+ return _tlsbase;
+}
+
#else /* !CYGWIN32 */
/*