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,gmane.lisp.guile.user Subject: Re: anyone define port types? Date: Sat, 11 Jun 2016 18:57:34 +0200 Message-ID: <87fusjwtmp.fsf@pobox.com> References: <87y492mnjp.fsf@pobox.com> <871t6pe6mg.fsf@gnu.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 1465664305 5534 80.91.229.3 (11 Jun 2016 16:58:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Jun 2016 16:58:25 +0000 (UTC) Cc: guile-user@gnu.org, 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 Sat Jun 11 18:58:14 2016 Return-path: Envelope-to: guile-devel@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 1bBmEf-0003i0-S4 for guile-devel@m.gmane.org; Sat, 11 Jun 2016 18:58:14 +0200 Original-Received: from localhost ([::1]:47833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBmEf-0002Yb-6C for guile-devel@m.gmane.org; Sat, 11 Jun 2016 12:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBmEI-0002YU-Vq for guile-devel@gnu.org; Sat, 11 Jun 2016 12:57:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBmEE-00026z-QY for guile-devel@gnu.org; Sat, 11 Jun 2016 12:57:49 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:51923 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBmEE-00026u-Lj; Sat, 11 Jun 2016 12:57:46 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id E712120EDA; Sat, 11 Jun 2016 12:57:44 -0400 (EDT) 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=1/UTAJRjiwTm 8BaMjUF4NqsLq6s=; b=rUvmv+wP862cgXWUradHMFMhafS+SgZ0dB6Dwm7CrgPE cG9NDmx6JTb8hKiwy7PK02RBN/u7CpBra1ofFChHgwl4SZA6mRiZycYHgarGoywS No23BdjpTRJzEGwSTmDP9p8ys+TibHuUp6tthTwjF6vz6MVIMmmuBO/cCERmPuM= 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=svc/EC lZYz3n/+B/7vmydq3rUvsn8sk53gZ27ZGZTYkHrdEoS7k00d/NPGXIbxQ7osbc/B Oz2XUZsx+oEw7R4XjehTaAJ5lXpJgEezVQkdwwLy1VZjt5J5GBxJVipwMPEYO4hW 3DSD5eG3oOU26CWti1Cl2+Z6j0ArFQyxrDlkc= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id E03AE20ED7; Sat, 11 Jun 2016 12:57:44 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id D9FB120ED6; Sat, 11 Jun 2016 12:57:42 -0400 (EDT) In-Reply-To: <871t6pe6mg.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Fri, 01 Apr 2016 16:38:47 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 9DD5D1DA-2FF5-11E6-9710-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.108.67 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18341 gmane.lisp.guile.user:12626 Archived-At: On Fri 01 Apr 2016 16:38, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Here=E2=80=99s a port type! :-) > > https://gitlab.com/gnutls/gnutls/blob/master/guile/src/core.c#L785 Thanks! So port types written in C will have to change unfortunately :/ From NEWS: ** Complete overhaul of port internals Guile's ports have been completely overhauled to allow Guile developers and eventually Guile users to write low-level input and output routines in Scheme. The new internals will eventually allow for user-space tasklets or green threads that suspend to a scheduler when they would cause blocking I/O, allowing users to write straightforward network services that parse their input and send their output as if it were blocking, while under the hood Guile can multiplex many active connections at once. At the same time, this change makes Guile's ports implementation much more maintainable, rationalizing the many legacy port internals and making sure that the abstractions between the user, Guile's core ports facility, and the port implementations result in a system that is as performant and expressive as possible. The interface to the user has no significant change, neither on the C side nor on the Scheme side. However this refactoring has changed the interface to the port implementor in an incompatible way. See below for full details. And later: ** API to define new port types from C has changed See the newly expanded "I/O Extensions" in the manual, for full details. Notably: *** Remove `scm_set_port_mark' Port mark functions have not been called since the switch to the BDW garbage collector. *** Remove `scm_set_port_equalp' Likewise port equal functions weren't being called. Given that ports have their own internal buffers, it doesn't make sense to hook them into equal? anyway. *** Remove `scm_set_port_free' It used to be that if an open port became unreachable, a special "free" function would be called instead of the "close" function. Now that the BDW-GC collector allows us to run arbitrary code in finalizers, we can simplify to just call "close" on the port and remove the separate free functions. Note that hooking into the garbage collector has some overhead. For that reason Guile exposes a new interface, `scm_set_port_needs_close_on_gc', allowing port implementations to indicate to Guile whether they need closing on GC or not. *** Remove `scm_set_port_end_input', `scm_set_port_flush' As buffering is handled by Guile itself, these functions which were to manage an implementation-side buffer are no longer needed. *** Change prototype of `scm_make_port_type' The `read' (renamed from `fill_input') and `write' functions now operate on bytevectors. Also the `mode_bits' argument now inplicitly includes SCM_OPN, so you don't need to include these. *** Change prototype of port `close' function The port close function now returns void. *** Port and port type data structures are now opaque Port type implementations should now use API to access port state. However, since the change to handle port buffering centrally, port type implementations rarely need to access unrelated port state. *** Port types are now `scm_t_port_type*', not a tc16 value `scm_make_port_type' now returns an opaque pointer, not a tc16. Relatedly, the limitation that there only be 256 port types has been lifted. Now. How to adapt? You can do the #if thing with versions. Or, maybe we should flesh out the custom binary input/output port support so that you can implement a GnuTLS port in Scheme. WDYT? Andy