From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#18592: FFI should have portable access to =?UTF-8?Q?=E2=80=98errno=E2=80=99?= Date: Mon, 19 Jan 2015 21:22:11 +0100 Message-ID: <87h9vmy0zw.fsf@gnu.org> References: <87fvf8oocf.fsf@ft.bewatermyfriend.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1421699188 14351 80.91.229.3 (19 Jan 2015 20:26:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Jan 2015 20:26:28 +0000 (UTC) Cc: 18592@debbugs.gnu.org To: Chaos Eternal Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jan 19 21:26:27 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YDItz-0003uG-AK for guile-bugs@m.gmane.org; Mon, 19 Jan 2015 21:26:23 +0100 Original-Received: from localhost ([::1]:39632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDIty-0000l0-Lm for guile-bugs@m.gmane.org; Mon, 19 Jan 2015 15:26:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDIqo-0004QL-C2 for bug-guile@gnu.org; Mon, 19 Jan 2015 15:23:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDIqk-0000ex-P7 for bug-guile@gnu.org; Mon, 19 Jan 2015 15:23:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDIqk-0000d3-MH for bug-guile@gnu.org; Mon, 19 Jan 2015 15:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YDIqk-0004ho-50 for bug-guile@gnu.org; Mon, 19 Jan 2015 15:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 19 Jan 2015 20:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18592 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 18592-submit@debbugs.gnu.org id=B18592.142169893618027 (code B ref 18592); Mon, 19 Jan 2015 20:23:02 +0000 Original-Received: (at 18592) by debbugs.gnu.org; 19 Jan 2015 20:22:16 +0000 Original-Received: from localhost ([127.0.0.1]:49883 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDIpz-0004gg-P0 for submit@debbugs.gnu.org; Mon, 19 Jan 2015 15:22:16 -0500 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:54698) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDIpx-0004gV-0X for 18592@debbugs.gnu.org; Mon, 19 Jan 2015 15:22:13 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 1821C454F; Mon, 19 Jan 2015 21:22:12 +0100 (CET) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qPNLM5leBg84; Mon, 19 Jan 2015 21:22:12 +0100 (CET) Original-Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by hera.aquilenet.fr (Postfix) with ESMTPSA id AACC019D7; Mon, 19 Jan 2015 21:22:11 +0100 (CET) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 30 =?UTF-8?Q?Niv=C3=B4se?= an 223 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Chaos Eternal's message of "Sun, 23 Nov 2014 01:53:35 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7709 Archived-At: Hi, Sorry for the long delay. Chaos Eternal 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=E2=80=99s my favorite because it=E2=80=99s both pragmatic and extensib= le (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=E2=80=99.