about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2025-01-28uefi: process: Fix argsAyush Singh-4/+3
- While working on process env support, I found that args were currently broken. Not sure how I missed it in the PR, but well here is the fix. - Additionally, no point in adding space at the end of args. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-26Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhprattbors-10/+3
Rollup of 7 pull requests Successful merges: - #133631 (Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only)) - #134358 (compiler: Set `target_abi = "ilp32e"` on all riscv32e targets) - #135812 (Fix GDB `OsString` provider on Windows ) - #135842 (TRPL: more backward-compatible Edition changes) - #135946 (Remove extra whitespace from rustdoc breadcrumbs for copypasting) - #135953 (ci.py: check the return code in `run-local`) - #136019 (Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-26Rollup merge of #133631 - flba-eb:add_nto_qnx71_iosock_support, r=workingjubileeJacob Pratt-10/+3
Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only) Changes of this pull request: 1. Refactor code for qnx nto targets to share more code in file `nto_qnx.rs` 1. Add support for an additional network stack on nto qnx 7.1. QNX 7.1 supports two network stacks: 1. `io-pkt`, which is default 2. `io-sock`, which is optional on 7.1 but default in QNX 8.0 As one can see in the [io-sock migration notes](https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html), this changes the libc API in a way similar to e.g. linux-gnu vs. linux-musl. This change adds a new target which has a different value for `target_env`, so that e.g. libc can distinguish between both APIs. 2. Add initial support for QNX 8.0, thanks to AkhilTThomas. As it turned out, the problem with forking many processes still exists in QNX 8.0. Because if this, we are now using it for any QNX version (i.e. not check for `target_env` anymore).
2025-01-25Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-SimulacrumJacob Pratt-5/+4
Update emscripten std tests This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten. Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-24Fix set_name in thread mod for NuttXHuang Qi-3/+8
Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function, this change aligns the implementation with the correct API available on NuttX This patch ensures thread naming works correctly on NuttX platforms. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-24add nto80 x86-64 and aarch64 targetAkhilTThomas-11/+3
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24Add new target for supporting Neutrino QNX 6.1 with `io-socket` network ↵Florian Bartels-3/+4
stack on aarch64 Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24Update a bunch of comments from before wasi support was addedbjorn3-5/+4
2025-01-21Remove test panic from File::openChris Denton-3/+0
2025-01-18Fix import of pipe in kernel_copy.rsJiahao XU-3/+2
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-17Move `std::pipe::*` into `std::io`Jiahao XU-6/+4
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-15Rollup merge of #132654 - joboet:lazy_main, r=ChrisDentonGuillaume Gomez-8/+9
std: lazily allocate the main thread handle https://github.com/rust-lang/rust/pull/123550 eliminated the allocation of the main thread handle, but at the cost of greatly increased complexity. This PR proposes another approach: Instead of creating the main thread handle itself, the runtime simply remembers the thread ID of the main thread. The main thread handle is then only allocated when it is used, using the same lazy-initialization mechanism as for non-runtime use of `thread::current`, and the `name` method uses the thread ID to identify the main thread handle and return the correct name ("main") for it. Thereby, we also allow accessing `thread::current` before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from `name` will only be "main" after the runtime initialization code has run, but I think that is acceptable. This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms). Reverts #123550, CC ``@GnomedDev``
2025-01-14Update ReadDir::next in std::sys::pal::unix::fs to use `&raw const ↵Zachary S-23/+13
(*ptr).field` instead of `ptr.offset(...).cast()`. Also, the macro is only called three times, and all with the same local variable entry_ptr, so just use the local variable directly, and rename the macro to entry_field_ptr.
2025-01-14std: lazily allocate the main thread handlejoboet-8/+9
Thereby, we also allow accessing thread::current before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from name will only be "main" after the runtime initialization code has run, but I think that is acceptable. This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms).
2025-01-14Auto merge of #135465 - jhpratt:rollup-7p93bct, r=jhprattbors-7/+16
Rollup of 10 pull requests Successful merges: - #134498 (Fix cycle error only occurring with -Zdump-mir) - #134977 (Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion) - #135390 (Re-added regression test for #122638) - #135393 (uefi: helpers: Introduce OwnedDevicePath) - #135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - #135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - #135444 (Update books) - #135450 (Fix emscripten-wasm-eh with unwind=abort) - #135452 (bootstrap: fix outdated feature name in comment) - #135454 (llvm: Allow sized-word rather than ymmword in tests) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-13Rollup merge of #135393 - Ayush1325:uefi-helper-path, r=thomccJacob Pratt-7/+16
uefi: helpers: Introduce OwnedDevicePath This PR is split off from #135368 to reduce noise. No real functionality changes, just some quality of life improvements. Also implement Debug for OwnedDevicePath for some quality of life improvements.
2025-01-13uefi: helpers: Introduce OwnedDevicePathAyush Singh-7/+16
This PR is split off from #135368 to reduce noise. Rename DevicePath to OwnedDevicePath. This is to allow a non-owning version of DevicePath in the future to work with UEFI shell APIs which provide const pointers to device paths for UEFI shell fs mapping. Also implement Debug for OwnedDevicePath for some quality of life improvements. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-13Rollup merge of #135405 - Ayush1325:path-is-absolute, r=tgross35Matthias Krüger-0/+23
path: Move is_absolute check to sys::path I am working on fs support for UEFI [0], which similar to windows has prefix components, but is not quite same as Windows. It also seems that Prefix is tied closely to Windows and cannot really be extended [1]. This PR just tries to remove coupling between Prefix and absolute path checking to allow platforms to provide there own implementation to check if a path is absolute or not. I am not sure if any platform other than windows currently uses Prefix, so I have kept the path.prefix().is_some() check in most cases. [0]: https://github.com/rust-lang/rust/pull/135368 [1]: https://github.com/rust-lang/rust/issues/52331#issuecomment-2492796137
2025-01-13path: Move is_absolute check to sys::pathAyush Singh-0/+23
I am working on fs support for UEFI [0], which similar to windows has prefix components, but is not quite same as Windows. It also seems that Prefix is tied closely to Windows and cannot really be extended [1]. This PR just tries to remove coupling between Prefix and absolute path checking to allow platforms to provide there own implementation to check if a path is absolute or not. I am not sure if any platform other than windows currently uses Prefix, so I have kept the path.prefix().is_some() check in most cases. [0]: https://github.com/rust-lang/rust/pull/135368 [1]: https://github.com/rust-lang/rust/issues/52331#issuecomment-2492796137 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-4/+4
2025-01-11Rollup merge of #135324 - Ayush1325:uefi-fs-unsupported, r=joboetJacob Pratt-1/+344
Initial fs module for uefi - Just a copy of unsupported fs right now to reduce the noise from future PRs to allow for easier review. - For the full working version of fs on uefi, see [0] - This is an effort to break the original PR (#129700) into much smaller chunks for faster upstreaming. [0]: https://github.com/Ayush1325/rust/tree/uefi-file-full
2025-01-11Rollup merge of #135236 - scottmcm:more-mcp807-library-updates, r=ChrisDentonJacob Pratt-25/+22
Update a bunch of library types for MCP807 This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types. r? ghost
2025-01-10Rollup merge of #132607 - YohDeadfall:pthread-name-fn-with-result, r=tgross35Jacob Pratt-11/+13
Used pthread name functions returning result for FreeBSD and DragonFly `pthread_getname_np` and `pthread_setname_np` received a wider adoption in past years and was added to: * FreeBSD by June 11 2020 via [`2ef84b7da9a6c3e23b4a135e6e863581f16d46e1`](https://github.com/freebsd/freebsd-src/commit/2ef84b7da9a6c3e23b4a135e6e863581f16d46e1), * DargonFly by March 8 2021 via [`ab5dc9aceb34419d1c4b6006739e61acee8ee999`](https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ab5dc9aceb34419d1c4b6006739e61acee8ee999). There's not so much advantage except that the result can be checked in debug builds. Ideally it should be unified with Linux' implementation, but it trims the input.
2025-01-09Update a bunch of library types for MCP807Scott McMurray-25/+22
This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
2025-01-10Initial fs module for uefiAyush Singh-1/+344
- Just a copy of unsupported fs right now to reduce the noise from future PRs to allow for easier review. - For the full working version of fs on uefi, see [0] [0]: https://github.com/Ayush1325/rust/tree/uefi-file-full Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-09Used pthread name functions returning result for FreeBSD and DragonFlyYoh Deadfall-11/+13
2025-01-08Rollup merge of #134389 - rust-wasi-web:condvar-no-threads, r=m-ou-seJacob Pratt-2/+4
Condvar: implement wait_timeout for targets without threads This always falls back to sleeping since there is no way to notify a condvar on a target without threads. Even on a target that has no threads the following code is a legitimate use case: ```rust use std::sync::{Condvar, Mutex}; use std::time::Duration; fn main() { let cv = Condvar::new(); let mutex = Mutex::new(()); let mut guard = mutex.lock().unwrap(); cv.notify_one(); let res; (guard, res) = cv.wait_timeout(guard, Duration::from_secs(3)).unwrap(); assert!(res.timed_out()); } ```
2025-01-07Avoid naming variables `str`Josh Triplett-3/+3
This renames variables named `str` to other names, to make sure `str` always refers to a type. It's confusing to read code where `str` (or another standard type name) is used as an identifier. It also produces misleading syntax highlighting.
2025-01-04Rollup merge of #134996 - bdbai:uwp-support, r=jieyouxu,ChrisDentonJubilee-2/+3
Add UWP (msvc) target support page - Added Platform Support page for `x86_64-uwp-windows-msvc`, `i686-uwp-windows-msvc`, `thumbv7a-uwp-windows-msvc` and `aarch64-uwp-windows-msvc` - Adding myself as a maintainer - Removing the ticks for `thumbv7a-pc-windows-msvc` and `thumbv7a-uwp-windows-msvc` as they do not currently build due to #134565 and https://github.com/rust-lang/backtrace-rs/pull/685 - Fixed a few minor issues to let most of the UWP targets compile - Happy new year to all! r? jieyouxu
2025-01-03Rollup merge of #133420 - thesummer:rtems-unwind, r=workingjubileeMatthias Krüger-1/+1
Switch rtems target to panic unwind Switch the RTEMS target to `panic_unwind`. Relates to https://github.com/rust-lang/backtrace-rs/pull/682
2025-01-03Auto merge of #134692 - GrigorenkoPV:sync_poision, r=tgross35bors-3/+3
Move some things to `std::sync::poison` and reexport them in `std::sync` Tracking issue: #134646 r? `@tgross35` I've used `sync_poison_mod` feature flag instead, because `sync_poison` had already been used back in 1.2. try-job: x86_64-msvc
2025-01-03Fix UWP buildbdbai-2/+3
2025-01-02Move some things to `std::sync::poison` and reexport them in `std::sync`Pavel Grigorenko-3/+3
2025-01-01std::fs::DirEntry.metadata(): prefer use of lstat() on EmscriptenKleis Auke Wolthuizen-8/+1
Align it with musl, which also prefers using lstat() here.
2025-01-01Avoid use of LFS64 symbols on EmscriptenKleis Auke Wolthuizen-6/+1
Since Emscripten uses musl libc internally. Non-functional change: all LFS64 symbols were aliased to their non-LFS64 counterparts in rust-lang/libc@7c952dceaad4cdc35e00884fcb12a713d41a87e0.
2024-12-28Auto merge of #134547 - SUPERCILEX:unify-copy, r=thomccbors-24/+70
Unify fs::copy and io::copy on Linux Currently, `fs::copy` first tries a regular file copy (via copy_file_range) and then falls back to userspace read/write copying. We should use `io::copy` instead as it tries copy_file_range, sendfile, and splice before falling back to userspace copying. This was discovered here: https://github.com/SUPERCILEX/fuc/issues/40 Perf impact: `fs::copy` will now have two additional statx calls to decide which syscall to use. I wonder if we should get rid of the statx calls and only continue down the next fallback when the relevant syscalls say the FD isn't supported.
2024-12-27Auto merge of #134822 - jieyouxu:rollup-5xuaq82, r=jieyouxubors-2/+27
Rollup of 8 pull requests Successful merges: - #134606 (ptr::copy: fix docs for the overlapping case) - #134622 (Windows: Use WriteFile to write to a UTF-8 console) - #134759 (compiletest: Remove the `-test` suffix from normalize directives) - #134787 (Spruce up the docs of several queries related to the type/trait system and const eval) - #134806 (rustdoc: use shorter paths as preferred canonical paths) - #134815 (Sort triples by name in platform_support.md) - #134816 (tools: fix build failure caused by PR #134420) - #134819 (Fix mistake in windows file open) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-27Rollup merge of #134819 - ChrisDenton:trunc, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-1/+1
Fix mistake in windows file open In #134722 this should have been `c::FileAllocationInfo` not `c::FileEndOfFileInfo`. Oops.
2024-12-27Rollup merge of #134622 - ChrisDenton:write-file-utf8, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-1/+26
Windows: Use WriteFile to write to a UTF-8 console If the console code page is UTF-8 then we can simply write to it without needing to convert to UTF-16 and calling `WriteConsole`.
2024-12-27Auto merge of #134786 - ChrisDenton:fix-rename-symlink, r=tgross35bors-7/+10
Fix renaming symlinks on Windows Previously we only detected mount points and not other types of links when determining reparse point behaviour. Also added some tests to avoid this regressing again in the future.
2024-12-27Fix renaming symlinks on WindowsChris Denton-7/+10
Previously we only detected mount points and not other types of links when determining reparse point behaviour.
2024-12-27Fix mistake in windows file openChris Denton-1/+1
2024-12-26Rollup merge of #134649 - SUPERCILEX:statx-remember, r=thomccJacob Pratt-1/+5
Fix forgetting to save statx availability on success Looks like we forgot to save the statx state on success which means the first failure (common when checking if a file exists) will always require spending an invalid statx to confirm the failure is real. r? `@thomcc`
2024-12-24Fix compilation issues on other unixesAlex Saveau-44/+53
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-24Windows: Use FILE_ALLOCATION_INFO for truncationChris Denton-8/+20
But fallback to FILE_END_OF_FILE_INFO for WINE
2024-12-21Fix forgetting to save statx availability on successAlex Saveau-1/+5
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-21Eliminate redundant statx syscallsAlex Saveau-9/+64
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-21Rollup merge of #131072 - Fulgen301:windows-rename-posix-semantics, ↵Matthias Krüger-1/+153
r=ChrisDenton Win: Use POSIX rename semantics for `std::fs::rename` if available Windows 10 1601 introduced `FileRenameInfoEx` as well as `FILE_RENAME_FLAG_POSIX_SEMANTICS`, allowing for atomic renaming and renaming if the target file is has already been opened with `FILE_SHARE_DELETE`, in which case the file gets renamed on disk while the open file handle still refers to the old file, just like in POSIX. This resolves #123985, where atomic renaming proved difficult to impossible due to race conditions. If `FileRenameInfoEx` isn't available due to missing support from the underlying filesystem or missing OS support, the renaming is retried with `FileRenameInfo`, which matches the behavior of `MoveFileEx`. This PR also manually replicates parts of `MoveFileEx`'s internal logic, as reverse-engineered from the disassembly: If the source file is a reparse point and said reparse point is a mount point, the mount point itself gets renamed; otherwise the reparse point is resolved and the result renamed. Notes: - Currently, the `win7` target doesn't bother with `FileRenameInfoEx` at all; it's probably desirable to remove that special casing and try `FileRenameInfoEx` anyway if it doesn't exist, in case the binary is run on newer OS versions. Fixes #123985
2024-12-21Unify fs::copy and io::copyAlex Saveau-19/+1
2024-12-21Windows: Use WriteFile to write to a UTF-8 consoleChris Denton-1/+26