From 93677af52064c84b611fefcbb8ea986c65a0c480 Mon Sep 17 00:00:00 2001
From: Michael Gran <spk121@yahoo.com>
Date: Tue, 29 Mar 2011 21:25:04 -0700
Subject: [PATCH 1/2] check for GC_allow_register_threads

This is not present in earlier versions of BDW-GC

* configure.ac: check for GC_allow_register_threads
* libguile/gen-scmconfig.c (SCM_HAVE_GC_ALLOW_REGISTER_THREADS): new define
* libguile/threads.c (scm_i_init_thread_for_guile): use new define
---
 configure.ac             |    2 +-
 libguile/gen-scmconfig.c |    6 ++++++
 libguile/threads.c       |    2 ++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index e5b8379..4fc2553 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1238,7 +1238,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])
+AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads])
 
 # 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/gen-scmconfig.c b/libguile/gen-scmconfig.c
index 97066b7..386fa4a 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -330,6 +330,12 @@ main (int argc, char *argv[])
   pf ("#define SCM_HAVE_GC_PTHREAD_EXIT 0 /* 0 or 1 */\n");
 #endif
 
+#ifdef HAVE_GC_ALLOW_REGISTER_THREADS
+  pf ("#define SCM_HAVE_GC_ALLOW_REGISTER_THREADS 1 /* 0 or 1 */\n");
+#else
+  pf ("#define SCM_HAVE_GC_ALLOW_REGISTER_THREADS 0 /* 0 or 1 */\n");
+#endif
+
   pf ("\n\n/*** File system access ***/\n");
 
   pf ("/* Define to 1 if `struct dirent64' is available.  */\n");
diff --git a/libguile/threads.c b/libguile/threads.c
index ad5bbe1..764fe1c 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -772,8 +772,10 @@ scm_i_init_thread_for_guile (struct GC_stack_base *base, SCM parent)
 	  */
 	  scm_i_init_guile (base);
 
+#if SCM_HAVE_GC_ALLOW_REGISTER_THREADS
           /* Allow other threads to come in later.  */
           GC_allow_register_threads ();
+#endif
 
 	  scm_i_pthread_mutex_unlock (&scm_i_init_mutex);
 	}
-- 
1.7.4

