chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] "Dynamically Loading" non-entry-point code


From: Felix Winkelmann
Subject: Re: [Chicken-users] "Dynamically Loading" non-entry-point code
Date: Tue, 22 Jun 2004 07:44:18 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

Daniel B. Faken wrote:

On Tue, 22 Jun 2004, felix wrote:

Daniel B. Faken wrote:

I need to call it from C (because I want the library to basically load some of its own bindings), so I defined this in my "scmif" interface
layer (see below)

Do you see any problem with this? (I wasn't too sure what you meant by "it gets complicated") Will this work with arbitrarily nested layers of callback?


<snip>

This could actually work, but I'm not totally sure.
Does it crash? ;-)

cheers,
felix


Sorry, I should have mentioned that; it *seems* to work just peachy. I have happily been able to simplify three separate packages this way. My question was more regarding if there was some theoretical problem.. I.e. what exactly would calling it 'just' from scheme (as per your suggestion) do differently from my C-calling-Scheme + one-layer-of-indirection
code?

By what I can infer from your example, it should work. The important
issue is to make sure no calls from Scheme to C into Scheme happen, that might
trigger a garbage collection without saving some context data (like the
continuation of the outermost Scheme context).
The other important issue is that, for GC to work, a "restart" trampoline
has to be established, so that once a minor GC has been run, something
is there that can be longjmp'd to.
And yet another important issue is that a minor GC may not simply remove
live C stack frames.

Depending on your definition of scmif_eval_stringf, your example looks ok to me.


  FWIW, I've also used this kind of indirection technique to add scheme
bindings to C functions at run-time and to add a safety layer so functions can be called whether the Chicken toplevel is active or not

Interesting. Can you give more information about how you setup the
safety layer?

(thanks for adding CHICKEN_is_running() :) ).

You're welcome. Happy customers is our goal.


cheers,
felix





reply via email to

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