+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).
+
2009-11-05 Ivan Maidanski <ivmai@mail.ru>
* win32_threads.c (GC_please_stop): If DllMain-based thread
* win32_threads.c (GC_stop_world): Add the comment for GC_printf()
usage (while holding GC_write_cs).
* win32_threads.c (GC_delete_gc_thread): Ditto.
- * os_depc.c (GC_remove_protection): Ditto.
+ * os_dep.c (GC_remove_protection): Ditto.
2009-11-05 Ivan Maidanski <ivmai@mail.ru>
#ifdef THREADS
# if defined(MSWIN32) || defined(MSWINCE)
GC_EXTERN CRITICAL_SECTION GC_write_cs; /* defined in misc.c */
+# ifdef GC_ASSERTIONS
+ GC_EXTERN GC_bool GC_write_disabled;
+ /* defined in win32_threads.c; */
+ /* protected by GC_write_cs. */
+
+# endif
# endif
# ifdef MPROTECT_VDB
GC_EXTERN volatile AO_TS_t GC_fault_handler_lock;
# endif
# ifdef MSWINCE
GC_EXTERN GC_bool GC_dont_query_stack_min;
- /* Defined and set in os_dep.c. */
+ /* Defined and set in os_dep.c. */
# endif
#elif defined(IA64)
GC_EXTERN ptr_t GC_save_regs_ret_val; /* defined in mach_dep.c. */
if (len == 0)
return 0;
IF_NEED_TO_LOCK(EnterCriticalSection(&GC_write_cs));
+# ifdef THREADS
+ GC_ASSERT(!GC_write_disabled);
+# endif
if (GC_stdout == INVALID_HANDLE_VALUE) {
IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs));
return -1;
# 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();
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) {
}
}
# ifndef CYGWIN32
+# ifdef GC_ASSERTIONS
+ GC_write_disabled = FALSE;
+# endif
LeaveCriticalSection(&GC_write_cs);
# endif
# ifdef PARALLEL_MARK