From: "Jack Andrews" <effbiae@ivorykite.com>
To: "David Monniaux" <David.Monniaux@ens.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] what magic is this?
Date: Fri, 6 Aug 2004 21:10:00 +1000 (EST) [thread overview]
Message-ID: <48478.60.246.253.51.1091790600.squirrel@www.ivorykite.com> (raw)
In-Reply-To: <Pine.GSO.4.03.10408051759360.21889-100000@basilic.ens.fr>
> External functions starting with a % are primitives that are
> directly compiled by the ocamlopt compiler into specific code,
> without the overhead of a function call.
oooh - nice.
now a request. it would be *really* nice if there were some public
%primitives that could be used by the FFI user.
i'm thinking they would be similar to the bigarray_ref/set primitives, but
would publish a contract for the lib writer.
this would be something to set ocaml apart (not that it isn't set apart
already) a fast FFI is something that languages lack - i wrote a
benchmark for java's JNI that demonstrated the problem of needing to
optimise the loop while(next())set(get()); (google for jni benchmark).
i'd propose that:
- in the C code, the first member of a custom struct is a pointer
eg: struct CUST
{ void *ptr;
int size;
};
- values are allocated as usual:
value vcust=alloc_custom(&ops,sizeof(struct CUST),x,y);
- four new primitives are available for use in ml file:
external get_int : <cust_type> -> int -> int = "%ffi_get_int"
external get_float : <cust_type> -> int -> float = "%ffi_get_float"
external set_int : <cust_type> -> int -> int -> unit =
"%ffi_set_int"
external set_float : <cust_type> -> int -> float -> unit =
"%ffi_set_float"
it would take me a week to work out how to implement these primitives, but
one of you ocaml guys could do it a lot quicker. please? you'd only have
to re-write it after i made a complete bodge of it :)
thanks in advance,
jack.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2004-08-06 11:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-04 7:27 effbiae
2004-08-05 16:00 ` David Monniaux
2004-08-06 11:10 ` Jack Andrews [this message]
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=48478.60.246.253.51.1091790600.squirrel@www.ivorykite.com \
--to=effbiae@ivorykite.com \
--cc=David.Monniaux@ens.fr \
--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).