summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorivmai <ivmai>2009-11-06 06:54:29 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:51 +0200
commitdabce82fc68eadae5f5de87dacf52eb0509c3361 (patch)
treeaf679f5f5b7435cef5deb72fb18c04b0617e918f /win32_threads.c
parent9ba19e6566ab47ac877a02f51b4443edb9a9b924 (diff)
2009-11-06 Ivan Maidanski <ivmai@mail.ru>
* include/private/gc_priv.h (GC_write_disabled): New variable declaration (only if GC_ASSERTIONS and Win32 threads). * misc.c (GC_write): Add assertion for GC_write_disabled value is not on (only if THREADS). * win32_threads.c (GC_write_disabled): New variable (only if GC_ASSERTIONS and not Cygwin). * win32_threads.c (GC_stop_world): Set and clear GC_write_disabled (while holding GC_write_cs).
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 04601de..393cedb 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -966,6 +966,11 @@ STATIC void GC_suspend(GC_thread t)
# endif
}
+#if defined(GC_ASSERTIONS) && !defined(CYGWIN32)
+ GC_INNER GC_bool GC_write_disabled = FALSE;
+ /* TRUE only if GC_stop_world() acquired GC_write_cs. */
+#endif
+
GC_INNER void GC_stop_world(void)
{
DWORD thread_id = GetCurrentThreadId();
@@ -987,12 +992,16 @@ GC_INNER void GC_stop_world(void)
GC_please_stop = TRUE;
# endif
# ifndef CYGWIN32
+ GC_ASSERT(!GC_write_disabled);
EnterCriticalSection(&GC_write_cs);
/* It's not allowed to call GC_printf() (and friends) here down to */
/* LeaveCriticalSection (same applies recursively to */
/* GC_get_max_thread_index(), GC_suspend(), GC_delete_gc_thread() */
/* (only if GC_win32_dll_threads), GC_size() and */
/* GC_remove_protection()). */
+# ifdef GC_ASSERTIONS
+ GC_write_disabled = TRUE;
+# endif
# endif
# ifndef GC_NO_DLLMAIN
if (GC_win32_dll_threads) {
@@ -1026,6 +1035,9 @@ GC_INNER void GC_stop_world(void)
}
}
# ifndef CYGWIN32
+# ifdef GC_ASSERTIONS
+ GC_write_disabled = FALSE;
+# endif
LeaveCriticalSection(&GC_write_cs);
# endif
# ifdef PARALLEL_MARK