From 612f8f6ba1f363a2ed9b099872e95ca10058c831 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 1 Apr 2010 17:39:52 -0700 Subject: [PATCH] Configure: Add backward compat fix for Guile 1.8. Guile 1.9 introduces two new typedefs that are used with the scm_internal_hash_fold() and scm_internal_hash_for_each_handle() functions. To preserve backward compatibility with Guile 1.8, we must check for these typedefs in Guile's API, and conditionally compile them. According to the Guile team, these two functions were intended for internal use (thus their naming convention), so LilyPond should eventually migrate away from using them. --- config.hh.in | 3 +++ configure.in | 7 +++++++ lily/general-scheme.cc | 2 +- lily/include/ly-module.hh | 8 ++++++-- lily/ly-module.cc | 9 ++++----- lily/module-scheme.cc | 2 +- lily/scm-hash.cc | 6 ++++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/config.hh.in b/config.hh.in index 47f057fcbc..338f8eb969 100644 --- a/config.hh.in +++ b/config.hh.in @@ -94,3 +94,6 @@ /* define if you have pango FT2 binding */ #define HAVE_PANGO_FT2 0 + +/* define if Guile has types scm_t_hash_fold_fn and scm_t_hash_handle_fn */ +#define HAVE_GUILE_HASH_FUNC 0 diff --git a/configure.in b/configure.in index 3f6959fa78..3f3b4f4d7b 100644 --- a/configure.in +++ b/configure.in @@ -112,6 +112,13 @@ STEPMAKE_TEXMF(REQUIRED) STEPMAKE_TEXMF_DIRS STEPMAKE_GUILE_DEVEL(REQUIRED, 1.8.2) +# check for 2 typedefs added in Guile 1.9 +save_CFLAGS="$CFLAGS" +CFLAGS="$GUILE_CFLAGS $CFLAGS" +AC_CHECK_TYPES([scm_t_hash_fold_fn, scm_t_hash_handle_fn], + [AC_DEFINE(HAVE_GUILE_HASH_FUNC)], [], + [#include ]) +CFLAGS="$save_CFLAGS" ## check rational bugfix. save_CPPFLAGS="$CPPFLAGS" diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index cd7e25d8c0..d409ce0967 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -462,7 +462,7 @@ LY_DEFINE (ly_hash_table_keys, "ly:hash-table-keys", 1,0,0, (SCM tab), "Return a list of keys in @var{tab}.") { - return scm_internal_hash_fold ((Hash_closure_function) & accumulate_symbol, + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &accumulate_symbol, NULL, SCM_EOL, tab); } diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index e9ab0b8537..0a7fdc8726 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -19,6 +19,7 @@ #ifndef LY_MODULE_HH #define LY_MODULE_HH +#include "config.hh" #include "lily-guile.hh" SCM ly_make_anonymous_module (bool safe); @@ -33,8 +34,11 @@ SCM ly_clear_anonymous_modules (); void clear_anonymous_modules (); SCM ly_use_module (SCM mod, SCM used); -/* Ugh signature of scm_internal_hash_fold () is inaccurate. */ -typedef SCM (*Hash_closure_function) (GUILE_ELLIPSIS); +/* For backward compatability with Guile 1.8 */ +#if !HAVE_GUILE_HASH_FUNC +typedef SCM (*scm_t_hash_fold_fn) (GUILE_ELLIPSIS); +typedef SCM (*scm_t_hash_handle_fn) (GUILE_ELLIPSIS); +#endif #define MODULE_GC_KLUDGE diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 07fdc531ed..b5880a0e9a 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -126,7 +126,8 @@ LY_DEFINE (ly_module_2_alist, "ly:module->alist", SCM_VALIDATE_MODULE (1, mod); SCM obarr = SCM_MODULE_OBARRAY (mod); - return scm_internal_hash_fold ((Hash_closure_function) & entry_to_alist, NULL, SCM_EOL, obarr); + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &entry_to_alist, + NULL, SCM_EOL, obarr); } void @@ -188,10 +189,8 @@ make_stand_in_procs_weak () SCM old_tab = scm_stand_in_procs; SCM new_tab = scm_make_weak_key_hash_table (scm_from_int (257)); - new_tab = scm_internal_hash_fold ((Hash_closure_function) & redefine_keyval, - NULL, - new_tab, - old_tab); + new_tab = scm_internal_hash_fold ((scm_t_hash_fold_fn) &redefine_keyval, + NULL, new_tab, old_tab); scm_stand_in_procs = new_tab; } diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index 192fcf4966..b58bf15ffb 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -47,7 +47,7 @@ LY_DEFINE (ly_module_copy, "ly:module-copy", { #define FUNC_NAME __FUNCTION__ SCM_VALIDATE_MODULE (1, src); - scm_internal_hash_fold ((Hash_closure_function) & module_define_closure_func, + scm_internal_hash_fold ((scm_t_hash_fold_fn) &module_define_closure_func, (void *) dest, SCM_EOL, SCM_MODULE_OBARRAY (src)); return SCM_UNSPECIFIED; diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index bb73d52cd5..058f3be9d5 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -39,7 +39,8 @@ copy_handle (void *closure, SCM handle) static void copy_scm_hashes (SCM dest, SCM src) { - scm_internal_hash_for_each_handle ( (SCM (*)(GUILE_ELLIPSIS)) ©_handle, dest, src); + scm_internal_hash_for_each_handle ((scm_t_hash_handle_fn) ©_handle, + dest, src); } Scheme_hash_table::Scheme_hash_table () @@ -142,7 +143,8 @@ collect_handles (void * /* closure */, SCM Scheme_hash_table::to_alist () const { - return scm_internal_hash_fold ((SCM (*)(GUILE_ELLIPSIS)) &collect_handles, NULL, SCM_EOL, hash_tab_); + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &collect_handles, + NULL, SCM_EOL, hash_tab_); } IMPLEMENT_SMOBS (Scheme_hash_table); -- 2.39.2