+2010-03-12 Ivan Maidanski <ivmai@mail.ru>
+
+ * alloc.c (GC_start_call_back): Replace the definition type to
+ GC_start_callback_proc.
+ * alloc.c (GC_set_start_callback, GC_get_start_callback): New
+ setter/getter function.
+ * alloc.c (GC_try_to_collect_inner): Call GC_notify_full_gc()
+ unconditionally (because GC_try_to_collect_inner always does full
+ GC).
+ * include/gc_mark.h (GC_start_callback_proc): New type.
+ * include/gc_mark.h (GC_set_start_callback,
+ GC_get_start_callback): New API function declaration.
+
2010-03-12 Ivan Maidanski <ivmai@mail.ru>
* doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Document.
|| GC_heapsize >= GC_collect_at_heapsize);
}
-/* STATIC */ void (*GC_start_call_back) (void) = 0;
+/* STATIC */ GC_start_callback_proc GC_start_call_back = 0;
/* Called at start of full collections. */
/* Not called if 0. Called with the allocation */
/* lock held. Not used by GC itself. */
+GC_API void GC_CALL GC_set_start_callback(GC_start_callback_proc fn)
+{
+ DCL_LOCK_STATE;
+ LOCK();
+ GC_start_call_back = fn;
+ UNLOCK();
+}
+
+GC_API GC_start_callback_proc GC_CALL GC_get_start_callback(void)
+{
+ GC_start_callback_proc fn;
+ DCL_LOCK_STATE;
+ LOCK();
+ fn = GC_start_call_back;
+ UNLOCK();
+ return fn;
+}
+
GC_INLINE void GC_notify_full_gc(void)
{
if (GC_start_call_back != 0) {
GC_collect_a_little_inner(1);
}
}
- if (stop_func == GC_never_stop_func) GC_notify_full_gc();
+ GC_notify_full_gc();
# ifndef SMALL_CONFIG
if (GC_print_stats) {
GET_TIME(start_time);
GC_API size_t GC_CALL GC_get_heap_size_inner(void);
GC_API size_t GC_CALL GC_get_free_bytes_inner(void);
+/* Set and get the client notifier on collections. The client function */
+/* is called at the start of every full GC (called with the allocation */
+/* lock held). May be 0. */
+typedef void (GC_CALLBACK * GC_start_callback_proc)(void);
+GC_API void GC_CALL GC_set_start_callback(GC_start_callback_proc);
+GC_API GC_start_callback_proc GC_CALL GC_get_start_callback(void);
+
#ifdef __cplusplus
} /* end of extern "C" */
#endif