From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: dynamic foreign function interface Date: Wed, 27 Jan 2010 01:22:09 +0100 Message-ID: References: <87aaw08pq3.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1264552077 20773 80.91.229.12 (27 Jan 2010 00:27:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Jan 2010 00:27:57 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jan 27 01:27:49 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NZvl7-0001ZZ-D8 for guile-devel@m.gmane.org; Wed, 27 Jan 2010 01:27:49 +0100 Original-Received: from localhost ([127.0.0.1]:59620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZvl8-0000WB-AL for guile-devel@m.gmane.org; Tue, 26 Jan 2010 19:27:50 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZvek-0004zM-Kc for guile-devel@gnu.org; Tue, 26 Jan 2010 19:21:14 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZveg-0004y3-RY for guile-devel@gnu.org; Tue, 26 Jan 2010 19:21:14 -0500 Original-Received: from [199.232.76.173] (port=60721 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZveg-0004xu-JM for guile-devel@gnu.org; Tue, 26 Jan 2010 19:21:10 -0500 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:52832 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZvea-0007R5-QX; Tue, 26 Jan 2010 19:21:05 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 9CEA1945A4; Tue, 26 Jan 2010 19:20:59 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=m0CulqhPIJ0O WsVS1dAza8ML4Gw=; b=Vmxlm9za9PxiYyLUDPsz/gnkEGB/dIv64i+a7bjChK18 bhm0CN+JP/eW14E0sAkbWxUnyU2r3274PLl77bY3LTVVf3/PPG+JwtSddxkDXkaH y9M5CnKKZVS48TBYkEKzHZWNOwvu0tLj/q3q5cy/LNdz6XisIZjvOwZ76oHhXWI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=SVKC3U atov1IB6zz3yXY64md+Ih8toZdfjZ7wCqOmBOyKcCZ7gQfsjjtsrT41Q8z4Bq8GG 1Jn3m++WwZbyC9id8BQME6Ym7SBQSbaLrFMVV/Ftov6b5mG5BFJRtyrF8f6MYqcd lX4fZ935Kj5HcK9yDDz68xYlAxaMYx+/t32AY= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 88C01945A3; Tue, 26 Jan 2010 19:20:58 -0500 (EST) Original-Received: from unquote (unknown [81.38.187.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 91D6C945A1; Tue, 26 Jan 2010 19:20:56 -0500 (EST) In-Reply-To: <87aaw08pq3.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 26 Jan 2010 23:29:24 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: D79183BC-0AD9-11DF-927E-6AF7ED7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9935 Archived-At: Yellow, On Tue 26 Jan 2010 23:29, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> By "dynamic", I mean that you don't have to write C and compile it; you >> can do everything at runtime from Scheme. You use dynamic-func and >> dynamic-link to get the raw function pointer, and make-foreign-function >> to turn that function pointer into a Scheme procedure. >> >> The interface is very low-level. Obviously declaring that an arbitrary >> symbol resolved via `dlsym' is of a certain function type is an unsafe >> operation that can lead to crashes. > > If it=E2=80=99s in a module of its own, then users will (in theory) be ab= le to > prevent its use by =E2=80=9Cuntrusted=E2=80=9D code, which would be fine. Well, yes. But anyone who has to make a sandbox should be specifying the set of bindings that are available, not the set that are restricted. But yes, I think we are in agreement hee. > One thing that would be neat is to integrate nicely with GNU=C2=A0ld=E2= =80=99s symbol > versioning (it would work around some of the safety lost by not > compiling actual C code.) For instance, one would be able to say: > > (dynamic-func "foo" lib "FOO_0.2") > > That would use dlvsym() on GNU and ignore the last argument on other > systems. (Though ideally ltdl would provide a wrapper for dlvsym). Indeed this would be neat. I think ltdl is the right place for this to go. >> I would merge it now, except for the fact that it depends on libffi. >> Libffi is very portable, and probably exists for all of Guile's >> architectures, but it is an extra dependency. Should we require libffi >> in Guile 1.9.8? Or should we build the necessary pieces conditionally? > > Well, it=E2=80=99s always annoying to add a dependency, but OTOH it was b= ound to > happen. So... let=E2=80=99s go? Wow, ok. Well yes, we did always think this was going to happen... so all right. I'll see what it takes, and merge when ready. Andy --=20 http://wingolog.org/