about summary refs log tree commit diff
path: root/library/std/src/sys/pal/windows
AgeCommit message (Collapse)AuthorLines
2025-07-28thread name in stack overflow messagejoboet-1/+5
2025-07-07UWP: link ntdll functions using raw-dylibChris Denton-60/+9
2025-07-06Auto merge of #141829 - dvdsk:sleep_until_linux, r=cuviper,RalfJungbors-1/+9
Specialize sleep_until implementation for unix (except mac) related tracking issue: https://github.com/rust-lang/rust/issues/113752 Supersedes https://github.com/rust-lang/rust/pull/118480 for the reasons see: https://github.com/rust-lang/rust/issues/113752#issuecomment-2902594469 Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-1/+9
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-06-28Workaround for mem safety in third party dllsChris Denton-12/+81
2025-06-25make `tidy-alphabetical` use a natural sortFolkert de Vries-3/+3
2025-06-15Windows: Use anonymous pipes in CommandChris Denton-86/+142
2025-06-05Optimize `Seek::stream_len` impl for `File`Tobias Bucher-0/+2
It uses the file metadata on Unix with a fallback for files incorrectly reported as zero-sized. It uses `GetFileSizeEx` on Windows. This reduces the number of syscalls needed for determining the file size of an open file from 3 to 1.
2025-05-23GetUserProfileDirectoryW is now documented to always store the sizeRalf Jung-2/+0
2025-05-19windows: document that we rely on an undocumented property of ↵Ralf Jung-0/+2
GetUserProfileDirectoryW
2025-05-15improve internal fastfail explainerjoboet-3/+2
2025-05-15deduplicate abort implementationsjoboet-2/+7
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-04-27use generic Atomic type where possibleChristopher Durham-14/+14
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-21Move `sys::pal::os::Env` into `sys::env`Thalia Archibald-132/+3
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-13Rollup merge of #139710 - thaliaarchi:move-args-pal, r=joboetChris Denton-537/+0
Move `args` into `std::sys` Move platform definitions of `args` into `std::sys`, as part of https://github.com/rust-lang/rust/issues/117276. cc ``@joboet``
2025-04-12Move args into std::sysThalia Archibald-537/+0
2025-04-04Update windows-bindgen to 0.61.0Chris Denton-27/+284
2025-04-02Remove creation of duplicate AnonPipeJake Wharton-1/+0
The File is unwrapped to a Handle into an AnonPipe, and then that AnonPipe was unwrapped to a Handle into another AnonPipe. The second operation is entirely redundant.
2025-03-27std: get rid of pre-Vista fallback codejoboet-22/+6
We haven't had any Windows XP targets for a long while now...
2025-03-22std: move process implementations to `sys`joboet-1154/+9
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/+6
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-09std: move stdio to `sys`joboet-479/+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-09Rollup merge of #138276 - bdbai:fix-uwp-ntopenfile, r=ChrisDentonMatthias Krüger-0/+11
Lazy load NtOpenFile for UWP Lazily load `NtOpenFile` to allow libraries targeting UWP to build and link. Fixes #138257 . r? `@ChrisDenton`
2025-03-09Lazy load NtOpenFile for UWPbdbai-0/+11
2025-03-08Move fs into sysThalia Archibald-1867/+1
2025-03-07Return OutOfMemoryError and update docsChris Denton-2/+2
2025-03-07Windows: Use MoveFileEx by default in `fs:rename`Chris Denton-123/+56
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-28/+25
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-01Rollup merge of #137809 - Noratrieb:io-error-casing, r=thomccMatthias Krüger-2/+2
Use correct error message casing for `io::const_error`s Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
2025-02-28Use correct error message casing for `io::const_error`sNoratrieb-2/+2
Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
2025-02-26Fix Windows `Command` search path bugChris Denton-1/+2
2025-02-23Win: use existing wrappers for `SetFileInformationByHandle` in ↵Dennis Duda-25/+11
`File::open_native`
2025-02-20Rollup merge of #137270 - QianNangong:master, r=ChrisDentonJubilee-2/+2
Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306 That commit make it failed to build `std` with `*-win7-windows-msvc` so fix it.
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-1/+2
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-19Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306Li Keqing-2/+2
2025-02-17Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDentonMatthias Krüger-0/+4
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-0/+4
2025-02-17Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDentonMatthias Krüger-6/+2
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-2/+2
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-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-13std: Apply deprecated_safe_2024Eric Huss-2/+4
2025-02-13Windows: Update generated bindings to 0.59Chris Denton-2734/+2770
2025-02-10Fix &&str and trailing commas in io::const_error!Thalia Archibald-6/+2
2025-02-10Rollup merge of #136705 - compiler-errors:edition-library, r=jhprattJubilee-4/+4
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-3/+3
2025-02-09Mark link_section attr with unsafeMichael Goulet-1/+1