diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2025-08-23 22:22:15 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-23 22:22:15 +0200 | 
| commit | 982b022b1e713ddff01071bd0538329b279c788b (patch) | |
| tree | 154e94ef9ec38f3ee47409265e598ff8ced9f3ab /compiler/rustc_pattern_analysis | |
| parent | f5210f2ba0f6f76f302445a454d50ebdedfceef2 (diff) | |
| parent | a6f266612a42737ee46b69645244975e75406b60 (diff) | |
| download | rust-982b022b1e713ddff01071bd0538329b279c788b.tar.gz rust-982b022b1e713ddff01071bd0538329b279c788b.zip | |
Rollup merge of #144452 - morinmorin:apple/update_read_limit, r=ChrisDenton
std/sys/fd: Relax `READ_LIMIT` on Darwin
Darwin's `read`/`write` syscalls emit `EINVAL` only when `nbyte > INT_MAX`. The case `nbyte == INT_MAX` is valid, so the subtraction (`- 1`) in
```rust
const READ_LIMIT: usize = if cfg!(target_vendor = "apple") {
    libc::c_int::MAX as usize - 1 // <- HERE
} else {
    libc::ssize_t::MAX as usize
};
```
can be removed.
I tested that the case `nbyte == INT_MAX` is valid on various versions of macOS, including old one like Mac OS X 10.5.
The man page says:
- read() and pread() will fail if the parameter nbyte exceeds INT_MAX (link: https://keith.github.io/xcode-man-pages/read.2.html)
- write() and pwrite() will fail if the parameter nbyte exceeds INT_MAX (link: https://keith.github.io/xcode-man-pages/write.2.html)
Here are links to Darwin's code:
- [macOS 15.5] https://github.com/apple-oss-distributions/xnu/blob/e3723e1f17661b24996789d8afc084c0c3303b26/bsd/kern/sys_generic.c#L307
- [Mac OS X 10.2] https://github.com/apple/darwin-xnu/blob/d738f900846ed2d5f685e18bf85ce63b0176f61a/bsd/kern/sys_generic.c#L220
Related PR: rust-lang/rust#38622.
Diffstat (limited to 'compiler/rustc_pattern_analysis')
0 files changed, 0 insertions, 0 deletions
