GNU bug report logs - #18592
FFI should have portable access to ‘errno’

Previous Next

Package: guile;

Reported by: Frank Terbeck <ft <at> bewatermyfriend.org>

Date: Tue, 30 Sep 2014 20:21:01 UTC

Severity: wishlist

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Chaos Eternal <chaoseternal <at> shlug.org>
To: 18592 <at> debbugs.gnu.org
Subject: bug#18592: FFI should have portable access to ‘errno’
Date: Sun, 23 Nov 2014 01:53:35 +0800
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.

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))

using this proposal, many "errno" like mechanisms can be handled,
for example, the h_errno of libc, etc.

further more, this proposal can be used to solve a sort of
requirements like make several calls atomic.

--
regards




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.