(fix of commit
bb91f03)
Issue #173 (bdwgc).
Also, update GC_world_stopped value in GC_stop_world_external and
GC_start_world_external.
* include/gc.h (GC_stop_world_external, GC_start_world_external): Do not
declare unless GC_THREADS; add comment.
* misc.c (GC_stop_world_external, GC_start_world_external): Do not
define unless THREADS; add assertion that GC is initialized.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_stop_world_external): Set
GC_world_stopped to true after STOP_WORLD; add assertion that the
world is not stopped.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_start_world_external): Set
GC_world_stopped to false before START_WORLD; add assertion that the
world is stopped.
* tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for
GC_stop_world_external and GC_start_world_external.
/* be called inside a GC callback function (except for */
/* GC_call_with_stack_base() one). */
GC_API int GC_CALL GC_unregister_my_thread(void);
+
+ /* Stop/start the world explicitly. Not recommended for general use. */
+ GC_API void GC_CALL GC_stop_world_external(void);
+ GC_API void GC_CALL GC_start_world_external(void);
#endif /* GC_THREADS */
/* Wrapper for functions that are likely to block (or, at least, do not */
(*GC_amiga_allocwrapper_do)(a,GC_malloc_atomic_ignore_off_page)
#endif /* _AMIGA && !GC_AMIGA_MAKINGLIB */
-GC_API void GC_CALL GC_stop_world_external(void);
-GC_API void GC_CALL GC_start_world_external(void);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
EXIT();
}
-GC_API void GC_CALL GC_stop_world_external(void)
-{
+#ifdef THREADS
+ GC_API void GC_CALL GC_stop_world_external(void)
+ {
+ GC_ASSERT(GC_is_initialized);
LOCK();
+# ifdef THREAD_LOCAL_ALLOC
+ GC_ASSERT(!GC_world_stopped);
+# endif
STOP_WORLD();
-}
+# ifdef THREAD_LOCAL_ALLOC
+ GC_world_stopped = TRUE;
+# endif
+ }
-GC_API void GC_CALL GC_start_world_external(void)
-{
+ GC_API void GC_CALL GC_start_world_external(void)
+ {
+# ifdef THREAD_LOCAL_ALLOC
+ GC_ASSERT(GC_world_stopped);
+ GC_world_stopped = FALSE;
+# else
+ GC_ASSERT(GC_is_initialized);
+# endif
START_WORLD();
UNLOCK();
-}
+ }
+#endif /* THREADS */
UNTESTED(GC_set_on_thread_event);
UNTESTED(GC_set_suspend_signal);
UNTESTED(GC_set_thr_restart_signal);
+ UNTESTED(GC_stop_world_external);
+ UNTESTED(GC_start_world_external);
# ifndef GC_NO_DLOPEN
UNTESTED(GC_dlopen);
# endif