From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Frank Terbeck Newsgroups: gmane.lisp.guile.bugs Subject: bug#18592: FFI should have portable access to =?UTF-8?Q?=E2=80=98errno=E2=80=99?= Date: Tue, 11 Nov 2014 21:02:20 +0100 Message-ID: <87k331v73n.fsf@ft.bewatermyfriend.org> References: <87fvf8oocf.fsf@ft.bewatermyfriend.org> <87wq71ixtw.fsf@yeeloong.lan> 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 1415736327 16669 80.91.229.3 (11 Nov 2014 20:05:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Nov 2014 20:05:27 +0000 (UTC) Cc: 18592@debbugs.gnu.org To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Nov 11 21:05:21 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 1XoHgj-0005Kp-Vg for guile-bugs@m.gmane.org; Tue, 11 Nov 2014 21:05:18 +0100 Original-Received: from localhost ([::1]:50454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoHgj-0003Oc-Aa for guile-bugs@m.gmane.org; Tue, 11 Nov 2014 15:05:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoHga-0003MN-Hf for bug-guile@gnu.org; Tue, 11 Nov 2014 15:05:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoHgV-0006DT-7E for bug-guile@gnu.org; Tue, 11 Nov 2014 15:05:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoHgV-0006Cs-3z for bug-guile@gnu.org; Tue, 11 Nov 2014 15:05:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XoHgU-0004SK-Lu for bug-guile@gnu.org; Tue, 11 Nov 2014 15:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Frank Terbeck Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 11 Nov 2014 20:05: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.141573628217099 (code B ref 18592); Tue, 11 Nov 2014 20:05:02 +0000 Original-Received: (at 18592) by debbugs.gnu.org; 11 Nov 2014 20:04:42 +0000 Original-Received: from localhost ([127.0.0.1]:57643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XoHgA-0004Rj-5g for submit@debbugs.gnu.org; Tue, 11 Nov 2014 15:04:42 -0500 Original-Received: from smtprelay01.ispgateway.de ([80.67.31.24]:59126) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XoHg7-0004Ra-VE for 18592@debbugs.gnu.org; Tue, 11 Nov 2014 15:04:40 -0500 Original-Received: from [46.183.98.176] (helo=jim.voodoo.lan) by smtprelay01.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1XoHg6-0005QQ-L8; Tue, 11 Nov 2014 21:04:38 +0100 Original-Received: by jim.voodoo.lan (Postfix, from userid 1000) id 2B2C7989B1; Tue, 11 Nov 2014 21:02:21 +0100 (CET) In-Reply-To: <87wq71ixtw.fsf@yeeloong.lan> (Mark H. Weaver's message of "Tue, 11 Nov 2014 10:03:23 -0500") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.4.51 (gnu/linux) X-Df-Sender: NDMwNDQ0 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:7633 Archived-At: Mark H. Weaver wrote: > Frank Terbeck writes: [...] >> Mark Weaver on IRC thought it would be a good idea to add portable >> access to the contents of =E2=80=98errno=E2=80=99 (however it's actually= implemented) to >> Guile's FFI. And now the idea has entered the bug tracker. :) > > Indeed, thanks for filing this ticket. > > I see a problem with this idea: something (e.g. a system async) might > change 'errno' before the Scheme code fetches the 'errno' value. Yes. Ludovic hinted at the use of =E2=80=98call-with-blocked-asyncs=E2=80= =99 to avoid this. To deal with that, I wrote a macro for guile-termios=C2=B9: (define-syntax-rule (call-with-errno (errno exp) fail0 fail1 ...) (let-values (((failed? errno) (call-with-blocked-asyncs (lambda () (let* ((f? (termios-failure? exp)) (err (if f? (get-errno) 0))) (values f? err)))))) (if failed? (begin fail0 fail1 ...) #t))) That seems to work fine, unless I'm missing something. Regards, Frank =C2=B9 https://github.com/ft/guile-termios