caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: caml-list@inria.fr
Subject: [Caml-list] create a closure in external C function?
Date: Tue, 06 Mar 2001 01:29:57 -0800	[thread overview]
Message-ID: <4.3.2.7.2.20010306011427.03669de0@shell16.ba.best.com> (raw)


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


             reply	other threads:[~2001-03-06  9:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-06  9:29 Chris Hecker [this message]
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

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

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

  git send-email \
    --in-reply-to=4.3.2.7.2.20010306011427.03669de0@shell16.ba.best.com \
    --to=checker@d6.com \
    --cc=caml-list@inria.fr \
    /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 NNTP newsgroup(s).