Skip to content

zig v0.16 iocalypse conundrum #17

Description

@stef

tried to port this to zig v0.16

but i am stuck with these two lines:

https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L699

const read_result = input.read(buf[0..len]) catch return -1;

https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L707

const write_result = output.write(buf[0..len]) catch return -1;

in zig v0.16

input and output are both Io.net.Socket instances in the
functions sockRead() and sockWrite() respectively. These functions
are called from inside the bearssl c code, to get data from/to the
socket. Now with the IOcalypse, sockets have their function names
changed from read/write to receive/send and - here's my blocking issue

  • they now demand an std.Io parameter.

i came up with two ugly workarounds:

  1. add a global std.Io variable in this module which gets set when calling Stream.init().
    i suspect this might mess with multithreading?

  2. just use the .handle variable of the socket, and directly call
    posix.system.(write|read)(socket.handle, buf[0..], buf.len)

    which eliminates some portability i suppose?

i'm gonna go for 2. but feel bad about it. maybe you have a better solution?

i'll open a PR as soon as i have a working port to 0.16, up to you if you accept my ugly workaround or maybe you teach me something better :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions