about summary refs log tree commit diff
path: root/library/std/src/sys/pal
AgeCommit message (Collapse)AuthorLines
2025-02-19fix by commentsxizheyin-21/+17
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-19Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306Li Keqing-2/+2
2025-02-19remove assume_init in stack_overflowxizheyin-7/+9
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-17Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDentonMatthias Krüger-1/+28
Use `tell` for `<File as Seek>::stream_position` Some platforms have a more efficient way to get the current offset of the file than by seeking. For example, Wasi has `fd_tell` and SOLID has `SOLID_FS_Ftell`. Implement `<File as Seek>::stream_position()` in terms of those. I do not use any APIs that were not already used in `std`. Although, the `libc` crate has [`ftell`](https://docs.rs/libc/latest/libc/fn.ftell.html), [`ftello`](https://docs.rs/libc/latest/libc/fn.ftello.html), and [`ftello64`](https://docs.rs/libc/latest/libc/fn.ftello64.html), I do not know platform coverage. It appears that Windows has no `tell`-like API. I have checked that it builds on each relevant platform.
2025-02-17Use tell for <File as Seek>::stream_positionThalia Archibald-1/+28
2025-02-17Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDentonMatthias Krüger-33/+21
Use `const_error!` when possible Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
2025-02-16Rollup merge of #136986 - ehuss:library-unsafe-fun, r=NoratriebMatthias Krüger-3/+3
Apply unsafe_op_in_unsafe_fn to the standard library This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024. Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee`` I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-1/+2
2025-02-15Rollup merge of #136978 - ChrisDenton:windows-bindgen, r=AmanieuJacob Pratt-2734/+2770
Windows: Update generated bindings Update to windows-bindgen 0.59. This update is aimed at reducing churn in the future, but means a bit more churn now: - `bindings.txt` no longer needs us to write the namespace for each item. This is good because it means in the future we won't need to change them if the namespace changes. However, there are a few where we still need to disambiguate due to duplicate items (this is a bug in the upstream metadata). - The output in `windows-sys.rs` is now sorted. It was mostly sorted before but not intentionally. This should mean future changes are less noisy. The actual code changes are minimal here. A few types are now `bool` instead of `BOOLEAN`, which is more convenient.
2025-02-15Rollup merge of #136879 - kornelski:non1, r=NoratriebJacob Pratt-5/+2
Add safe new() to NotAllOnes Replaces duplicated `unsafe` code with a single, easier to verify implementation.
2025-02-14Rollup merge of #136983 - ehuss:misc-2024-prep, r=tgross35Jubilee-31/+33
Prepare standard library for Rust 2024 migration This includes a variety of commits preparing the standard library for migration to Rust 2024. The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
2025-02-14std: Apply unsafe_op_in_unsafe_fnEric Huss-1/+1
2025-02-14Fix safety of windows uwp functionsEric Huss-2/+2
These functions were changed to be safe in https://github.com/rust-lang/rust/pull/127763, but this particular UWP version was missed. Otherwise this causes unnecessary unsafe block warnings/errors.
2025-02-14Rollup merge of #136052 - no1wudi:fix, r=workingjubileeMatthias Krüger-1/+1
Correct comment for FreeBSD and DragonFly BSD in unix/thread
2025-02-14Add safe new to NotAllOnesKornel-5/+2
2025-02-13std: Apply deprecated_safe_2024Eric Huss-6/+8
2025-02-13std: Apply fixes for tail drop expressionsEric Huss-2/+2
2025-02-13std: Apply rust_2024_incompatible_patEric Huss-2/+2
2025-02-13std: Apply unsafe_attr_outside_unsafeEric Huss-21/+21
2025-02-13Consistently using as_mut_ptr() and as_ptr() in threadxizheyin-8/+11
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in unixxizheyin-8/+20
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13Windows: Update generated bindings to 0.59Chris Denton-2734/+2770
2025-02-12expect EINVAL for pthread_mutex_destroy for aixHenry Jiang-3/+3
2025-02-10Fix long lines which rustfmt fails to formatThalia Archibald-106/+45
rustfmt fails to format this match expression, because it has several long string literals over the maximum line width. This seems to exhibit rustfmt issues #3863 (Gives up on chains if any line is too long) and #3156 (Fail to format match arm when other arm has long line).
2025-02-10Fix &&str and trailing commas in io::const_error!Thalia Archibald-26/+15
2025-02-10Use io::const_error! when possible over io::Error::newThalia Archibald-7/+6
2025-02-10Rollup merge of #136705 - compiler-errors:edition-library, r=jhprattJubilee-56/+56
Some miscellaneous edition-related library tweaks Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2025-02-10Rollup merge of #136552 - ChrisDenton:option-find-handle, r=Mark-SimulacrumJubilee-10/+6
Use an `Option` for `FindNextFileHandle` in `ReadDir` instead of `INVALID_FILE_HANDLE` sentinel value Sometimes we store an invalid handle when we don't want to return an error. We then check the handle before use in order to avoid actually using the invalid handle. However, using an `Option` for this is better and avoids us forgetting to check the handle is valid. This was noticed due to us closing the handle without checking for validity: https://github.com/rust-lang/rust/blob/bd6a6777f5cbbec549f123995026cef76d1e6b84/library/std/src/sys/pal/windows/fs.rs#L148-L151
2025-02-09Mark extern blocks as unsafeMichael Goulet-54/+54
2025-02-09Mark link_section attr with unsafeMichael Goulet-2/+2
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-18/+20
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-09Auto merge of #136754 - Urgau:rollup-qlkhjqr, r=Urgaubors-3/+41
Rollup of 5 pull requests Successful merges: - #134679 (Windows: remove readonly files) - #136213 (Allow Rust to use a number of libc filesystem calls) - #136530 (Implement `x perf` directly in bootstrap) - #136601 (Detect (non-raw) borrows of null ZST pointers in CheckNull) - #136659 (Pick the max DWARF version when LTO'ing modules with different versions ) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-09Rollup merge of #136213 - erickt:fs, r=Mark-SimulacrumUrgau-1/+17
Allow Rust to use a number of libc filesystem calls This allows Rust on Fuchsia to use a number of function calls from libc: * dirfd * fdatasync * flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN * fstatat cc #120426 try-job: dist-various-2
2025-02-09Rollup merge of #134679 - ChrisDenton:rm-readonly, r=Mark-SimulacrumUrgau-2/+24
Windows: remove readonly files When calling `remove_file`, we shouldn't fail to delete readonly files. As the test makes clear, this make the Windows behaviour consistent with other platforms. This also makes us internally consistent with `remove_dir_all`. try-job: x86_64-msvc-ext1
2025-02-08Rustfmtbjorn3-18/+20
2025-02-07std: get rid of `sys_common::io`joboet-6/+6
2025-02-07std: move `io` module out of `pal`joboet-573/+0
2025-02-05Rollup merge of #136449 - joboet:move_pal_net, r=ChrisDenton许杰友 Jieyou Xu (Joe)-6158/+5
std: move network code into `sys` 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.
2025-02-05Rollup merge of #136418 - Ayush1325:command-env, r=jhpratt许杰友 Jieyou Xu (Joe)-3/+62
uefi: process: Add support for command environment variables Set environment variables before launching the process and restore the prior variables after the program exists. This is the same implementation as the one used by UEFI Shell Execute [0]. [0]: https://github.com/tianocore/edk2/blob/2d2642f4832ebc45cb7d5ba9430b933d953b94f2/ShellPkg/Application/Shell/ShellProtocol.c#L1700
2025-02-04Use Option for FindNextFileHandleChris Denton-10/+6
2025-02-03std::fs: further simplify dirent64 handlingRalf Jung-8/+6
2025-02-02std: move network code into `sys`joboet-6158/+5
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.
2025-02-02uefi: process: Add support for command environment variablesAyush Singh-3/+62
Set environment variables before launching the process and restore the prior variables after the program exists. This is the same implementation as the one used by UEFI Shell Execute [0]. [0]: https://github.com/tianocore/edk2/blob/2d2642f4832ebc45cb7d5ba9430b933d953b94f2/ShellPkg/Application/Shell/ShellProtocol.c#L1700 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-30Rollup merge of #135475 - Ayush1325:uefi-absolute-path, r=jhprattMatthias Krüger-1/+49
uefi: Implement path This PR is split off from https://github.com/rust-lang/rust/pull/135368 to reduce noise. UEFI paths can be of 4 types: 1. Absolute Shell Path: Uses shell mappings 2. Absolute Device Path: this is what we want 3. Relative root: path relative to the current root. 4. Relative Absolute shell path can be identified with `:` and Absolute Device path can be identified with `/`. Relative root path will start with `\`. The algorithm is mostly taken from edk2 UEFI shell implementation and is somewhat simple. Check for the path type in order. For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to get a BorrowedDevicePath for the volume. For Relative paths, we use the current working directory to construct the new path. BorrowedDevicePath abstraction is needed to interact with `EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol with the lifetime of UEFI shell. Absolute Shell paths cannot exist if UEFI shell is missing. cc `@nicholasbishop`
2025-01-28Allow Rust to use a number of libc filesystem callsErick Tryzelaar-1/+17
This allows Rust on Fuchsia to use a number of function calls from libc: * dirfd * fdatasync * flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN * fstatat
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-26Windows: Test that deleting a running binary failsChris Denton-2/+4
2025-01-26Windows: remove readonly filesChris Denton-2/+22