rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
116 stars 17 forks source link

rust-lang/libc seems to have incorrect definition for `sockaddr_in` #174

Open adryzz opened 4 months ago

adryzz commented 4 months ago

Was trying to get mio to build and run on the 3ds, using its poll backend, such that crates like reqwest and the literal thousands of libraries that depend on tokio's net feature would run, but i ran into this issue, just asking if it's to report to upstream, and if so, we should check whether other definitions are wrong, such that they can be fixed all at once:

this is sockaddr_in in rust: https://github.com/rust-lang/libc/blob/a0f5b4b21391252fe38b2df9310dc65e37b07d9f/src/unix/newlib/horizon/mod.rs#L34-L38

and this is the devkitpro definition: https://libctru.devkitpro.org/structsockaddr__in.html

    pub struct sockaddr_in {
        pub sin_family: ::sa_family_t,
        pub sin_port: ::in_port_t,
        pub sin_addr: ::in_addr,
+       pub sin_zero: [::c_char; 8],
    }
Meziu commented 4 months ago

Uhm, I thought we had accounted for those definitions already… If we can find more issues in the bindings we could push everything through with one PR, otherwise it’s fine to just merge this one change directly to libc.

FenrirWolf commented 4 months ago

There's at least one more problem that I was planning on making an issue for: libctru changed the definition for hostent some time ago, and both libc and std are using the old one still

adryzz commented 4 months ago

yeah, we should create some patches to fix libc/std all at once. i'll try checking if other definitions are wrong

adryzz commented 4 months ago

uhh one problem: i found this: https://github.com/rust-lang/libc/pull/2725, which is the PR that created this problem. how do we proceed?

edit: for more info, this branch of mio adds Horizon OS support, and doesn't build without the extra bytes

Meziu commented 4 months ago

uhh one problem: i found this: rust-lang/libc#2725, which is the PR that created this problem. how do we proceed?

Wow, i had completely forgotten about that! Do we know whether the original “faulty checks” issue is still present? I’m a bit unsure on how to tackle this problem.

Edit: we could turn off the checks in std (or make custom ones for Horizon), but that would create a bit of difference with the rest of the implementations that we’d have to maintain (would they even accept it?)