Merge pull request #550 from knocte/master
[mono.git] / mono / metadata / sgen-os-win32.c
index 355ab6ef033e43426307e21184f9fb4cd2f3358a..a476c73d3b047c77733a1b84020b5ba523247b08 100644 (file)
@@ -2,13 +2,13 @@
 
 #if defined(HAVE_SGEN_GC) && defined(HOST_WIN32)
 
-#include <windows.h>
+#include "io-layer/io-layer.h"
 
 #include "metadata/sgen-gc.h"
 #include "metadata/gc-internal.h"
 
 gboolean
-mono_sgen_resume_thread (SgenThreadInfo *info)
+sgen_resume_thread (SgenThreadInfo *info)
 {
        DWORD id = mono_thread_info_get_tid (info);
        HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
@@ -25,7 +25,7 @@ mono_sgen_resume_thread (SgenThreadInfo *info)
 }
 
 gboolean
-mono_sgen_suspend_thread (SgenThreadInfo *info)
+sgen_suspend_thread (SgenThreadInfo *info)
 {
        DWORD id = mono_thread_info_get_tid (info);
        HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
@@ -68,29 +68,31 @@ mono_sgen_suspend_thread (SgenThreadInfo *info)
        info->regs [5] = context.Eax;
        info->regs [6] = context.Ebp;
        info->regs [7] = context.Esp;
-       info->stopped_regs = &info->regs;
 
        /* Notify the JIT */
        if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
-               mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, NULL);
+               mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, NULL, NULL);
 
        return TRUE;
 }
 
 void
-mono_sgen_wait_for_suspend_ack (int count)
+sgen_wait_for_suspend_ack (int count)
 {
        /* Win32 suspend/resume is synchronous, so we don't need to wait for anything */
 }
 
 int
-mono_sgen_thread_handshake (BOOL suspend)
+sgen_thread_handshake (BOOL suspend)
 {
        SgenThreadInfo *info;
        SgenThreadInfo *current = mono_thread_info_current ();
        int count = 0;
 
        FOREACH_THREAD_SAFE (info) {
+               if (info->joined_stw == suspend)
+                       continue;
+               info->joined_stw = suspend;
                if (info == current)
                        continue;
                if (info->gc_disabled)
@@ -99,23 +101,22 @@ mono_sgen_thread_handshake (BOOL suspend)
                        g_assert (!info->doing_handshake);
                        info->doing_handshake = TRUE;
 
-                       if (!mono_sgen_suspend_thread (info))
+                       if (!sgen_suspend_thread (info))
                                continue;
                } else {
                        g_assert (info->doing_handshake);
                        info->doing_handshake = FALSE;
 
-                       if (!mono_sgen_resume_thread (info))
+                       if (!sgen_resume_thread (info))
                                continue;
                }
-
                ++count;
        } END_FOREACH_THREAD_SAFE
        return count;
 }
 
 void
-mono_sgen_os_init (void)
+sgen_os_init (void)
 {
 }