unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: guile-devel <guile-devel@gnu.org>
Subject: dynamic foreign function interface
Date: Tue, 26 Jan 2010 23:06:07 +0100	[thread overview]
Message-ID: <m34om8zflc.fsf@pobox.com> (raw)

Hey all,

I just finished up some work to make a dynamic foreign function
interface. This is on the wip-ffi branch.

By "dynamic", I mean that you don't have to write C and compile it; you
can do everything at runtime from Scheme. You use dynamic-func and
dynamic-link to get the raw function pointer, and make-foreign-function
to turn that function pointer into a Scheme procedure.

The interface is very low-level. Obviously declaring that an arbitrary
symbol resolved via `dlsym' is of a certain function type is an unsafe
operation that can lead to crashes.

Apart from that typing problem, you have pointer and struct types. If
you say that the function takes an int8, Guile will ensure that it can
make an int8; but if you say that the function takes a pointer or a
by-value struct, Guile will only ensure that the arg is a "foreign"
(from foreign.[ch]) pointer, only checking lengths in the case that it's
a struct of known length.

The intention is to provide an expressive Scheme layer, on top of which
any safety constructs can be built as needed.

I would merge it now, except for the fact that it depends on libffi.
Libffi is very portable, and probably exists for all of Guile's
architectures, but it is an extra dependency. Should we require libffi
in Guile 1.9.8? Or should we build the necessary pieces conditionally?

Let me know,

Andy
-- 
http://wingolog.org/




             reply	other threads:[~2010-01-26 22:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26 22:06 Andy Wingo [this message]
2010-01-26 22:29 ` dynamic foreign function interface Ludovic Courtès
2010-01-27  0:22   ` Andy Wingo
2010-01-28 21:39     ` Neil Jerram

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=m34om8zflc.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).