cffi/cffi — pull request #28 by ffilozov (2013-08-07 12:01:12+00:00)
Title: Preliminary support for returning errno as a second value

On some implementations, the only safe way to get errno after a foreign call is to pass a particular option to the foreign function definition. In Allegro this is done by passing :error-value to ff:def-foreign-call. Along with the foreign functions' return value, errno will be returned as the second value.

This commit adds a new option called :errno. It's used as follows: (foreign-funcall ("strlen" :errno t) :string "foo" :int), or (defcfun (strlen "strlen" :errno t) :int (s :string)).

This commit has the least code needed to make it work for Allegro.

Any help in making the code more general, and cover more cases, would be appreciated. I believe there might be other code that needs to know about errno, but I don't particularly understand those pieces.