2009-11-06 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Fri, 6 Nov 2009 05:54:29 +0000 (05:54 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:51 +0000 (21:06 +0400)
* 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).

ChangeLog
include/private/gc_priv.h
misc.c
win32_threads.c

index 8b64fe9..dcc0f05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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
@@ -7,7 +18,7 @@
        * 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>
 
index 49041a9..000661f 100644 (file)
@@ -2011,6 +2011,12 @@ GC_EXTERN signed_word GC_bytes_found;
 #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;
@@ -2018,7 +2024,7 @@ GC_EXTERN signed_word GC_bytes_found;
 # 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. */
diff --git a/misc.c b/misc.c
index f7a10a6..4254096 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -978,6 +978,9 @@ out:
       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;
index 04601de..393cedb 100644 (file)
@@ -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