2009-10-08 Ivan Maidanski <ivmai@mail.ru>
+ * alloc.c (GC_default_stop_func, GC_try_to_collect_general,
+ GC_gcollect): Add the comment.
+ * alloc.c (GC_try_to_collect_general): Move the assertion on
+ stop_func != 0 to GC_try_to_collect().
+ * alloc.c (GC_try_to_collect_general): If stop_func == 0 then use
+ GC_default_stop_func instead (holding the lock).
+ * alloc.c (GC_gcollect): Pass 0 as stop_func instead of
+ GC_default_stop_func (to prevent data races).
+
+2009-10-08 Ivan Maidanski <ivmai@mail.ru>
+
* Makefile.direct: Move "define arguments" documentation to
doc/README.macros; add reference to doc/README.macros.
* Makefile.dj: Change the documentation reference to
/* collection within GC_time_limit. */
STATIC GC_stop_func GC_default_stop_func = GC_never_stop_func;
+ /* accessed holding the lock. */
GC_API void GC_CALL GC_set_stop_func(GC_stop_func stop_func)
{
extern GC_bool GC_force_unmap_on_gcollect; /* defined in misc.c */
#endif
+/* If stop_func == 0 then GC_default_stop_func is used instead. */
STATIC GC_bool GC_try_to_collect_general(GC_stop_func stop_func,
GC_bool force_unmap)
{
DCL_LOCK_STATE;
if (!GC_is_initialized) GC_init();
- GC_ASSERT(stop_func != 0);
if (GC_debugging_started) GC_print_all_smashed();
GC_INVOKE_FINALIZERS();
LOCK();
ENTER_GC();
/* Minimize junk left in my registers */
GC_noop(0,0,0,0,0,0);
- result = GC_try_to_collect_inner(stop_func);
+ result = GC_try_to_collect_inner(stop_func != 0 ? stop_func :
+ GC_default_stop_func);
EXIT_GC();
# ifdef USE_MUNMAP
GC_unmap_threshold = old_unmap_threshold; /* restore */
/* Externally callable routines to invoke full, stop-the-world collection. */
GC_API int GC_CALL GC_try_to_collect(GC_stop_func stop_func)
{
+ GC_ASSERT(stop_func != 0);
return (int)GC_try_to_collect_general(stop_func, FALSE);
}
GC_API void GC_CALL GC_gcollect(void)
{
- (void)GC_try_to_collect_general(GC_default_stop_func, FALSE);
+ /* 0 is passed as stop_func to get GC_default_stop_func value */
+ /* while holding the allocation lock (to prevent data races). */
+ (void)GC_try_to_collect_general(0, FALSE);
if (GC_have_errors) GC_print_all_errors();
}