about summary refs log tree commit diff
path: root/library/std/src/sys/windows/mod.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-357/+0
2023-12-03library: use c string literalsklensy-2/+2
2023-11-22redundant_slicingChris Denton-1/+1
2023-11-22needless_borrowChris Denton-1/+1
this expression creates a reference which is immediately dereferenced by the compiler
2023-10-16Create `windows/api.rs` for safer FFIChris Denton-2/+14
2023-08-25Add a new helper to avoid calling io::Error::kindBen Kimock-0/+5
2023-07-05Revert "use c literals in library"León Orell Valerian Liehr-2/+2
This reverts commit f212ba6d6d60963c8101bb24fc3e53fca80c046f.
2023-05-31use c literals in libraryklensy-2/+2
2023-04-16Windows: map a few more error codes to ErrorKindChris Denton-3/+6
NotFound errors: * `ERROR_INVALID_DRIVE`: The system cannot find the drive specified * `ERROR_BAD_NETPATH`: The network path was not found * `ERROR_BAD_NET_NAME`: The network name cannot be found. InvalidFilename: * `ERROR_BAD_PATHNAME`: The specified path is invalid.
2022-12-29std: unify id-based thread parking implementationsjoboet-1/+1
2022-10-27Use stdio in UWP appsChris Denton-3/+1
This has been supported since Windows 10.0.16299. See https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-console-l1-1-0dll
2022-09-02Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplettbors-1/+1
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE` When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program ```rust fn main() { loop { println!("hello world"); } } ``` will print an error if used with a short-lived pipe, e.g. % ./main | head -n 1 hello world thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace by enabling `#[unix_sigpipe = "sig_dfl"]` like this ```rust #![feature(unix_sigpipe)] #[unix_sigpipe = "sig_dfl"] fn main() { loop { println!("hello world"); } } ``` there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately: % ./main | head -n 1 hello world The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`. With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`. See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-08-30Replace `AlignedAs` with a more specific `Align8` typeThom Chiovoloni-21/+6
2022-08-29Fix some possible UB in std::sys::windowsThom Chiovoloni-0/+23
2022-08-28Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`Martin Nordholts-1/+1
This makes it possible to instruct libstd to never touch the signal handler for `SIGPIPE`, which makes programs pipeable by default (e.g. with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe` errors.
2022-08-19Fix comment typoThom Chiovoloni-1/+1
2022-08-18Avoid zeroing a 1kb stack buffer on every call to ↵Thom Chiovoloni-5/+13
`std::sys::windows::fill_utf16_buf`
2022-05-27Call the OS function to set the main thread's name on program initWesley Wiser-1/+5
Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
2022-04-23Auto merge of #96314 - AronParker:issue-96297-fix, r=thomccbors-1/+7
Reduce allocations for path conversions on Windows Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-22Remove redundant type annotationAron Parker-1/+1
2022-04-22Reduce allocations for path conversions on WindowsAron Parker-1/+7
Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-17Improve Windows path prefix parsingdylni-0/+4
2022-04-14library: Remove definitions and reexports of `strlen` from libstdVadim Petrochenkov-1/+0
2022-04-08fix some unused constant warning on some Windows targetsRalf Jung-0/+1
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-2/+2
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-22Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.Mara Bos-3/+1
2022-03-09Use `unreachable!` for an unreachable code pathChris Denton-1/+7
2022-02-10Rename to `InvalidFilename`Yuki Okushi-2/+2
2022-02-10Map `ERROR_INVALID_NAME` to `FilenameInvalid`Yuki Okushi-1/+2
2022-02-10Rename `FilenameTooLong` to `FilenameInvalid`Yuki Okushi-1/+1
2022-02-10windows: Map `ERROR_INVALID_NAME` as `InvalidInput`Yuki Okushi-1/+1
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-2/+2
2022-01-25make Windows abort_internal Miri-compatibleRalf Jung-0/+1
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-3/+3
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-06-18ErrorKind: Windows: Fix tidyIan Jackson-2/+1
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Windows: Fix botched rebaseIan Jackson-2/+0
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Provide many more ErrorKinds, motivated by Unix errnosIan Jackson-0/+21
Rationale for the mappings etc. is extensively discussed in the MR https://github.com/rust-lang/rust/pull/79965 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Reformat the mapping table (windows)Ian Jackson-22/+24
use ErrorKind::*; I don't feel confident enough about Windows things to reorder this alphabetically Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-1/+1
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-1/+1
2021-05-06Use the proper import library namesChris Denton-14/+0
2021-05-03Move `std::sys::windows::ext` to `std::os::windows`Christiaan Dirkx-1/+0
2021-05-02Use ErrorKind::OutOfMemory in unix, windows, and wasiKornel-0/+1
2021-04-22Document that `init` and `cleanup` are not guaranteed to runChristiaan Dirkx-0/+2
2021-04-22Move most init to `sys::init`Christiaan Dirkx-1/+3
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-2/+7
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-1/+1
2021-04-18Update `decode_error_kind` to decode os errors to `NotSupported`Christiaan Dirkx-0/+1
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-2/+2
2020-12-14Auto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieubors-0/+1
Add fast futex-based thread parker for Windows. This adds a fast futex-based thread parker for Windows. It either uses WaitOnAddress+WakeByAddressSingle or NT Keyed Events (NtWaitForKeyedEvent+NtReleaseKeyedEvent), depending on which is available. Together, this makes this thread parker work for Windows XP and up. Before this change, park()/unpark() did not work on Windows XP: it needs condition variables, which only exist since Windows Vista. --- Unfortunately, NT Keyed Events are an undocumented Windows API. However: - This API is relatively simple with obvious behaviour, and there are several (unofficial) articles documenting the details. [1] - parking_lot has been using this API for years (on Windows versions before Windows 8). [2] Many big projects extensively use parking_lot, such as servo and the Rust compiler itself. - It is the underlying API used by Windows SRW locks and Windows critical sections. [3] [4] - The source code of the implementations of Wine, ReactOs, and Windows XP are available and match the expected behaviour. - The main risk with an undocumented API is that it might change in the future. But since we only use it for older versions of Windows, that's not a problem. - Even if these functions do not block or wake as we expect (which is unlikely, see all previous points), this implementation would still be memory safe. The NT Keyed Events API is only used to sleep/block in the right place. [1]\: http://www.locklessinc.com/articles/keyed_events/ [2]\: https://github.com/Amanieu/parking_lot/commit/43abbc964e [3]\: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c [4]\: Windows Internals, Part 1, ISBN 9780735671300 --- The choice of fallback API is inspired by parking_lot(_core), but the implementation of this thread parker is different. While parking_lot has no use for a fast path (park() directly returning if unpark() was already called), this implementation has a fast path that returns without even checking which waiting/waking API to use, as the same atomic variable with compatible states is used in all cases.