From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chaos Eternal Newsgroups: gmane.lisp.guile.bugs Subject: bug#18592: FFI should have portable access to =?UTF-8?Q?=E2=80=98errno=E2=80=99?= Date: Sun, 23 Nov 2014 01:53:35 +0800 Message-ID: References: <87fvf8oocf.fsf@ft.bewatermyfriend.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1416699023 14934 80.91.229.3 (22 Nov 2014 23:30:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Nov 2014 23:30:23 +0000 (UTC) To: 18592@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Nov 23 00:30:16 2014 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 1XsK86-0005I7-Nq for guile-bugs@m.gmane.org; Sun, 23 Nov 2014 00:30:14 +0100 Original-Received: from localhost ([::1]:47130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsK86-0005iY-AS for guile-bugs@m.gmane.org; Sat, 22 Nov 2014 18:30:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsEsq-00030e-MK for bug-guile@gnu.org; Sat, 22 Nov 2014 12:54:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XsEsk-0003zL-HE for bug-guile@gnu.org; Sat, 22 Nov 2014 12:54:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsEsk-0003zF-De for bug-guile@gnu.org; Sat, 22 Nov 2014 12:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XsEsj-00012z-Qq for bug-guile@gnu.org; Sat, 22 Nov 2014 12:54:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87fvf8oocf.fsf@ft.bewatermyfriend.org> Resent-From: Chaos Eternal Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 22 Nov 2014 17:54:01 +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.14166788203992 (code B ref 18592); Sat, 22 Nov 2014 17:54:01 +0000 Original-Received: (at 18592) by debbugs.gnu.org; 22 Nov 2014 17:53:40 +0000 Original-Received: from localhost ([127.0.0.1]:41945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XsEsN-00012K-NE for submit@debbugs.gnu.org; Sat, 22 Nov 2014 12:53:40 -0500 Original-Received: from mail-ie0-f181.google.com ([209.85.223.181]:36077) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XsEsK-00012B-Li for 18592@debbugs.gnu.org; Sat, 22 Nov 2014 12:53:37 -0500 Original-Received: by mail-ie0-f181.google.com with SMTP id tp5so6763697ieb.12 for <18592@debbugs.gnu.org>; Sat, 22 Nov 2014 09:53:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=mEbUbvpAYpvLY9gZzjx3kPkPPKojdnm/LD6rahPH3tM=; b=m59SUPtBbtdbsNWA16mibDtCZZHxn8zyiyWixsNy+GKryKMqQ3JXmM8h+ZrcmiUA8p Le1lxUJ/eJBDsu246ywUWdaL94jC083DVhlr4sYrNXUy26yYib/5bvGtVJ3p2DUrUUUO k0KRYGwf+F7mIIw3oJ8esEbnqcvTznItkL49gRD/MqY4p9RcoecHYKabG/fWsULVvTCd gwh1Ko3j/ksnc4QhiVKwVv31IsrKvIFOeXvX/egewm1bpVNxCK+pfxRSehK0dBQMUrNf +oVkM4IbzcJT0XKEdCLCBYascpLQFfUfpVMgQwDrZtYitpQwRHbgVn4QhehPpN32YRrq kmpQ== X-Gm-Message-State: ALoCoQkW8DHYHK9423mtzHcEu7zcKxzL+Xug81jTjaw3Yfy6uKfHDc6z0dYTCMtNjO+4YbfAb8ul X-Received: by 10.43.157.202 with SMTP id lr10mr7660732icc.78.1416678815849; Sat, 22 Nov 2014 09:53:35 -0800 (PST) Original-Received: by 10.64.102.40 with HTTP; Sat, 22 Nov 2014 09:53:35 -0800 (PST) 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-Mailman-Approved-At: Sat, 22 Nov 2014 18:30:12 -0500 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:7642 Archived-At: 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