Closed lemvik closed 2 years ago
Firstly, I think varargs is actually not supported by this library (I don't see the argument type marker for this, and I vaguely remember that indeed not all implementations support it). It may work in some implementations but not all of them.
For the ABI properties, it might be better to automatically handle in Chez's foreign-procedure
as other implementations do those things (e.g. Larceny is calling ffi-get-abi
to get proper ABI inside of the make-c-function
).
I've created issue #25 to (officially) support varargs. Thanks for reminding me :D
Thank you!
I've added implementation specific calling convention capability to foreign-procedure
, though bare Chez doesn't support (__varargs_after X)
. It seems that's Racket specific thing. So, maybe you also need to ask Chez developers to support variadic arguments (or something similar with __varargs_after
).
Thank you for the change!
Currently there is no (?) way to specify additional ABI properties (calling convention, etc.) of foreign procedures in Chez (and other) implementation of
pffi
.Chez supports those (here is the doc) and most of the time they are not really required to be able to build an FFI wrapper around C library. However, there is an exception to that, in particular, on MacOS X M1.
This comment in a Racket Chez branch mentions that in order to correctly set up a call for C procedure that uses
va_list
on an Apple Silicon architecture one needs to provide(__varargs_after X)
ABI specifier.Inability to specify it prevents
akku
Scheme package manager from working on M1 Mac OS - it binds tolibcurl
and usescurl_easy_setopt
function that is actually a vararg-taking C func.On the other hand, I'm not sure if any other Scheme implementation actually allows specifying ABI conventions so I wonder what would be the best way to add such support in a uniform way.