From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-user@gnu.org, guile-devel@gnu.org
Subject: Re: anyone define port types?
Date: Sat, 11 Jun 2016 18:57:34 +0200 [thread overview]
Message-ID: <87fusjwtmp.fsf@pobox.com> (raw)
In-Reply-To: <871t6pe6mg.fsf@gnu.org> ("Ludovic Courtès"'s message of "Fri, 01 Apr 2016 16:38:47 +0200")
On Fri 01 Apr 2016 16:38, ludo@gnu.org (Ludovic Courtès) writes:
> Here’s 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
next prev parent reply other threads:[~2016-06-11 16:57 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-28 19:04 anyone define port types? Andy Wingo
2016-03-28 23:53 ` Matt Wette
2016-04-05 14:06 ` Mark H Weaver
2016-04-05 23:55 ` Matt Wette
2016-06-11 16:50 ` Andy Wingo
2016-03-29 7:58 ` tomas
2016-03-29 8:52 ` Nala Ginrut
2016-03-30 6:29 ` Panicz Maciej Godek
2016-03-30 11:18 ` Jan Nieuwenhuizen
2016-03-30 17:17 ` Panicz Maciej Godek
2016-03-30 17:53 ` Marko Rauhamaa
2016-03-30 19:02 ` Panicz Maciej Godek
2016-03-30 19:57 ` Marko Rauhamaa
2016-03-31 16:11 ` Barry Fishman
2016-03-31 19:28 ` Marko Rauhamaa
2016-03-30 19:43 ` Jan Wedekind
2016-03-30 20:07 ` Marko Rauhamaa
2016-03-30 21:01 ` Jan Wedekind
2016-03-30 22:44 ` Marko Rauhamaa
2016-03-31 20:42 ` Jan Wedekind
2016-03-31 22:28 ` Marko Rauhamaa
2016-06-11 16:53 ` Andy Wingo
2016-04-01 14:38 ` Ludovic Courtès
2016-06-11 16:57 ` Andy Wingo [this message]
2016-04-14 14:08 ` Ludovic Courtès
2016-06-11 17:02 ` Andy Wingo
2016-06-12 8:25 ` Chris Vine
2016-06-19 9:13 ` Andy Wingo
2016-06-19 9:55 ` Marko Rauhamaa
2016-06-19 15:27 ` Andy Wingo
2016-06-19 15:33 ` Chris Vine
2016-06-19 17:48 ` Andy Wingo
2016-06-19 20:09 ` Chris Vine
2016-06-20 3:38 ` William ML Leslie
2016-06-20 6:45 ` Chris Vine
2016-06-20 7:34 ` Andy Wingo
2016-06-20 9:01 ` Chris Vine
2016-06-22 22:44 ` Chris Vine
2016-06-23 7:36 ` Andy Wingo
2016-06-23 8:56 ` Andy Wingo
2016-06-23 9:24 ` Chris Vine
2016-06-23 9:50 ` Marko Rauhamaa
2016-06-23 10:43 ` Andy Wingo
2016-06-23 11:49 ` William ML Leslie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fusjwtmp.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=guile-user@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).