hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 015f00c39c5a82378034c491b213b568e7a22a48
parent 52df69f9980d438fa44509dd5d679453fcdeec45
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 20 Oct 2021 12:01:01 +0200

iobus: fill out ... files_update struct

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/iobus/main.ha | 15+++++++++++++--
Miobus/io_uring/bus.ha | 1+
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/cmd/iobus/main.ha b/cmd/iobus/main.ha @@ -6,6 +6,11 @@ use os; use strings; use unix::poll; +type state = struct { + mainbus: *iobus::bus, + userbus: *iobus::bus, +}; + export fn main() void = { let mainbus = iobus::new()!; defer iobus::destroy(mainbus); @@ -16,6 +21,7 @@ export fn main() void = { defer io::close(userfd); const in = iobus::register_file(mainbus, os::stdin_file); + // XXX: This seems to break polling? possible kernel bug //const userfd = iobus::register_file(mainbus, userfd); let pollin = iobus::poll(mainbus, in, poll::event::POLLIN)!; @@ -28,13 +34,18 @@ export fn main() void = { strings::toutf8("hi!\n"), 0)!; iobus::submit(userbus, &write)!; + let state = state { + mainbus = mainbus, + userbus = userbus, + }; + for (true) { const res = iobus::dispatch(mainbus)!; defer iobus::done(mainbus, res); if (iobus::handleof(res) == &pollin) { iobus::endpoll(mainbus, res)!; - if (!readcmd(mainbus)) { + if (!readcmd(&state)) { fmt::errorln("exit")!; break; }; @@ -56,7 +67,7 @@ export fn main() void = { }; }; -fn readcmd(bus: *iobus::bus) bool = { +fn readcmd(state: *state) bool = { const line = match (bufio::scanline(os::stdin)!) { case line: []u8 => yield strings::fromutf8(line); diff --git a/iobus/io_uring/bus.ha b/iobus/io_uring/bus.ha @@ -106,6 +106,7 @@ export fn register_file(bus: *bus, file: io::file) registered_file = { io_uring::files_update { offs = bus.lastfd: u32, fds = &bus.fdset[bus.lastfd], + ... }, ]; bus.fdset[bus.lastfd] = file;