From: ivmai Date: Thu, 5 Nov 2009 17:19:06 +0000 (+0000) Subject: 2009-11-05 Ivan Maidanski X-Git-Tag: gc7_2alpha4~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ba19e6566ab47ac877a02f51b4443edb9a9b924;p=gc 2009-11-05 Ivan Maidanski * win32_threads.c (GC_please_stop): If DllMain-based thread registration is not compiled in then define GC_please_stop as a non-volatile variable for assertion only. * win32_threads.c (GC_stop_world): Set and clear only if defined. * 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. --- diff --git a/ChangeLog b/ChangeLog index 62606494..8b64fe99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-11-05 Ivan Maidanski + + * win32_threads.c (GC_please_stop): If DllMain-based thread + registration is not compiled in then define GC_please_stop as + a non-volatile variable for assertion only. + * win32_threads.c (GC_stop_world): Set and clear only if defined. + * 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. + 2009-11-05 Ivan Maidanski * pthread_support.c (GC_inner_start_routine): Join 3 sequential diff --git a/os_dep.c b/os_dep.c index 01352cb3..1e651247 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3029,6 +3029,8 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, * shortly. Ensure that all pages containing any part of the n hblks * starting at h are no longer protected. If is_ptrfree is false, * also ensure that they will subsequently appear to be dirty. + * Not allowed to call GC_printf (and the friends) here, see Win32 + * GC_stop_world() for the information. */ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree) diff --git a/win32_threads.c b/win32_threads.c index a71d11b5..04601dec 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -249,12 +249,13 @@ struct GC_Thread_Rep { typedef struct GC_Thread_Rep * GC_thread; typedef volatile struct GC_Thread_Rep * GC_vthread; -/* - * We assumed that volatile ==> memory ordering, at least among - * volatiles. This code should consistently use atomic_ops. - */ - -STATIC volatile GC_bool GC_please_stop = FALSE; +#ifndef GC_NO_DLLMAIN + /* We assumed that volatile ==> memory ordering, at least among */ + /* volatiles. This code should consistently use atomic_ops. */ + STATIC volatile GC_bool GC_please_stop = FALSE; +#elif defined(GC_ASSERTIONS) + STATIC GC_bool GC_please_stop = FALSE; +#endif /* * We track thread attachments while the world is supposed to be stopped. @@ -492,8 +493,7 @@ STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb, GC_INLINE LONG GC_get_max_thread_index(void) { LONG my_max = GC_max_thread_index; - - if (my_max >= MAX_THREADS) return MAX_THREADS-1; + if (my_max >= MAX_THREADS) return MAX_THREADS - 1; return my_max; } @@ -614,6 +614,8 @@ STATIC void GC_delete_gc_thread(GC_vthread gc_id) /* It is either called synchronously from the thread being */ /* deleted, or by the joining thread. */ /* In this branch asynchronous changes to *gc_id are possible. */ + /* It's not allowed to call GC_printf (and the friends) here, */ + /* see GC_stop_world() for the information. */ gc_id -> stack_base = 0; gc_id -> id = 0; # ifdef CYGWIN32 @@ -981,9 +983,16 @@ GC_INNER void GC_stop_world(void) } # endif /* PARALLEL_MARK */ - GC_please_stop = TRUE; +# if !defined(GC_NO_DLLMAIN) || defined(GC_ASSERTIONS) + GC_please_stop = TRUE; +# endif # ifndef CYGWIN32 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()). */ # endif # ifndef GC_NO_DLLMAIN if (GC_win32_dll_threads) { @@ -1058,7 +1067,9 @@ GC_INNER void GC_start_world(void) } } } - GC_please_stop = FALSE; +# if !defined(GC_NO_DLLMAIN) || defined(GC_ASSERTIONS) + GC_please_stop = FALSE; +# endif } #ifdef MSWINCE