caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] create a closure in external C function?
@ 2001-03-06  9:29 Chris Hecker
  2001-03-06 10:50 ` Fabrice Le Fessant
  2001-03-06 17:01 ` Xavier Leroy
  0 siblings, 2 replies; 12+ messages in thread
From: Chris Hecker @ 2001-03-06  9:29 UTC (permalink / raw)
  To: caml-list


I can't find any docs on this, except for a couple hints that it might be possible...

I want to create a function and return it from an external C function:

type ii = int -> int
val f : int -> ii = "c_function"

where c_function looks something like this:

value c_function( value i )
{
    return Val_closure(&some_c_int_int_function);
}

Is this possible?  The Closure_tag is not very well documented, but from tracing through the asm for some callbacks and passing closures to C functions, it appears that the first word is a pointer to the actual generated code for the caml function.  So, if you wanted to make this work you'd have to return a pointer to a caml function that calls _caml_c_call, which isn't really documented either (and looks platform specific, although it seems to just be jumping to the address of the passed C function after setting things up).

Any hope of getting this working?  Is caml_c_call designed to be a C callable function on all platforms (it doesn't look like it, since it takes a parm in registers on x86, which is unusual)?  Is the bytecode sitatution completely different (I assume so)?

Chris

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-03-07  8:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-06  9:29 [Caml-list] create a closure in external C function? Chris Hecker
2001-03-06 10:50 ` Fabrice Le Fessant
2001-03-06 17:01 ` Xavier Leroy
2001-03-06 18:19   ` Chris Hecker
2001-03-07  3:23     ` Fergus Henderson
2001-03-06 18:58   ` Marcin 'Qrczak' Kowalczyk
2001-03-06 19:13     ` Chris Hecker
2001-03-06 21:16       ` Marcin 'Qrczak' Kowalczyk
2001-03-06 22:56         ` Chris Hecker
2001-03-07  0:22           ` Marcin 'Qrczak' Kowalczyk
2001-03-07  0:44             ` Chris Hecker
2001-03-07  8:49               ` Marcin 'Qrczak' Kowalczyk

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 NNTP newsgroup(s).