[plt-scheme] FFI and "glue code"

From: Grant Rettke (grettke at acm.org)
Date: Mon Apr 26 16:48:50 EDT 2010


One of the functions that I want to call into via the FFI I'm using
(MPI) expects the address of a particular structure called
ompi_communicator_t. In order the make the call, MPI_Comm_size, I
don't need to create a new ompi_communicator_t, I can just use one
that is predefined named MPI_COMM_WORLD. The call just needs its

>From looking at the FFI API it looks like the easiest way to get a
pointer to that predefined struct would be to write some glue code
where a function returned MPI_COMM_WORLD's address, and in Scheme I
bound that to a _cpointer that I could pass back into the FFI.

Does that make sense? I don't see any other way to arbitrarily get a
pointer to some predefined value.

Best wishes,

Grant Rettke

Posted on the users mailing list.