about summary refs log tree commit diff
path: root/library/std/src/sys/pal
AgeCommit message (Collapse)AuthorLines
2024-06-23wasm64 build with target-feature=+simd128,+atomicswooden-worm-10/+15
2024-06-24Rollup merge of #126854 - devnexen:std_unix_os_fallback_upd, r=Mark-SimulacrumMatthias Krüger-3/+3
std::unix::os::home_dir: fallback's optimisation. we're using a guaranteed initialised field on success.
2024-06-24Rollup merge of #126807 - devnexen:copy_file_macos_simpl, r=Mark-SimulacrumMatthias Krüger-35/+15
std::unix::fs: copy simplification for apple. since we do support from macOs Sierra, we avoid the little runtime overhead with the fclonefileat symbol check.
2024-06-23fix buildDavid Carlier-2/+1
2024-06-23std::unix::os::home_dir: fallback's optimisation.David Carlier-2/+3
we're using a guaranteed initialised field on success.
2024-06-22Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=AmanieuMatthias Krüger-9/+9
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists FCP completed in tracking issue. Tracking issue: https://github.com/rust-lang/rust/issues/83186 Closes https://github.com/rust-lang/rust/issues/83186 Stabilized API: ```rust mod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>; } ```
2024-06-22Auto merge of #124101 - the8472:pidfd-methods, r=cuviperbors-101/+199
Add PidFd::{kill, wait, try_wait} #117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: #82971
2024-06-22to extract a pidfd we must consume the childThe 8472-5/+4
As long as a pidfd is on a child it can be safely reaped. Taking it would mean the child would now have to be awaited through its pid, but could also be awaited through the pidfd. This could then suffer from a recycling race.
2024-06-22Add PidFd::{kill, wait, try_wait}The 8472-101/+200
2024-06-21std::unix::fs: copy simplification for apple.David Carlier-35/+15
since we do support from macOs Sierra, we avoid the little runtime overhead with the fclonefileat symbol check.
2024-06-20Don't perform mitigation for thread-unsafe libc::exit under Miri.Zachary S-1/+9
1. Miri's exit is thread-safe 2. Miri doesn't (yet) support `libc::gettid`, used in the implementation of the mitigation on Linux.
2024-06-20fix rustdoc URLZachary S-3/+4
2024-06-20On `target_os = "linux"`, ensure that only one Rust thread calls ↵Zachary S-0/+90
`libc::exit` or returns from `main`.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+4
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-15Rollup merge of #126229 - ChrisDenton:bindgen, r=Mark-SimulacrumGuillaume Gomez-417/+66
Bump windows-bindgen to 0.57 This PR updates our generated Windows API bindings using the latest version of `windows-bindgen`. The only change to the generated code is that `derive` is used for `Copy` and `Clone` instead of `impl`.
2024-06-15std: refactor the TLS implementationjoboet-998/+5
As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. @rustbot label +A-thread-locals
2024-06-14Auto merge of #126473 - matthiaskrgr:rollup-8w2xm09, r=matthiaskrgrbors-91/+180
Rollup of 7 pull requests Successful merges: - #123769 (Improve escaping of byte, byte str, and c str proc-macro literals) - #126054 (`E0229`: Suggest Moving Type Constraints to Type Parameter Declaration) - #126135 (add HermitOS support for vectored read/write operations) - #126266 (Unify guarantees about the default allocator) - #126285 (`UniqueRc`: support allocators and `T: ?Sized`.) - #126399 (extend the check for LLVM build) - #126426 (const validation: fix ICE on dangling ZST reference) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-14Rollup merge of #126135 - hermit-os:fuse, r=jhprattMatthias Krüger-91/+180
add HermitOS support for vectored read/write operations In general, the I/O interface of hermit-abi is revised and now a more POSIX-like interface. Consequently, platform abstraction layer for HermitOS has slightly adjusted and some inaccuracies remove. Hermit is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-06-13std::unix::fs::link using direct linkat call for Solaris and macOs.David Carlier-19/+2
Since we support solaris 11 and macOs Sierra as minimum, we can get rid of the runtime overhead.
2024-06-12Update a cranelift patch file for formatting changes.Nicholas Nethercote-2/+2
PR #125443 will reformat all the use declarations in the repo. This would break a patch kept in `rustc_codegen_cranelift` that gets applied to `library/std/src/sys/pal/windows/rand.rs`. So this commit formats the use declarations in `library/std/src/sys/pal/windows/rand.rs` in advance of #125443 and updates the patch file accordingly. The motivation is that #125443 is a huge change and we want to get fiddly little changes like this out of the way so it can be nothing more than an `x fmt --all`.
2024-06-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-9/+9
2024-06-10Bump windows-bindgen to 0.57Chris Denton-417/+66
2024-06-10fix: build on haikuSteve Lau-2/+2
2024-06-09Migrate more things to WinErrorChris Denton-30/+69
2024-06-09Rollup merge of #126168 - devnexen:current_exe_haiku_simpl, r=ChrisDentonMatthias Krüger-10/+10
std::unix::os current_exe implementation simplification for haiku. _get_net_image_info is a bit overkill as it allows to get broader informations about the process.
2024-06-08std::unix::os current_exe implementation simplification for haiku.David Carlier-10/+10
_get_net_image_info is a bit overkill as it allows to get broader informations about the process.
2024-06-08std::unix::process adding few specific freebsd signals to be able to id.David Carlier-0/+4
2024-06-08Rollup merge of #125998 - devnexen:get_mode_illumos, r=NilstriebLeón Orell Valerian Liehr-0/+4
std::unix::fs::get_mode implementation for illumos/solaris. they both support the F_GETFL fctnl flag/O_ACCMODE mask to get the file descriptor access modes.
2024-06-07add HermitOS support of vectored read/write operationsStefan Lankes-91/+180
In general, the I/O interface of hermit-abi is more POSIX-like interface. Consequently, platform abstraction layer for HermitOS has slightly adjusted and some inaccuracies remove.
2024-06-07Rollup merge of #126030 - ChrisDenton:update-wingen-readme, r=Mark-SimulacrumMatthias Krüger-1/+1
Update `./x fmt` command in library/std/src/sys/pal/windows/c/README.md `./x fmt` no longer accepts paths so the command in the readme won't work.
2024-06-05Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiBJubilee Young-4/+4
Prevent copy-paste errors from producing new starved-for-resources threaded platforms by raising `DEFAULT_MIN_STACK_SIZE` from 4096 bytes to at least 64KiB. Two platforms "affected" by this have no actual threads: - UEFI - "unsupported" Platforms that this actually affects: - wasm32-wasi with "atomics" enabled - wasm32-wasi-p1-threads Two exceptions: - SGX: a "secure code execution" platform, stays at 4096B - TEEOS: also a "secure code execution" platform, stays at 8192B I believe either of these may have sufficiently "interesting" semantics around threads, or significant external library support. Either would mean making any choices here for them is suspect.
2024-06-05Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgrbors-12/+6
Rollup of 9 pull requests Successful merges: - #124840 (resolve: mark it undetermined if single import is not has any bindings) - #125622 (Winnow private method candidates instead of assuming any candidate of the right name will apply) - #125648 (Remove unused(?) `~/rustsrc` folder from docker script) - #125672 (Add more ABI test cases to miri (RFC 3391)) - #125800 (Fix `mut` static task queue in SGX target) - #125871 (Orphanck[old solver]: Consider opaque types to never cover type parameters) - #125893 (Handle all GVN binops in a single place.) - #126008 (Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps) - #126032 (Update description of the `IsTerminal` example) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-05Rollup merge of #125800 - fortanix:raoul/rte-99-fix_mut_static_task_queue, ↵Matthias Krüger-12/+6
r=jethrogb Fix `mut` static task queue in SGX target [PR 125046](https://github.com/rust-lang/rust/pull/125046) prevents mutable references to statics with `#[linkage]`. Such a construct was used with the tests for the `x86_64-fortanix-unknown-sgx` target. This PR fixes this and cleans up code a bit in 5 steps. Each step passes CI: - The `mut` static is removed, and `Task` explicitly implements `Send` - Renaming of the `task_queue::lock` function - Pass function for `Thread` as `Send` to `Thread::imp` and update when `Packet<'scope, T>` implements `Sync` - Storing `Task::p` as a type that implements `Send` - Letting the compiler auto implement `Send` for `Task` cc: ``@jethrogb``
2024-06-05Rollup merge of #125940 - devnexen:unix_fs_netbsd_get_path, r=cuviperMatthias Krüger-9/+13
std::unix::fs::get_path: using fcntl codepath for netbsd instead. on netbsd, procfs is not as central as on linux/solaris thus can be perfectly not mounted. Thus using fcntl with F_GETPATH, the kernel deals with MAXPATHLEN internally too.
2024-06-05Update `./x fmt` commandChris Denton-1/+1
2024-06-04std::unix::fs::get_mode implementation for illumos/solaris.David Carlier-0/+4
they both support the F_GETFL fctnl flag/O_ACCMODE mask to get the file descriptor access modes.
2024-06-04Let compiler auto impl `Send` for `Task`Raoul Strackx-2/+0
2024-06-04Store `Task::p` as `dyn FnOnce() + Send`Raoul Strackx-3/+3
2024-06-04std::unix::fs::get_path: using fcntl codepath for netbsd instead.David Carlier-9/+13
on netbsd, procfs is not as central as on linux/solaris thus can be perfectly not mounted. Thus using fcntl with F_GETPATH, the kernel deals with MAXPATHLEN internally too.
2024-06-03Remove stray "this"Tobias Bucher-2/+1
2024-06-02Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboetbors-1/+10
std::pal::unix::thread fetching min stack size on netbsd. PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN returns it as it can vary from arch to another.
2024-05-30Avoid `mut` and simplify initialization of `TASK_QUEUE`Raoul Strackx-9/+5
2024-05-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-33/+29
Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions. Fixes #27970. Fixes #90308. CC #124866.
2024-05-28Disable stack overflow handler tests on iOS-like platformsMads Marquart-0/+8
2024-05-26Auto merge of #122079 - tbu-:pr_copy_file_range_probe, r=the8472bors-19/+48
Less syscalls for the `copy_file_range` probe If it's obvious from the actual syscall results themselves that the syscall is supported or unsupported, don't do an extra syscall with an invalid file descriptor. CC #122052
2024-05-26std::pal::unix::thread fetching min stack size on netbsd.David Carlier-1/+10
PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN returns it as it can vary from arch to another.
2024-05-25Rollup merge of #125271 - RalfJung:posix_memalign, r=workingjubileeMatthias Krüger-9/+7
use posix_memalign on almost all Unix targets Seems nice to be able to use a single common codepath for all of them. :) The `libc` crate says this symbol exists for all Unix targets. I did locally do check-builds to ensure this still builds, but I can't really test more than that. - For redox, I found indications posix_memalign really exists [here](https://gitlab.redox-os.org/redox-os/relibc/-/merge_requests/271) - For esp-idf, I found indications [here](https://github.com/playable-tech/esp-idf/commit/c5b297a86f3d65081bc690e81ab53db47b18d31c) - ~~For horizon and vita (these seem to be gaming console OSes? "Horizon OS" also has some hits for a Facebook product but that seems unrelated), they seem to be based on "newlib", where posix_memalign [seems to exist](https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=3ba2c39fb2a12cd7332ef16b1b3e3df994f7c6f5).~~ Turns out no, this 20-year-old standard POSIX function is unfortunately [not supported](https://github.com/rust-lang/rust/pull/125271#issuecomment-2119221419) here.
2024-05-21Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubileeMatthias Krüger-150/+127
Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS Use `_NSGetEnviron`, `_NSGetArgc` and `_NSGetArgv` on iOS/tvOS/watchOS/visionOS, see each commit and the code comments for details. This allows us to unify more code with the macOS implementation, as well as avoiding linking to the `Foundation` framework (which is good for startup performance). The biggest problem with doing this would be if it lead to App Store rejections. After doing a bunch of research on this, while [it did happen once in 2009](https://blog.unity.com/engine-platform/unity-app-store-submissions-problem-solved), I find it fairly unlikely to happen nowadays, especially considering that Apple has later _added_ `crt_externs.h` to the iOS/tvOS/watchOS/visionOS SDKs, strongly signifying the functions therein is indeed supported on those platforms (even though they lack an availability attribute). That we've been overly cautious here has also been noted by `@thomcc` in https://github.com/rust-lang/rust/pull/117910#issuecomment-1903372350. r? `@workingjubilee` `@rustbot` label O-apple
2024-05-20switch also the default implementation for read_vectoredStefan Lankes-13/+2
2024-05-20switch to the default implementation of `write_vectored`Stefan Lankes-8/+2