diff options
author | Andy Wingo <wingo@pobox.com> | 2011-11-24 00:33:49 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-11-24 11:47:36 +0100 |
commit | 3dc9f41900a0e9f915da3aa1eea6e0fae829c40d (patch) | |
tree | 341f211c17227f4484ecf033b20ce2f7d49b40df | |
parent | 686022e84ee374c3193967b69504f01c030f4c7e (diff) | |
download | guile-3dc9f41900a0e9f915da3aa1eea6e0fae829c40d.tar.gz |
support for new GC_move_disappearing_link
* configure.ac: Check for GC_move_disappearing_link.
* libguile/weak-set.c (move_weak_entry):
* libguile/weak-table.c (move_disappearing_links):
(move_weak_entry): Use GC_move_disappearing_link if available.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | libguile/weak-set.c | 4 | ||||
-rw-r--r-- | libguile/weak-table.c | 34 |
3 files changed, 35 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index a5918a3f9..a88fd1b7f 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 GC_get_suspend_signal]) +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_suspend_signal GC_move_disappearing_link]) # 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/weak-set.c b/libguile/weak-set.c index 53d22a3da..57e9e5001 100644 --- a/libguile/weak-set.c +++ b/libguile/weak-set.c @@ -173,9 +173,13 @@ move_weak_entry (scm_t_weak_entry *from, scm_t_weak_entry *to) if (copy.key && SCM_HEAP_OBJECT_P (SCM_PACK (copy.key))) { +#ifdef HAVE_GC_MOVE_DISAPPEARING_LINK + GC_move_disappearing_link ((GC_PTR) &from->key, (GC_PTR) &to->key); +#else GC_unregister_disappearing_link ((GC_PTR) &from->key); SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) &to->key, (GC_PTR) to->key); +#endif } } else diff --git a/libguile/weak-table.c b/libguile/weak-table.c index 18e164843..47d65e69c 100644 --- a/libguile/weak-table.c +++ b/libguile/weak-table.c @@ -152,6 +152,33 @@ unregister_disappearing_links (scm_t_weak_entry *entry, } static void +move_disappearing_links (scm_t_weak_entry *from, scm_t_weak_entry *to, + SCM key, SCM value, scm_t_weak_table_kind kind) +{ + if ((kind == SCM_WEAK_TABLE_KIND_KEY || kind == SCM_WEAK_TABLE_KIND_BOTH) + && SCM_HEAP_OBJECT_P (key)) + { +#ifdef HAVE_GC_MOVE_DISAPPEARING_LINK + GC_move_disappearing_link ((GC_PTR) &from->key, (GC_PTR) &to->key); +#else + GC_unregister_disappearing_link (&from->key); + SCM_I_REGISTER_DISAPPEARING_LINK (&to->key, SCM_HEAP_OBJECT_BASE (key)); +#endif + } + + if ((kind == SCM_WEAK_TABLE_KIND_VALUE || kind == SCM_WEAK_TABLE_KIND_BOTH) + && SCM_HEAP_OBJECT_P (value)) + { +#ifdef HAVE_GC_MOVE_DISAPPEARING_LINK + GC_move_disappearing_link ((GC_PTR) &from->value, (GC_PTR) &to->value); +#else + GC_unregister_disappearing_link (&from->value); + SCM_I_REGISTER_DISAPPEARING_LINK (&to->value, SCM_HEAP_OBJECT_BASE (value)); +#endif + } +} + +static void move_weak_entry (scm_t_weak_entry *from, scm_t_weak_entry *to, scm_t_weak_table_kind kind) { @@ -164,10 +191,9 @@ move_weak_entry (scm_t_weak_entry *from, scm_t_weak_entry *to, to->key = copy.key; to->value = copy.value; - unregister_disappearing_links (from, kind); - register_disappearing_links (to, - SCM_PACK (copy.key), SCM_PACK (copy.value), - kind); + move_disappearing_links (from, to, + SCM_PACK (copy.key), SCM_PACK (copy.value), + kind); } else { |