about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unsupported
AgeCommit message (Collapse)AuthorLines
2025-09-19Fix unsupported std::sys::threadThalia Archibald-1/+0
Fixes building std for any platform with an unsupported thread abstraction. This includes {aarch64,armv7,x86_64}-unknown-trusty and riscv32im-risc0-zkvm-elf, which explicitly include the unsupported module, and platforms with no PAL. Bug fix for PR 145177 (std: move thread into sys).
2025-09-12Revert "Constify SystemTime methods"Ralf Jung-11/+4
This reverts commit 7ce620dd7c6fc3371290b40a1ea28146f0d37031. The const-hacks introduces bugs, and they make the code harder to maintain. Let's wait until we can constify these functions without changing their implementation.
2025-09-08std: move `thread` into `sys` (rename only)joboet-48/+0
2025-08-26remove deprecated Error::description in implsMarijn Schouten-7/+1
2025-08-12Constify SystemTime methodsltdk-4/+11
2025-08-06Print thread ID in panic message if thread name is unknownTrevor Gross-0/+4
`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
2025-07-28thread name in stack overflow messagejoboet-1/+5
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-1/+5
Using clock nanosleep leads to more accurate sleep times on platforms where it is supported. To enable using clock_nanosleep this makes `sleep_until` platform specific. That unfortunatly requires identical placeholder implementations for the other platforms (windows/mac/wasm etc). we will land platform specific implementations for those later. See the `sleep_until` tracking issue. This requires an accessors for the Instant type. As that accessor is only used on the platforms that have clock_nanosleep it is marked as allow_unused. 32bit time_t targets do not use clock_nanosleep atm, they instead rely on the same placeholder as the other platforms. We could make them use clock_nanosleep too in the future using `__clock_nanosleep_time64`. __clock_nanosleep_time64 is documented at: https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-04-21Move `sys::pal::os::Env` into `sys::env`Thalia Archibald-41/+0
Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`.
2025-04-18Combine env consts into std::sys::env_constsThalia Archibald-10/+0
2025-04-12Move args into std::sysThalia Archibald-37/+0
2025-03-22std: move process implementations to `sys`joboet-323/+0
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-14Mv os-specific trait impl of `Pipe*` into `std::os::*`Jiahao XU-0/+51
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-09std: move stdio to `sys`joboet-60/+0
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.
2025-03-08Move fs into sysThalia Archibald-349/+0
2025-02-17Use tell for <File as Seek>::stream_positionThalia Archibald-0/+4
2025-02-07std: move `io` module out of `pal`joboet-57/+0
2025-02-02std: move network code into `sys`joboet-370/+0
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2024-11-26std: update internal uses of `io::const_error!`joboet-2/+2
2024-11-14Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviperJubilee-1/+6
Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: https://github.com/rust-lang/libs-team/issues/93 Tracking issue: #132818 Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).` Closes: #124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? libs
2024-11-09Add as_slice/into_slice for IoSlice/IoSliceMut.Alona Enraght-Moony-1/+6
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk> Co-authored-by: Nathan West <Lucretiel@gmail.com>
2024-10-13Implement file_lock featureChristopher Berner-0/+20
This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and unlock() to File gated behind the file_lock feature flag
2024-09-23std: implement the `random` featurejoboet-4/+0
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-09-19`pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool`Lieselotte-7/+4
2024-08-27std: move allocators to `sys`joboet-24/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-23Initial implementation of anonymous_pipeJiahao XU-1/+14
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com> Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com> Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-06-24Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrumbors-34/+0
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-15std: refactor the TLS implementationjoboet-34/+0
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-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-1/+1
2024-06-05Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiBJubilee Young-1/+1
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-05-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-2/+2
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-02std: move thread parking to `sys::sync`joboet-12/+0
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-4/+1
2024-04-09Fix dead code warningbjorn3-0/+1
2024-04-08Store all args in the unsupported Command implementationbjorn3-31/+118
This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.
2024-04-05Revert #121666Chris Denton-5/+1
This reverts #121666 due to #123495
2024-03-31std: move `thread::current` TLS variable out of `thread_info`joboet-10/+0
2024-03-23Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlinbors-0/+2
Replace visibility test with reachability test in dead code detection Fixes https://github.com/rust-lang/rust/issues/119545 Also included is a fix for an error now flagged by the lint
2024-03-12std: move `Once` implementations to `sys`joboet-101/+0
2024-03-12Allow dead code in sys/palArthur Carcano-0/+2
The dead_code lint was previously eroneously missing this dead code. Since this lint bug has been fixed, the unused field need to be removed or marked as `#[allow(dead_code)]`. These structures API is common to all platforms so the code cannot be removed and is hence marked allow(dead_code).
2024-03-02Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviperMatthias Krüger-1/+5
Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
2024-03-01Add `get_name` placeholder to other targetsChris Denton-1/+5
2024-02-20Delete architecture-specific memchr code in std::sysArthur Carcano-4/+0
Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in core::slice::memchr. Hence this commit deletes memchr from std::sys[_common] and replace calls to it by calls to core::slice::memchr functions. This deletes (r)memchr from the list of symbols linked to libc.
2024-02-16std: move locks to `sys` on platforms without threadsjoboet-130/+0
2024-02-15Use generic `NonZero` internally.Markus Reiter-4/+4
2024-02-08std: move path into `sys`joboet-2/+0
2024-01-25Rollup merge of #120332 - mu001999:cleanup/dead_code, r=NilstriebMatthias Krüger-3/+0
Remove unused struct Detected by #118257
2024-01-22std: move cmath into `sys`joboet-2/+0
2024-01-21Remove unused structr0cky-3/+0