Repository navigation
host_env: export O_* flags, wasm errno, and posix names #8788
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fa2551e
host_env: export O_* flags and wasm errno
youknowone d3a812b
stdlib: take O_* open flags from host_env
youknowone 8f7178e
host_env: export remaining posix integer names
youknowone 29dcad8
stdlib: take remaining posix names from host_env
youknowone d7be5ed
host_env: define AT_EACCESS on Android
youknowone a22f50c
vm: gate stop_bit_set to tests
youknowone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,86 @@ | ||
| //! Errno numbers for `wasm32-unknown-unknown`. | ||
| //! | ||
| //! There is no libc errno table. The values are the Linux ABI the stdlib | ||
| //! and `OSError` subclasses match against. | ||
| //! There is no libc errno table. The values are the Darwin/BSD numbers the | ||
| //! guest `O_*` flags and `OSError` subclasses match against. | ||
|
|
||
| #[must_use] | ||
| pub fn strerror_string(errno: i32) -> Option<String> { | ||
| errors::strerror(errno).map(str::to_owned) | ||
| } | ||
|
|
||
| pub mod errors { | ||
| pub const EAGAIN: i32 = 11; | ||
| pub const ECONNABORTED: i32 = 103; | ||
| pub const ECONNRESET: i32 = 104; | ||
| pub const EPERM: i32 = 1; | ||
| pub const ENOENT: i32 = 2; | ||
| pub const ESRCH: i32 = 3; | ||
| pub const EINTR: i32 = 4; | ||
| pub const EIO: i32 = 5; | ||
| pub const EBADF: i32 = 9; | ||
| pub const ECHILD: i32 = 10; | ||
| pub const EAGAIN: i32 = 35; | ||
| pub const EWOULDBLOCK: i32 = 35; | ||
| pub const EINPROGRESS: i32 = 36; | ||
| pub const EALREADY: i32 = 37; | ||
| pub const EPIPE: i32 = 32; | ||
| pub const ENOTDIR: i32 = 20; | ||
| pub const EISDIR: i32 = 21; | ||
| pub const EINVAL: i32 = 22; | ||
| pub const EMFILE: i32 = 24; | ||
| pub const ESPIPE: i32 = 29; | ||
| pub const EROFS: i32 = 30; | ||
| pub const EACCES: i32 = 13; | ||
| pub const EEXIST: i32 = 17; | ||
| pub const ENOTSUP: i32 = 45; | ||
| pub const EAFNOSUPPORT: i32 = 47; | ||
| pub const ECONNABORTED: i32 = 53; | ||
| pub const ECONNRESET: i32 = 54; | ||
| pub const ESHUTDOWN: i32 = 58; | ||
| pub const ETIMEDOUT: i32 = 60; | ||
| pub const ECONNREFUSED: i32 = 61; | ||
|
|
||
| pub fn strerror(errno: i32) -> Option<&'static str> { | ||
| Some(match errno { | ||
| EPERM => "Operation not permitted", | ||
| ENOENT => "No such file or directory", | ||
| ESRCH => "No such process", | ||
| EIO => "Input/output error", | ||
| EINTR => "Interrupted system call", | ||
| ECHILD => "No child processes", | ||
| EACCES => "Permission denied", | ||
| EEXIST => "File exists", | ||
| ENOTDIR => "Not a directory", | ||
| EISDIR => "Is a directory", | ||
| EPIPE => "Broken pipe", | ||
| EAGAIN => "Resource temporarily unavailable", | ||
| EINPROGRESS => "Operation now in progress", | ||
| EALREADY => "Operation already in progress", | ||
| ENOTSUP => "Operation not supported", | ||
| EAFNOSUPPORT => "Address family not supported by protocol", | ||
| ECONNABORTED => "Software caused connection abort", | ||
| ECONNRESET => "Connection reset by peer", | ||
| ETIMEDOUT => "Operation timed out", | ||
| ECONNREFUSED => "Connection refused", | ||
| EBADF => "Bad file descriptor", | ||
| EINVAL => "Invalid argument", | ||
| EMFILE => "Too many open files", | ||
| ESPIPE => "Illegal seek", | ||
| EROFS => "Read-only file system", | ||
| ESHUTDOWN => "Can't send after socket shutdown", | ||
| _ => return None, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::errors; | ||
|
|
||
| #[test] | ||
| fn eagain_is_darwin() { | ||
| assert_eq!(errors::EAGAIN, 35); | ||
| assert_eq!(errors::EWOULDBLOCK, 35); | ||
| assert_eq!( | ||
| errors::strerror(errors::EAGAIN), | ||
| Some("Resource temporarily unavailable") | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 10518
Populate the wasm
errnotable.On
wasm32-unknown-unknown,errno.module_execexports onlyERROR_CODES, but the fallback table is empty. Therefore, reachable Python code such asimport errno; errno.EAGAINcan raiseAttributeError, despiteerrors::EAGAINbeing defined as35.Suggested fix
🤖 Prompt for AI Agents