Hi all,
In Allegro CL, the only safe way to get errno after a foreign function call is to configure the foreign function definition to return it as a second value.
So any library that tries to get errno is potentially broken in Allegro CL. I'm seeing this in practice with lisp-zmq, for example.
I'd like to introduce a new option to defcfun and foreign-funcall called :errno.
It would look like this: (foreign-funcall ("strlen" :errno t) :string "foo" :int), or (defcfun (strlen "strlen" :errno t) :int (s :string)).
Calling (strlen) would return two values, the return value of the foreign call, and errno.
In some Lisps, the only way to get errno is to make an additional foreign call. Then perhaps that call could be made by CFFI and returns as the second value.
Since CFFI delegates the handling of errno to the implementation, perhaps we could preserve the status quo and not get bugged down in grandiose plans of portability.
Thoughts and suggestions are welcome.
Thanks,
Felix