[iolib-devel] On iolib-posix, OSICAT and FFI interfaces
Stelian Ionescu
sionescu at common-lisp.net
Fri Jul 27 23:34:28 UTC 2007
hi, I'd like to ask your advice concerning how to implement a good OS
interface. I and luis are working on the FFI interface to the OS which
is part of IOlib(iolib-posix) and we are a bit undecided over the
approach to take especially regarding how to handle IN/OUT or OUT struct
arguments:
1) return multiple arguments, the first one being the foreign function's
return value(if it's not "void"), the rest being the struct members
unpacked. this has the advantage of being mainly non-consing - except
maybe for large numbers of values - IIRC with stat() I get 14 multiple
values. If I'm not mistaken most implementation stack-allocate multiple
values(perhaps only up to a certain number ?)
2) copy each struct into a structure object or CLOS object(like
sb-posix). this has the disadvantage of consing one or more objects with
each call
3) make two packages: one with an interface very close to C, without
unpacking or consing objects, ie. STAT would need to be passed a foreign
pointer to a "struct stat" and the programmer would use directly CFFI
to retrieve desired data.
the second interface would be a high-level one, lispy in the sense of
having ENVIRONMENT-VARIABLE and (SETF ENVIRONMENT-VARIABLE) instead of
GETENV and SETENV. the function names would be quite different from the
OS names also because we could have something like (SETF FILE-STAT) as
"frontend" for several syscalls such as chown, chmod and utime (example
taken from http://clisp.cons.org/impnotes/syscalls.html).
in all 3 options I imply reporting errors via conditions
the choice I prefer is n° 3, because it allows me to have both a
(mostly) non-consing interface for when I really need speed and a lispy
interface that *most* people would want to use since dealing with a FFI
is most often obnoxious, and yes, I'm a bit obsessed by speed/efficiency :)
among existing libraries, OSICAT seems to be the one closer to what I
prefer and we(luis and I) have been thinking of continuing development
of OSICAT if you agree, abandoning iolib-posix on favour of
something like osicat-posix-ffi and osicat-windows-ffi - the low-level
side of it
suggestions ?
--
(sign :name "Stelian Ionescu" :aka "fe[nl]ix"
:quote "Quidquid latine dictum sit, altum videtur.")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/iolib-devel/attachments/20070728/967b0154/attachment.sig>
More information about the iolib-devel
mailing list