about summary refs log tree commit diff
path: root/src/libstd/sys/windows
AgeCommit message (Collapse)AuthorLines
2020-05-02Replace `cfg` macro with attribute.Markus Reiter-1/+0
2020-04-26Update nameSteven Fackler-12/+12
2020-04-26Add Read/Write::can_read/write_vectoredSteven Fackler-0/+40
When working with an arbitrary reader or writer, code that uses vectored operations may end up being slower than code that copies into a single buffer when the underlying reader or writer doesn't actually support vectored operations. These new methods allow you to ask the reader or witer up front if vectored operations are efficiently supported. Currently, you have to use some heuristics to guess by e.g. checking if the read or write only accessed the first buffer. Hyper is one concrete example of a library that has to do this dynamically: https://github.com/hyperium/hyper/blob/0eaf304644a396895a4ce1f0146e596640bb666a/src/proto/h1/io.rs#L582-L594
2020-04-14Add missing commaYoungsuk Kim-1/+1
2020-04-09Rollup merge of #67705 - lzutao:wmemchr, r=wesleywiserMazdak Farrokhzad-2/+46
Use unrolled loop for searching NULL in [u16] on Windows
2020-04-06Forward OsStr::clone_into to the inner VecJosh Stone-0/+4
Despite OS differences, they're all just `Vec<u8>` inside, so we can just forward `clone_into` calls to that optimized implementation.
2020-04-03Rollup merge of #70597 - vakaras:thread_new_double_free_bug_fix, r=AmanieuMazdak Farrokhzad-6/+11
Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new While working on concurrency support for Miri, I found that the `libstd::syn::unix::Thread::new` method has two potential problems: double-free and undefined behaviour. **Double-free** could occur if the following events happened (credit for pointing this out goes to @RalfJung): 1. The call to `pthread_create` successfully launched a new thread that executed to completion and deallocated `p`. 2. The call to `pthread_attr_destroy` returned a non-zero value causing the `assert_eq!` to panic. 3. Since `mem::forget(p)` was not yet executed, the destructor of `p` would be executed and cause a double-free. As far as I understand, this code also violates the stacked-borrows aliasing rules and thus would result in **undefined behaviour** if these rules were adopted. The problem is that the ownership of `p` is passed to the newly created thread before the call to `mem::forget`. Since the call to `mem::forget` is still a call, it counts as a use of `p` and triggers UB. This pull request changes the code to use `mem::ManuallyDrop` instead of `mem::forget`. As a consequence, in case of a panic, `p` would be potentially leaked, which while undesirable is probably better than double-free or undefined behaviour.
2020-04-02Use unrolled looplzutao-9/+43
2020-04-02use of wmemchr for faster searching in [u16]Lzu Tao-2/+12
2020-04-01In Thread::new, add a comment that a panic could cause a memory leak.Vytautas Astrauskas-1/+1
2020-03-31Use Box::into_raw instead of ManuallyDrop in Thread::new.Vytautas Astrauskas-5/+4
2020-04-01Rollup merge of #70081 - lcnr:issue68387, r=varkorDylan DPC-3/+2
add `unused_braces` lint Add the lint `unused_braces` which is warn by default. `unused_parens` is also extended and now checks anon consts. closes #68387 r? @varkor
2020-03-31Inline start_thread into its callers.Vytautas Astrauskas-2/+6
2020-03-31Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new.Vytautas Astrauskas-3/+5
2020-03-31fix internal lint falloutBastian Kauschke-3/+2
2020-03-30Rollup merge of #70479 - RalfJung:win-env, r=Mark-SimulacrumDylan DPC-1/+1
avoid creating unnecessary reference in Windows Env iterator Discovered in https://github.com/rust-lang/miri/pull/1225: the Windows `Env` iterator violates Stacked Borrows by creating an `&u16`, turning it into a raw pointer, and then accessing memory outside the range of that type. There is no need to create a reference here in the first place, so the fix is trivial. Cc @JOE1994 Cc https://github.com/rust-lang/unsafe-code-guidelines/issues/134
2020-03-29Rollup merge of #70510 - RalfJung:bool-vs-boolean, r=Mark-SimulacrumDylan DPC-1/+1
fix TryEnterCriticalSection return type Source: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-tryentercriticalsection Fixes https://github.com/rust-lang/rust/issues/70504
2020-03-29Rollup merge of #69937 - TyPR124:osstr_ascii, r=dtolnayDylan DPC-5/+34
ASCII methods on OsStr Would close #69566 I don't know enough about encodings to know if this is a valid change, however the comment on the issue suggests it could be. This does two things: 1. Makes ASCII methods available on OsStr 2. Makes it possible to obtain a `&mut OsStr`. This is necessary to actually use `OsStr::make_ascii_*case` methods since they modify the underlying value. As far as I can tell, the only way to modify a `&mut OsStr` is via the methods I just added. My original hope was to have these methods on `OsStrExt` for Windows, since the standard library already assumes `make_ascii_uppercase` is valid in Windows (see the change I made to windows/process.rs). If it is found these are not valid changes on non-Windows platforms, I can move the methods to the ext trait instead.
2020-03-28use make_ascii_uppercase in windows/process.rsTyPR124-5/+4
2020-03-28ascii methods on osstrTyPR124-0/+30
2020-03-28fix TryEnterCriticalSection return typeRalf Jung-1/+1
2020-03-27avoid creating unnecessary reference in Windows Env iteratorRalf Jung-1/+1
2020-03-27Auto merge of #68404 - Amanieu:llvm-asm, r=estebankbors-1/+1
Rename asm! to llvm_asm! As per https://github.com/rust-lang/rfcs/pull/2843, this PR renames `asm!` to `llvm_asm!`. It also renames the compiler's internal `InlineAsm` data structures to `LlvmInlineAsm` in preparation for the new `asm!` functionality specified in https://github.com/rust-lang/rfcs/pull/2850. This PR doesn't actually deprecate `asm!` yet, it just makes it redirect to `llvm_asm!`. This is necessary because we first need to update the submodules (in particular stdarch) to use `llvm_asm!`.
2020-03-27Rollup merge of #70048 - TyPR124:mutable_osstr, r=dtolnayDylan DPC-0/+12
Allow obtaining &mut OsStr ```rust impl DerefMut for OsString {...} // type Target = OsStr impl IndexMut<RangeFull> for OsString {...} // type Output = OsStr ``` --- This change is pulled out of #69937 per @dtolnay This implements `DerefMut for OsString` to allow obtaining a `&mut OsStr`. This also implements `IndexMut for OsString`, which is used by `DerefMut`. This pattern is the same as is used by `Deref`. This is necessary to for methods like `make_ascii_lowercase` which need to mutate the underlying value.
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-1/+1
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-21Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfacklerDylan DPC-3/+3
Fix abort-on-eprintln during process shutdown This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-20Fix abort-on-eprintln during process shutdownAlex Crichton-3/+3
This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-20add comment about maintaining OsStr encodingTyPR124-0/+2
2020-03-16make safety comments more explicitTyPR124-4/+4
2020-03-16corrections on safety commentsTyPR124-3/+3
2020-03-16remove #[inline] for consistency in windows/os_strTyPR124-1/+0
2020-03-16add comments about safetyTyPR124-0/+6
2020-03-16allowing getting &mut OsStr from OsStringTyPR124-0/+5
2020-03-16Rollup merge of #69858 - da-x:windows-precise-time, r=Dylan-DPCDylan DPC-1/+5
std: on Windows, use GetSystemTimePreciseAsFileTime if it is available This implements #67266.
2020-03-09Use GetSystemTimePreciseAsFileTime if it is availableDan Aloni-1/+5
2020-02-23Implement `Copy` for `IoSlice`LeSeulArtichaut-0/+2
2020-01-16Rollup merge of #68033 - ollie27:win_f32, r=dtolnayDylan DPC-5/+5
Don't use f64 shims for f32 cmath functions on non 32-bit x86 MSVC These shims are only needed on 32-bit x86. Additionally since https://reviews.llvm.org/rL268875 LLVM handles adding the shims itself for the intrinsics.
2020-01-10make use of pointer::is_nullLzu Tao-1/+1
2020-01-08Don't use f64 shims for f32 cmath functions on none 32-bit x86 MSVCOliver Middleton-5/+5
These shims are only needed on 32-bit x86. Additionally since https://reviews.llvm.org/rL268875 LLVM handles adding the shims itself for the intrinsics.
2020-01-04Rollup merge of #67848 - ollie27:float_link_name_attr, r=Dylan-DPCGuillaume Gomez-1/+0
Remove unused `#[link_name = "m"]` attributes These were perhaps supposed to be `#[link(name = "m")]` but linking libm should be handled by the libc crate anyway. They should have triggered a compile error: #47725
2020-01-03Remove unused `#[link_name = "m"]` attributesOliver Middleton-1/+0
These were perhaps supposed to be `#[link(name = "m")]` but linking libm should be handled by the libc crate anyway.
2020-01-02Use drop instead of the toilet closure `|_| ()`Lzu Tao-6/+6
2019-12-28Auto merge of #67605 - lzutao:msdn-links, r=Mark-Simulacrumbors-17/+17
tidy: change msdn links to newer locations see accouncement at https://docs.microsoft.com/welcome-to-docs The script that I used: https://gist.github.com/lzutao/1449c9210ad91899841d62e0058d2caa
2019-12-25tidy: change msdn links to newer locationsLzu Tao-17/+17
see accouncement at https://docs.microsoft.com/welcome-to-docs
2019-12-24Deprecate Error::description for realDavid Tolnay-0/+1
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-12-22Format the worldMark Rousskov-544/+548
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-12/+12
2019-12-09inline some common methods on OsStrLzu Tao-0/+1
2019-12-02added correct error code for WSASocketW failure fallbackavikozokin-2/+2
2019-11-29Format libstd/sys with rustfmtDavid Tolnay-518/+613
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd/sys -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd/sys outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of the files. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference