summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2012-03-08 13:22:09 +0100
committerAndy Wingo <wingo@pobox.com>2012-03-08 13:22:09 +0100
commitbc612809929b85fdcb39bc17a15a53c88b43a8bd (patch)
tree14444f0fb0f69cf9db6b7bf1493c780488c47093 /libguile
parentc336514976ed3f2b2b20c56149ede7f5ec549c52 (diff)
parentf740445a9b5bf0a5e5090f0a2ddaffb2b803bab7 (diff)
downloadguile-bc612809929b85fdcb39bc17a15a53c88b43a8bd.tar.gz
Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts: configure.ac libguile/finalizers.c libguile/finalizers.h libguile/gc.c libguile/gc.h libguile/inline.c libguile/inline.h libguile/ports.c libguile/smob.c libguile/smob.h module/ice-9/deprecated.scm module/ice-9/r4rs.scm
Diffstat (limited to 'libguile')
-rw-r--r--libguile/finalizers.c23
-rw-r--r--libguile/gc.c2
-rw-r--r--libguile/init.c4
-rw-r--r--libguile/strings.c2
-rw-r--r--libguile/threads.c3
-rw-r--r--libguile/vports.c18
6 files changed, 30 insertions, 22 deletions
diff --git a/libguile/finalizers.c b/libguile/finalizers.c
index 07d8f0748..25aadf431 100644
--- a/libguile/finalizers.c
+++ b/libguile/finalizers.c
@@ -43,6 +43,17 @@ static size_t finalization_count;
+#ifndef HAVE_GC_SET_FINALIZER_NOTIFIER
+static void
+GC_set_finalizer_notifier (void (*notifier) (void))
+{
+ GC_finalizer_notifier = notifier;
+}
+#endif
+
+
+
+
void
scm_i_set_finalizer (void *obj, scm_t_finalizer_proc proc, void *data)
{
@@ -142,10 +153,9 @@ run_finalizers_async_thunk (void)
}
-/* The function queue_after_gc_hook is run by the scm_before_gc_c_hook
- * at the end of the garbage collection. The only purpose of this
- * function is to mark the after_gc_async (which will eventually lead to
- * the execution of the after_gc_async_thunk).
+/* The function queue_finalizer_async is run by the GC when there are
+ * objects to finalize. It will enqueue an asynchronous call to
+ * GC_invoke_finalizers() at the next SCM_TICK in this thread.
*/
static void
queue_finalizer_async (void)
@@ -154,7 +164,10 @@ queue_finalizer_async (void)
static scm_i_pthread_mutex_t lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
scm_i_pthread_mutex_lock (&lock);
- if (scm_is_false (SCM_CDR (finalizer_async_cell)))
+ /* If t is NULL, that could be because we're allocating in
+ threads.c:guilify_self_1. In that case, rely on the
+ GC_invoke_finalizers call there after the thread spins up. */
+ if (t && scm_is_false (SCM_CDR (finalizer_async_cell)))
{
SCM_SETCDR (finalizer_async_cell, t->active_asyncs);
t->active_asyncs = finalizer_async_cell;
diff --git a/libguile/gc.c b/libguile/gc.c
index b33fb0ca1..df93d32e5 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -384,6 +384,8 @@ SCM_DEFINE (scm_gc, "gc", 0, 0, 0,
#define FUNC_NAME s_scm_gc
{
scm_i_gc ("call");
+ /* If you're calling scm_gc(), you probably want synchronous
+ finalization. */
GC_invoke_finalizers ();
return SCM_UNSPECIFIED;
}
diff --git a/libguile/init.c b/libguile/init.c
index 90b01eedb..684f6eb02 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -444,7 +444,8 @@ scm_i_init_guile (void *base)
scm_init_ioext ();
scm_init_keywords (); /* Requires smob_prehistory */
scm_init_list ();
- scm_init_macros (); /* Requires smob_prehistory */
+ scm_init_random (); /* Requires smob_prehistory */
+ scm_init_macros (); /* Requires smob_prehistory and random */
scm_init_mallocs (); /* Requires smob_prehistory */
scm_init_modules (); /* Requires smob_prehistory */
scm_init_numbers ();
@@ -502,7 +503,6 @@ scm_i_init_guile (void *base)
scm_init_eval_in_scheme ();
scm_init_evalext ();
scm_init_debug (); /* Requires macro smobs */
- scm_init_random (); /* Requires smob_prehistory */
scm_init_simpos ();
#if HAVE_MODULES
scm_init_dynamic_linking (); /* Requires smob_prehistory */
diff --git a/libguile/strings.c b/libguile/strings.c
index 961705782..c84c8301a 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -748,7 +748,7 @@ scm_i_make_symbol (SCM name, scm_t_bits flags,
name = SH_STRING_STRING (name);
start += STRING_START (name);
}
- buf = SYMBOL_STRINGBUF (name);
+ buf = STRING_STRINGBUF (name);
if (start == 0 && length == STRINGBUF_LENGTH (buf))
{
diff --git a/libguile/threads.c b/libguile/threads.c
index f9104f9e3..8e72eafdf 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -625,6 +625,9 @@ guilify_self_2 (SCM parent)
t->join_queue = make_queue ();
t->block_asyncs = 0;
+
+ /* See note in finalizers.c:queue_finalizer_async(). */
+ GC_invoke_finalizers ();
}
diff --git a/libguile/vports.c b/libguile/vports.c
index 62f552ad7..4ff13f2e8 100644
--- a/libguile/vports.c
+++ b/libguile/vports.c
@@ -56,21 +56,11 @@ sf_flush (SCM port)
scm_t_port *pt = SCM_PTAB_ENTRY (port);
SCM stream = SCM_PACK (pt->stream);
- if (pt->write_pos > pt->write_buf)
- {
- /* write the byte. */
- scm_call_1 (SCM_SIMPLE_VECTOR_REF (stream, 0),
- SCM_MAKE_CHAR (*pt->write_buf));
- pt->write_pos = pt->write_buf;
-
- /* flush the output. */
- {
- SCM f = SCM_SIMPLE_VECTOR_REF (stream, 2);
+ SCM f = SCM_SIMPLE_VECTOR_REF (stream, 2);
+
+ if (scm_is_true (f))
+ scm_call_0 (f);
- if (scm_is_true (f))
- scm_call_0 (f);
- }
- }
}
static void