about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-07-01Remove unqualified import io:: Error for vxworks as all Error references are ↵B I Mohammed Abbas-1/+1
qualified in process_vxworks.rs
2024-06-29Rollup merge of #126953 - joboet:lazy_key, r=jhprattMatthias Krüger-128/+115
std: separate TLS key creation from TLS access Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses. Related to #110897.
2024-06-28std: add safety commentsjoboet-4/+16
2024-06-25std: separate TLS key creation from TLS accessjoboet-125/+100
Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses.
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-8/+23
#126333
2024-06-25inner truncate methods for UEFI platformsash-0/+5
2024-06-25Check that we get somewhat sane PIDs when spawning with pidfdsThe 8472-0/+3
2024-06-25more fine-grained feature-detection for pidfd spawningThe 8472-21/+33
we now distinguish between pidfd_spawn support, pidfd-via-fork/exec and not-supported
2024-06-25document safety properties of the internal Process::new constructorThe 8472-0/+6
2024-06-25use pidfd_spawn for faster process creation when pidfds are requestedThe 8472-6/+106
2024-06-25document the cvt methodsThe 8472-0/+4
2024-06-24Rollup merge of #125082 - kpreid:const-uninit, r=dtolnayMichael Goulet-1/+1
Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks. \[This PR originally contained the changes in #125995 too. See edit history for the original PR description.] The documentation of `MaybeUninit::uninit_array()` says: > Note: in a future Rust version this method may become unnecessary when Rust allows [inline const expressions](https://github.com/rust-lang/rust/issues/76001). The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`. The PR adding it also said: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a standard library method that will be replaceable with `let buffer = [MaybeUninit::<T>::uninit(); $N];` That time has come to pass — inline const expressions are stable — so `MaybeUninit::uninit_array()` is now unnecessary. The only remaining question is whether it is an important enough *convenience* to keep it around. I believe it is net good to remove this function, on the principle that it is better to compose two orthogonal features (`MaybeUninit` and array construction) than to have a specific function for the specific combination, now that that is possible.
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-1/+1
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-06-24Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrumbors-774/+835
std: refactor the TLS implementation 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-24std: fix wasm buildsjoboet-2/+16
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/+7
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-20Convert some module-level `//` and `///` comments to `//!`.Nicholas Nethercote-2/+3
This makes their intent and expected location clearer. We see some examples where these comments were not clearly separate from `use` declarations, which made it hard to understand what the comment is describing.
2024-06-17std: rename module for clarityjoboet-2/+2
2024-06-17std: update TLS module documentationjoboet-16/+22
2024-06-17std: use the `c_int` from `core::ffi` instead of `libc`joboet-1/+1
2024-06-17std: simplify `#[cfg]`s for TLSjoboet-15/+10
2024-06-16std: move `sys_common::backtrace` to `sys`joboet-0/+228
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-774/+820
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-09Rollup merge of #126146 - devnexen:signal_fbsd, r=ChrisDentonMatthias Krüger-0/+4
std::unix::process adding few specific freebsd signals to be able to id.
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-08Auto merge of #125966 - schvv31n:impl_os_string_pathbuf_leak, r=workingjubileebors-0/+10
Implement `os_string_pathbuf_leak` implementation of #125965 ACP: https://github.com/rust-lang/libs-team/issues/389 [ Accepted ]
2024-06-08std::unix::process adding few specific freebsd signals to be able to id.David Carlier-0/+4