bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

load_extension calls scm_dynamic_call unconditionally


From: Scott McPeak
Subject: load_extension calls scm_dynamic_call unconditionally
Date: Tue, 22 Sep 2009 15:56:38 -0700
User-agent: Thunderbird 2.0.0.18 (X11/20081113)

Hi,

I'm trying to write a program that uses Guile but does not do any
dynamic linking, yet still uses the SRFI-1 extension.  The
documentation for scm_load_extension hints at how to do this:


http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Dynamic-Linking-and-Compiled-Code-Modules.html#index-scm_005fload_005fextension-2351

However, after registering SRFI-1 in my inner_main by calling
scm_c_register_extension, statically linking
libguile-srfi-srfi-1-v-3.a, and confirming via debugger and printouts
that my registered extension is being found and initialized,
load_extension still calls scm_dynamic_call and scm_dynamic_link, both
of which I've modified to call abort().

This is contrary to my interpretation of the documentation for
load_extension, which says it calls a pre-registered function
*instead* of calling dynamic-call.

The change to load_extension that makes it behaves the way I expect is
simple (diff against guile-1.8.7/libguile/extensions.c):

  --- extensions.c.orig   2009-09-22 15:15:52.000000000 -0700
  +++ extensions.c        2009-09-22 15:39:01.000000000 -0700
  @@ -71,6 +71,9 @@
   static void
   load_extension (SCM lib, SCM init)
   {
  +  /* Set to true if we find a matching extension. */
  +  int found = 0;
  +
     /* Search the registry. */
     if (registered_extensions != NULL)
       {
  @@ -89,12 +92,19 @@
              && !strcmp (ext->init, cinit))
            {
              ext->func (ext->data);
  +           found = 1;
              break;
            }

         scm_dynwind_end ();
       }

  +  /* The documentation for 'scm_load_extension' says that if a
  +   * pre-registered function is found, then it is run *instead* of
  +   * calling 'dynamic-call'. */
  +  if (found)
  +    return;
  +
     /* Dynamically link the library. */
     scm_dynamic_call (init, scm_dynamic_link (lib));
   }

This this correct?

-Scott




reply via email to

[Prev in Thread] Current Thread [Next in Thread]