Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change WASI's RawFd from u32 to c_int (i32). #88012

Merged
merged 1 commit into from
Aug 19, 2021

Commits on Aug 13, 2021

  1. Change WASI's RawFd from u32 to c_int (i32).

    WASI previously used `u32` as its `RawFd` type, since its "file descriptors"
    are unsigned table indices, and there's no fundamental reason why WASI can't
    have more than 2^31 handles.
    
    However, this creates myriad little incompability problems with code
    that also supports Unix platforms, where `RawFd` is `c_int`. While WASI
    isn't a Unix, it often shares code with Unix, and this difference made
    such shared code inconvenient. rust-lang#87329 is the most recent example of such
    code.
    
    So, switch WASI to use `c_int`, which is `i32`. This will mean that code
    intending to support WASI should ideally avoid assuming that negative file
    descriptors are invalid, even though POSIX itself says that file descriptors
    are never negative.
    
    This is a breaking change, but `RawFd` is considerd an experimental
    feature in [the documentation].
    
    [the documentation]: https://doc.rust-lang.org/stable/std/os/wasi/io/type.RawFd.html
    sunfishcode committed Aug 13, 2021
    Configuration menu
    Copy the full SHA
    35de5c9 View commit details
    Browse the repository at this point in the history