[erlang-questions] Passing a C array to the emulator as an ErlIOVec

Vance Shipley vances@REDACTED
Fri Dec 14 22:31:51 CET 2007


Joel,

I have some drivers which marshall C structs into binaries
and deal with them in erlang.  It's a bit tedious to put
together but I think I've done a good job of having autotools
(autoconf,automake,etc.) handle the portability and some of
the library changes (e.g. changes to array sizes).  The first
thing to be sure of is that you've handled word alignment
padding.

An example driver is here:

http://netaccess-erldrv.googlecode.com/svn/trunk/c_src/netaccess_drv.c
http://netaccess-erldrv.googlecode.com/svn/trunk/include/iisdn.hrl.in
http://netaccess-erldrv.googlecode.com/svn/trunk/src/iisdn.erl

For each C struct in the API I implement a function:

	foo(#foo{}) -> binary()
	foo(binary()) -> #foo{}

It's tedious to implement bt I've moved between Solaris 32 and 64
and to Linux automatically just by rerunning autotools.

Hope that helps.

	-Vance



More information about the erlang-questions mailing list