unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Patrick McCarty <pnorcks@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Backward compatibility status
Date: Fri, 2 Apr 2010 11:21:46 -0700	[thread overview]
Message-ID: <20100402182146.GA7627@mail.google.com> (raw)
In-Reply-To: <87y6hu8oe5.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]

Hi Ludo,

Sorry about the delayed response...

On 2010-03-15, Ludovic Courtès wrote:
> 
> Patrick McCarty <pnorcks@gmail.com> writes:
> 
> > 2010/3/6 Ludovic Courtès <ludo@gnu.org>:
> >> | Name              | Cause                                           |
> >> |-------------------+-------------------------------------------------|
> >> | lilypond-2.13.9   | `scm_internal_hash_fold' & `scm_t_hash_fold_fn' |
> >
> > Is this something that should be fixed in LilyPond?
> 
> I think so, yes (especially since ‘scm_internal_hash_fold’ was intended
> to be sort-of internal.)

Okay, thanks.  I didn't make that connection at first.  :-)

I think, eventually, LilyPond should migrate away from using these
"internal" functions, but that's not something I'm able to figure out
right now.

> > If I add the typedefs to the appropriate LilyPond header file and use
> > them, the problem goes away, but I don't know if there are unexpected
> > side effects of this.
> 
> I think you want a fix that retains compatibility with 1.8.  How about
> having a ‘configure’ test checking for this typedef?

Is the attached patch for LilyPond what you had in mind?

I'll apply it if it looks okay to you.  I've tested with both Guile
1.8 and 1.9, and it seems to work OK.

> > I am unable to test any further, because there are more build failures
> > down the pipeline.  :-)
> 
> Heh.  Let us know what other Guile-related failures you stumble upon!

I will.  Thanks, for your support.

Regards,
-Patrick

[-- Attachment #2: 0001-Add-checks-for-new-types-in-Guile-2.0.patch --]
[-- Type: text/plain, Size: 5140 bytes --]

From ce815a06b1cc91aa8dfd2a31a782e9a068a6e9d6 Mon Sep 17 00:00:00 2001
From: Patrick McCarty <pnorcks@gmail.com>
Date: Thu, 1 Apr 2010 17:39:52 -0700
Subject: [PATCH] Add checks for new types in Guile 2.0.

In order to preserve backward compatibility with Guile 1.8 and forward
compatibility with Guile 2.0 and later, add configure checks to
conditionally compile 2 new types used for (internal) hash-fold
procedures.

Eventually, LilyPond should migrate away from using functions that are
intended for internal use, but these checks will suffice for now.
---
 config.hh.in              |    3 +++
 configure.in              |    7 +++++++
 lily/general-scheme.cc    |    2 +-
 lily/include/ly-module.hh |    7 +++++--
 lily/ly-module.cc         |    9 ++++-----
 lily/module-scheme.cc     |    2 +-
 lily/scm-hash.cc          |    6 ++++--
 7 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/config.hh.in b/config.hh.in
index 7f43e21..3bcfa72 100644
--- a/config.hh.in
+++ b/config.hh.in
@@ -97,3 +97,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 f7547d1..cc3df1a 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 <libguile.h>])
+CFLAGS="$save_CFLAGS"
 
 ## check rational bugfix.
 save_CPPFLAGS="$CPPFLAGS"
diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc
index cd7e25d..d409ce0 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 e9ab0b8..f301e59 100644
--- a/lily/include/ly-module.hh
+++ b/lily/include/ly-module.hh
@@ -33,8 +33,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 07fdc53..b5880a0 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 192fcf4..b58bf15 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 bb73d52..058f3be 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)) &copy_handle, dest, src);
+  scm_internal_hash_for_each_handle ((scm_t_hash_handle_fn) &copy_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);
-- 
1.7.0.3


  parent reply	other threads:[~2010-04-02 18:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-07  0:29 Backward compatibility status Ludovic Courtès
2010-03-14 23:12 ` Patrick McCarty
2010-03-14 23:38   ` Ludovic Courtès
2010-03-20 22:06     ` Ian Hulin
2010-03-20 22:35       ` Ludovic Courtès
2010-04-02 18:21     ` Patrick McCarty [this message]
2010-04-05 17:06       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100402182146.GA7627@mail.google.com \
    --to=pnorcks@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).