I worked out a basic implementation for a
thread-local errno. Bordeaux-threads has been added as a dependency as well as two extra functions: cffi:set-errno and cffi:get-errno.
This is a much cleaner interface than passing an object, and the generated function doesn't need to have an extra parameter.
Sample:
CL-USER> (cffi:defcfun ("socket" :errno t) :int
(a :int)
(b :int)
(c :int))
Warning: :call-direct ignored because :error-value specified.
SOCKET
CL-USER> (socket -1 -1 -1)
-1
CL-USER> (cffi:get-errno)
22
T
The implementation uses locking, so its efficiency could improved. I'm interested in your suggestions on how to do that.