Merge branch 'master' into boehm-demers-weiser-gc
[bpt/guile.git] / libguile / gc.c
index 230957b..bb39efd 100644 (file)
@@ -17,7 +17,7 @@
 
 /* #define DEBUGINFO */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
 
@@ -346,6 +346,18 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_gc_dump, "gc-dump", 0, 0, 0,
+           (void),
+           "Dump information about the garbage collector's internal data "
+           "structures and memory usage to the standard output.")
+#define FUNC_NAME s_scm_gc_dump
+{
+  GC_dump ();
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
 
 SCM_DEFINE (scm_object_address, "object-address", 1, 0, 0,
             (SCM obj),
@@ -388,7 +400,6 @@ SCM_DEFINE (scm_gc, "gc", 0, 0, 0,
 #define FUNC_NAME s_scm_gc
 {
   scm_i_scm_pthread_mutex_lock (&scm_i_sweep_mutex);
-  scm_gc_running_p = 1;
   scm_i_gc ("call");
   /* njrev: It looks as though other places, e.g. scm_realloc,
      can call scm_i_gc without acquiring the sweep mutex.  Does this
@@ -397,7 +408,6 @@ SCM_DEFINE (scm_gc, "gc", 0, 0, 0,
      (e.g. scm_permobjs above in scm_gc_stats) by a critical section,
      not by the sweep mutex.  Shouldn't all the GC-relevant objects be
      protected in the same way? */
-  scm_gc_running_p = 0;
   scm_i_pthread_mutex_unlock (&scm_i_sweep_mutex);
   scm_c_hook_run (&scm_after_gc_c_hook, 0);
   return SCM_UNSPECIFIED;
@@ -627,10 +637,12 @@ void
 scm_storage_prehistory ()
 {
   GC_all_interior_pointers = 0;
+  GC_set_free_space_divisor (scm_getenv_int ("GC_FREE_SPACE_DIVISOR", 3));
 
   GC_INIT ();
 
-#ifdef SCM_I_GSC_USE_PTHREAD_THREADS
+#if (! ((defined GC_VERSION_MAJOR) && (GC_VERSION_MAJOR >= 7))) \
+    && (defined SCM_I_GSC_USE_PTHREAD_THREADS)
   /* When using GC 6.8, this call is required to initialize thread-local
      freelists (shouldn't be necessary with GC 7.0).  */
   GC_init ();