GNU bug report logs -
#18592
FFI should have portable access to ‘errno’
Previous Next
Full log
Message #22 received at 18592 <at> debbugs.gnu.org (full text, mbox):
Hi,
Sorry for the long delay.
Chaos Eternal <chaoseternal <at> shlug.org> skribis:
> Proposals to solve this bug:
>
> Proposal 1.
>
> Adding a keyword argument to pointer->procedure, if set to true, the
> generated wrapper will check 'errno' immediately after ffi_call and
> return the errno as second value.
>
> the proposed pointer->procedure maybe like this:
> pointer->procedure return_type func_ptr arg_types #:return-errno
>
> Proposal 2.
>
> let pointer->procedure check return_type, if it is a list:
> (func_return_type, 'errno)
> then return multiple values, as errno be second value.
That’s my favorite because it’s both pragmatic and extensible (we can
also add support for h_errno, etc.)
> Proposal 3.
>
> introduce another procedure "pointers->procedure", which will pack
> multiple function pointer into one procedure, in this procedure, the
> packed functions will be called in sequence, and their return value
> will be returned as multiple values.
>
> the interface would be like this:
> pointers->procedure (list-of-return-type) (list-of-pointers) (list-of arg-defs)
>
> also, we need a simple c-function deref-pointer-to-int, which will
> de-reference a pointer and return it's int value.
>
> using above tools, a proper system call with errno be returned could
> be like this:
>
> ((pointers->procedure
> (list int int)
> (list pointer-of-inotify-add-watch pointer-of-deref-pointer-to-int)
> (list (list int '* int) (list '*)))
> (list inotify-fd "path-to-watch" watch-flag) (list pointer-of-errno))
The problem is that POINTER-OF-ERRNO does not necessarily exist and
cannot be obtained portably.
Also, I find the interface a bit clumsy.
So my support goes to #2. Would you like to give it a try?
Thanks for your input!
Ludo’.
This bug report was last modified 8 years and 338 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.