diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | libguile/gc.c | 26 |
2 files changed, 21 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index 710cc2f3f..3a56cda1c 100644 --- a/configure.ac +++ b/configure.ac @@ -1259,7 +1259,7 @@ save_LIBS="$LIBS" LIBS="$BDW_GC_LIBS $LIBS" CFLAGS="$BDW_GC_CFLAGS $CFLAGS" -AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask GC_set_start_callback]) +AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask GC_set_start_callback GC_get_heap_usage_safe]) # Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not # declared, and has a different type (returning void instead of diff --git a/libguile/gc.c b/libguile/gc.c index 23cc8a383..4895b7dfe 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -193,6 +193,22 @@ SCM_DEFINE (scm_set_debug_cell_accesses_x, "set-debug-cell-accesses!", 1, 0, 0, #endif /* SCM_DEBUG_CELL_ACCESSES == 1 */ + +#ifndef HAVE_GC_GET_HEAP_USAGE_SAFE +static void +GC_get_heap_usage_safe (GC_word *pheap_size, GC_word *pfree_bytes, + GC_word *punmapped_bytes, GC_word *pbytes_since_gc, + GC_word *ptotal_bytes) +{ + *pheap_size = GC_get_heap_size (); + *pfree_bytes = GC_get_free_bytes (); + *punmapped_bytes = GC_get_unmapped_bytes (); + *pbytes_since_gc = GC_get_bytes_since_gc (); + *ptotal_bytes = GC_get_total_bytes (); +} +#endif + + /* Hooks. */ scm_t_c_hook scm_before_gc_c_hook; scm_t_c_hook scm_before_mark_c_hook; @@ -275,14 +291,12 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0, #define FUNC_NAME s_scm_gc_stats { SCM answer; - size_t heap_size, free_bytes, bytes_since_gc, total_bytes; + GC_word heap_size, free_bytes, unmapped_bytes, bytes_since_gc, total_bytes; size_t gc_times; - heap_size = GC_get_heap_size (); - free_bytes = GC_get_free_bytes (); - bytes_since_gc = GC_get_bytes_since_gc (); - total_bytes = GC_get_total_bytes (); - gc_times = GC_gc_no; + GC_get_heap_usage_safe (&heap_size, &free_bytes, &unmapped_bytes, + &bytes_since_gc, &total_bytes); + gc_times = GC_gc_no; answer = scm_list_n (scm_cons (sym_gc_time_taken, scm_from_long (gc_time_taken)), |