]> granicus.if.org Git - gc/commitdiff
2010-03-12 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Fri, 12 Mar 2010 20:43:11 +0000 (20:43 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:53 +0000 (21:06 +0400)
* 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.

ChangeLog
alloc.c
include/gc_mark.h

index c35fda8508e94f3dd48420ca3f8cd064cb8f75ef..68db4abebc937898240bb7bbfa9abc1ba542c643 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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.
diff --git a/alloc.c b/alloc.c
index eee0ca5a8de7ef446ac211aa04c5e014f1e61d33..78011a46694abf40c4c1432d31a65297c8bc540c 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -303,11 +303,29 @@ GC_INNER GC_bool GC_should_collect(void)
            || 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) {
@@ -407,7 +425,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
             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);
index e3a09a52a6ba7118567b03053a7f2bf859aa2b49..420e47023397e27dca32b18caf220558b3836aa4 100644 (file)
@@ -211,6 +211,13 @@ GC_API void GC_CALL GC_register_describe_type_fn(int /* kind */,
 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