about summary refs log tree commit diff
path: root/library/std/src/sys/windows
AgeCommit message (Collapse)AuthorLines
2021-05-19Windows implementation of `fs::try_exists`Chris Denton-1/+30
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-0/+1
can specialize it Windows implementation of `fs::try_exists`
2021-05-19Windows `Command` environment variables are case-preservingChris Denton-9/+128
But comparing is case-insensitive.
2021-05-19Rename `rterr` to `rtprintpanic`Christiaan Dirkx-1/+1
2021-05-19Replace `sys_common::util::report_overflow` with `rterr!`Christiaan Dirkx-2/+5
2021-05-12Provide ExitStatusErrorIan Jackson-2/+23
Closes #73125 This is in pursuance of Issue #73127 Consider adding #[must_use] to std::process::ExitStatus In MR #81452 Add #[must_use] to [...] process::ExitStatus we concluded that the existing arrangements in are too awkward so adding that #[must_use] is blocked on improving the ergonomics. I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10windows: provide NonZeroDWORDIan Jackson-0/+2
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-06Use the proper import library namesChris Denton-168/+167
2021-05-06Add `#[link]` attributes to dll importsChris Denton-0/+3
This avoids using jmp stubs when calling functions exported from a dll.
2021-05-03Move `std::sys::windows::ext` to `std::os::windows`Christiaan Dirkx-1145/+0
2021-05-02Use ErrorKind::OutOfMemory in unix, windows, and wasiKornel-0/+3
2021-04-28Remove `DropGuard` in `sys::windows::process` and use `StaticMutex` insteadChristiaan Dirkx-24/+4
2021-04-25Rollup merge of #84541 - KaiJewson:inline-raw, r=m-ou-seDylan DPC-0/+18
Inline most raw socket, fd and handle conversions Now that file descriptor types on Unix have niches, it is advantageous for user libraries which provide file descriptor wrappers (e.g. `Socket` from socket2) to store a `File` internally instead of a `RawFd`, so that the niche can be taken advantage of. However, doing so will currently result in worse performance as `IntoRawFd`, `FromRawFd` and `AsRawFd` are not inlined. This change adds `#[inline]` to those methods on std types that wrap file descriptors, handles or sockets.
2021-04-25Inline most raw socket, fd and handle conversionsKaiJewson-0/+18
2021-04-25Auto merge of #84115 - CDirkx:rt, r=m-ou-sebors-17/+23
Rework `init` and `cleanup` This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`. Full list of changes: - new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros. - `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`. - <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
2021-04-22Document that `init` and `cleanup` are not guaranteed to runChristiaan Dirkx-0/+2
2021-04-22Apply suggestions from reviewChristiaan Dirkx-5/+8
2021-04-22Move most init to `sys::init`Christiaan Dirkx-3/+3
2021-04-22Remove `sys::args::Args::inner_debug` and use `Debug` insteadChristiaan Dirkx-12/+2
2021-04-22Move all cleanup to `sys::cleanup`Christiaan Dirkx-6/+0
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-7/+14
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-3/+6
2021-04-18Update `decode_error_kind` to decode os errors to `NotSupported`Christiaan Dirkx-0/+1
2021-04-18Add and insta-stabilize `std::io::ErrorKind::NotSupported`Christiaan Dirkx-2/+2
2021-04-14Move `std::sys_common::alloc` to `std::sys::common`Christiaan Dirkx-1/+1
2021-04-02Remove `debug_assert`Christiaan Dirkx-4/+1
2021-04-02Introduce `get_process_heap` and fix atomic ordering.Christiaan Dirkx-13/+22
2021-03-26Cache `GetProcessHeap`Christiaan Dirkx-16/+54
2021-03-26Apply suggestions from code reviewCDirkx-2/+4
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2021-03-26Rework `std::sys::windows::alloc`Christiaan Dirkx-32/+173
Add documentation to the system functions and `SAFETY` comments. Refactored helper functions, fixing the correctness of `get_header`.
2021-03-24comment posCount Count-1/+1
2021-03-24assert!() instead of panic!() for expected invariantCount Count-32/+30
2021-03-24rename fn write_valid_utf8() to write_valid_utf8_to_console()Count Count-4/+4
2021-03-24correct commentCount Count-1/+1
2021-03-24use io::Error::new_const() everywhereCount Count-6/+6
2021-03-24fixCount Count-1/+1
2021-03-24Reject byte if it cannot start a valid UTF-8 sequence.Count Count-1/+2
2021-03-24fix c&p errorCount Count-1/+1
2021-03-24Export utf8_char_width() publicly in core::std behind the "str_internals" ↵Count Count-12/+1
feature gate and use it in sys::windows::stdio instead of reimplementing it there.
2021-03-24fix fmtCount Count-2/+2
2021-03-24fix incomplete UTF-8 writes in Windows console stdioCount Count-14/+102
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-18/+18
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-2/+4
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-17Expose force_quotes on Windows.Yonggang Luo-10/+49
Quotes the arg and not quotes the arg have different effect on Windows when the program called are msys2/cygwin program. Refer to https://github.com/msys2/MSYS2-packages/issues/2176 Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2021-02-15Rollup merge of #82119 - m-ou-se:typo, r=dtolnayJonas Schievink-1/+1
Fix typo in link to CreateSymbolicLinkW documentation.
2021-02-14Fix typo in link to CreateSymbolicLinkW documentation.Mara Bos-1/+1
2021-02-10Seal the CommandExt, OsStrExt and OsStringExt traitsAmanieu d'Antras-15/+15
2021-02-08Remove outdated comment.Mara Bos-2/+0
2021-01-31Fix calling convention for CRT startupArlie Davis-12/+10
My PR #81478 used the wrong calling convention for a set of functions that are called by the CRT. These functions need to use `extern "C"`. This would only affect x86, which is the only target (that I know of) that has multiple calling conventions.
2021-01-29Resolve DLL imports at CRT startup, not on demandArlie Davis-71/+95
On Windows, libstd uses GetProcAddress to locate some DLL imports, so that libstd can run on older versions of Windows. If a given DLL import is not present, then libstd uses other behavior (such as fallback implementations). This commit uses a feature of the Windows CRT to do these DLL imports during module initialization, before main() (or DllMain()) is called. This is the ideal time to resolve imports, because the module is effectively single-threaded at that point; no other threads can touch the data or code of the module that is being initialized. This avoids several problems. First, it makes the cost of performing the DLL import lookups deterministic. Right now, the DLL imports are done on demand, which means that application threads _might_ have to do the DLL import during some time-sensitive operation. This is a small source of unpredictability. Since threads can race, it's even possible to have more than one thread running the same redundant DLL lookup. This commit also removes using the heap to allocate strings, during the DLL lookups.