[erlang-questions] Erlang FFI: new draft EEP, patches, and summary

Alceste Scalas <>
Sat Sep 29 13:01:32 CEST 2007


based on the feedback received on this mailing list, I've updated
the Erlang FFI draft EEP and patches.  Everything is available at
the usual place:


Here's a summary of the changes discussed so far (with references to
the previous emails):

     1. buffer-to-binary and cstring-to-binary conversions [1]

     2. passing/returning Erlang binary()'es as ErlDrvBinary'es [2]

     3. FFI and preload information on erl_ddll:info/2 [1]

     4. high-level API with type-tagged values [1]

     5. 'nonnull' FFI type, for representing (and checking) non-NULL
        pointers [3]

     6. ffi:sizeof(Type) and hard-coded type size macros [1]

     7. erl_ddll:load_library/2 and erlang:open_port/1 [1]

Here's a list of enhancements that were *not* discussed before (for
the details, see the updated draft EEP):

     8. passing iolist()s to the C side as ErlIOVec's

     9. ffi:min/1, ffi:max/1 and ffi:check/1 (for range and
        consistence checking on type-tagged values)

     10. utility macros for easier binary matching of FFI types.

     11. some new FFI types (pid_t, off_t).

At the moment, there are two known issues (in the patches and/or the
draft EEP):

     1. the patches have not been tested on big-endian platforms,
        yet.  I expect them to have signedness problems, so beta
        testers (and bug fixers ;-) are welcome!

     2. floating point types are not (yet) properly supported by
        ffi:min/1, ffi:max/1 and ffi:check/1.  In general, the
        floating point checking API needs to be enhanced (for
        example, there should be a way to obtain FLT_EPSILON for the
        current platform).

And finally, here's the only proposal that has not been integrated
(yet) in the draft EEP:

     * David Hopwood proposed a very elegant closure-based FFI [3].
       However, I didn't get how it could be actually used, and asked
       for clarifications [4].

I think that's all.  As usual, leave your feedback and/or try the
patches.  Thanks!



Notes and references:

[1] Erlang FFI : 1st discussion summary

[2] FFI: handling refcounted binaries

[3] David Howood's original proposal for the closure-based FFI

[4] Discussion about the closure-based FFI

Alceste Scalas <>

This message was sent using IMP, the Internet Messaging Program.

More information about the erlang-questions mailing list