Merge branch 'master' into boehm-demers-weiser-gc
[bpt/guile.git] / libguile / init.c
index 219ef62..2d5c943 100644 (file)
@@ -20,7 +20,7 @@
 /* Include the headers for just about everything.
    We call all their initialization functions.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
 
 #include "libguile/deprecated.h"
 
 #include "libguile/init.h"
+#include "libguile/private-options.h"
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -394,6 +395,14 @@ really_cleanup_for_exit (void *unused)
 static void
 cleanup_for_exit ()
 {
+  if (scm_i_pthread_mutex_trylock (&scm_i_init_mutex) == 0)
+    scm_i_pthread_mutex_unlock (&scm_i_init_mutex);
+  else
+    {
+      fprintf (stderr, "Cannot exit gracefully when init is in progress; aborting.\n");
+      abort ();
+    }
+
   /* This function might be called in non-guile mode, so we need to
      enter it temporarily. 
   */
@@ -424,7 +433,9 @@ scm_i_init_guile (SCM_STACKITEM *base)
   scm_ports_prehistory ();
   scm_smob_prehistory ();
   scm_fluids_prehistory ();
-  scm_hashtab_prehistory ();   /* requires storage_prehistory */
+  scm_weaks_prehistory ();
+  scm_hashtab_prehistory ();   /* requires storage_prehistory, and
+                                  weaks_prehistory */
 #ifdef GUILE_DEBUG_MALLOC
   scm_debug_malloc_prehistory ();
 #endif
@@ -471,6 +482,7 @@ scm_i_init_guile (SCM_STACKITEM *base)
   scm_init_backtrace ();       /* Requires fluids */
   scm_init_fports ();
   scm_init_strports ();
+  scm_init_ports ();
   scm_init_gdbint ();           /* Requires strports */
   scm_init_hash ();
   scm_init_hashtab ();
@@ -489,7 +501,6 @@ scm_i_init_guile (SCM_STACKITEM *base)
   scm_init_numbers ();
   scm_init_options ();
   scm_init_pairs ();
-  scm_init_ports ();
 #ifdef HAVE_POSIX
   scm_init_filesys ();
   scm_init_posix ();