summary refs log tree commit diff
path: root/src/libstd/sys/windows
AgeCommit message (Collapse)AuthorLines
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
2019-10-22Apply clippy::while_let_on_iterator suggestionsMateusz Mikuła-2/+1
2019-10-22Apply clippy::needless_return suggestionsMateusz Mikuła-7/+7
2019-10-11make File::try_clone produce non-inheritable handles on WindowsJack O'Connor-1/+1
File handles shouldn't be inheritable in general. `std::process::Command` takes care of making them inheritable when child processes are spawned, and the `CREATE_PROCESS_LOCK` protects against races in that section on Windows. But `File::try_clone` has been creating inheritable file descriptors outside of that lock, which could be leaking into other child processes unintentionally. See also https://github.com/rust-lang/rust/pull/31069#discussion_r334117665.
2019-09-05std: Improve downstream codegen in `Command::env`Alex Crichton-13/+11
This commit rejiggers the generics used in the implementation of `Command::env` with the purpose of reducing the amount of codegen that needs to happen in consumer crates, instead preferring to generate code into libstd. This was found when profiling the compile times of the `cc` crate where the binary rlib produced had a lot of `BTreeMap` code compiled into it but the crate doesn't actually use `BTreeMap`. It turns out that `Command::env` is generic enough to codegen the entire implementation in calling crates, but in this case there's no performance concern so it's fine to compile the code into the standard library. This change is done by removing the generic on the `CommandEnv` map which is intended to handle case-insensitive variables on Windows. Instead now a generic isn't used but rather a `use` statement defined per-platform is used. With this commit a debug build of `Command::new("foo").env("a", "b")` drops from 21k lines of LLVM IR to 10k.
2019-08-15Rollup merge of #63155 - mfkl:uwp-msvc, r=alexcrichtonMazdak Farrokhzad-2/+2
Add UWP MSVC targets Hi, - The README URI change is the correct one for VS2019 community edition, which I suspect most people would use. Doesn't _need_ to be merged though. - This https://github.com/rust-lang/rust/commit/5e6619edd1a3b5c3f85438166d4d32af49f800fd fixes the UWP build (msvc or not, doesn't matter). I suspect it broke with recent changes unnoticed because no CI. - Store lib location is found through the VCToolsInstallDir env variable. The end of the path is currently for the VS2019 store lib locations only. - I could not test the aarch64_uwp_windows_msvc target because the rust build script does not currently support arm64 msvc AFAIU.
2019-08-03Add {IoSlice, IoSliceMut}::advanceThomas de Zeeuw-0/+24
2019-07-31Fix UWP buildMartin Finkel-2/+2
2019-07-27Rollup merge of #63013 - nivkner:ffi-safe-slice, r=sfacklerMazdak Farrokhzad-0/+1
add `repr(transparent)` to `IoSliceMut` where missing tried using `IoSliceMut` in FFI, got `improper_ctypes` warning. according to the docs: `IoSliceMut` is "guaranteed to be ABI compatible with the `iovec` type" so it should be usable in FFI. `IoSlice` is also `repr(transparent)` for every platform where these types contain `iovec`-like types. vxworks also has `IoSliceMut` as transparent so its not even consistently one or the other. no comment about this next to the types or in the PR that introduced the types, so assuming this was just missed. r? @sfackler
2019-07-26add repr(transparent) to IoSliceMut where missingNiv Kaminer-0/+1
2019-07-26std: Add more accessors for `Metadata` on WindowsAlex Crichton-16/+69
This commit adds accessors for more fields in `fs::Metadata` on Windows which weren't previously exposed. There's two sources of `fs::Metadata` on Windows currently, one from `DirEntry` and one from a file itself. These two sources of information don't actually have the same set of fields exposed in their stat information, however. To handle this the platform-specific accessors of Windows-specific information all return `Option` to return `None` in the case a metadata comes from a `DirEntry`, but they're guaranteed to return `Some` if it comes from a file itself. This is motivated by some changes in CraneStation/wasi-common#42, and I'm curious how others feel about this platform-specific functionality!
2019-07-25std: win: Disable stack overflow handling on UWPHugo Beauzée-Luyssen-29/+45
The required functions are not available, so hope for the best
2019-07-25std: win: Don't use console APIs on UWPHugo Beauzée-Luyssen-26/+119
2019-07-25std: win: Don't use GetFileInformationByHandle on UWPHugo Beauzée-Luyssen-19/+76
2019-07-25std: win: Don't use GetUserProfileDirectoryW on UWPHugo Beauzée-Luyssen-13/+26
2019-07-25std: win: Don't expose link() on UWPHugo Beauzée-Luyssen-4/+11
Or rather expose it, but always return an error
2019-07-25std: win: Don't use SetHandleInformation on UWPHugo Beauzée-Luyssen-19/+61
Attempt to create sockets with the WSA_FLAG_NO_HANDLE_INHERIT flag, and handle the potential error gracefully (as the flag isn't support on Windows 7 before SP1)
2019-07-25std: rand: Use BCrypt on UWPHugo Beauzée-Luyssen-2/+41
As Rtl* functions are not allowed there
2019-07-25libstd: windows: compat: Allow use of attributesHugo Beauzée-Luyssen-0/+2
2019-07-05Rollup merge of #62123 - jeremystucki:needless_lifetimes_std, r=alexcrichtonMazdak Farrokhzad-2/+2
Remove needless lifetimes (std) Split from #62039
2019-07-01Convert more usages overChris Gregory-1/+1
2019-07-01Remove needless lifetimesJeremy Stucki-2/+2
2019-06-20Auto merge of #60341 - mtak-:macos-tlv-workaround, r=alexcrichtonbors-4/+0
macos tlv workaround fixes: #60141 Includes: * remove dead code: `requires_move_before_drop`. This hasn't been needed for a while now (oops I should have removed it in #57655) * redox had a copy of `fast::Key` (not sure why?). That has been removed. * Perform a `read_volatile` on OSX to reduce `tlv_get_addr` calls per `__getit` from (4-2 depending on context) to 1. `tlv_get_addr` is relatively expensive (~1.5ns on my machine). Previously, in contexts where `__getit` was inlined, 4 calls to `tlv_get_addr` were performed per lookup. For some reason when `__getit` is not inlined this is reduced to 2x - and performance improves to match. After this PR, I have only ever seen 1x call to `tlv_get_addr` per `__getit`, and macos now benefits from situations where `__getit` is inlined. I'm not sure if the `read_volatile(&&__KEY)` trick is working around an LLVM bug, or a rustc bug, or neither. r? @alexcrichton
2019-05-25std: Depend on `backtrace` crate from crates.ioAlex Crichton-1059/+0
This commit removes all in-tree support for generating backtraces in favor of depending on the `backtrace` crate on crates.io. This resolves a very longstanding piece of duplication where the standard library has long contained the ability to generate a backtrace on panics, but the code was later extracted and duplicated on crates.io with the `backtrace` crate. Since that fork each implementation has seen various improvements one way or another, but typically `backtrace`-the-crate has lagged behind libstd in one way or another. The goal here is to remove this duplication of a fairly critical piece of code and ensure that there's only one source of truth for generating backtraces between the standard library and the crate on crates.io. Recently I've been working to bring the `backtrace` crate on crates.io up to speed with the support in the standard library which includes: * Support for `StackWalkEx` on MSVC to recover inline frames with debuginfo. * Using `libbacktrace` by default on MinGW targets. * Supporting `libbacktrace` on OSX as an option. * Ensuring all the requisite support in `backtrace`-the-crate compiles with `#![no_std]`. * Updating the `libbacktrace` implementation in `backtrace`-the-crate to initialize the global state with the correct filename where necessary. After reviewing the code in libstd the `backtrace` crate should be at exact feature parity with libstd today. The backtraces generated should have the same symbols and same number of frames in general, and there's not known divergence from libstd currently. Note that one major difference between libstd's backtrace support and the `backtrace` crate is that on OSX the crates.io crate enables the `coresymbolication` feature by default. This feature, however, uses private internal APIs that aren't published for OSX. While they provide more accurate backtraces this isn't appropriate for libstd distributed as a binary, so libstd's dependency on the `backtrace` crate explicitly disables this feature and forces OSX to use `libbacktrace` as a symbolication strategy. The long-term goal of this refactoring is to eventually move us towards a world where we can drop `libbacktrace` entirely and simply use Gimli and the surrounding crates for backtrace support. That's still aways off but hopefully will much more easily enabled by having the source of truth for backtraces live in crates.io! Procedurally if we go forward with this I'd like to transfer the `backtrace-rs` crate to the rust-lang GitHub organization as well, but I figured I'd hold off on that until we get closer to merging.
2019-05-22Revert "Add implementations of last in terms of next_back on a bunch of ↵Steven Fackler-2/+0
DoubleEndedIterators." This reverts commit 3e86cf36b5114f201868bf459934fe346a76a2d4.
2019-05-15Revert "ensure fast thread local lookups occur once per access on macos"tyler-4/+0
This reverts commit d252f3b77f3b7d4cd59620588f9d026633c05816.
2019-05-15ensure fast thread local lookups occur once per access on macostyler-0/+4
2019-05-15remove dead code: requires_move_before_droptyler-4/+0
2019-05-14Rollup merge of #60130 - khuey:efficient_last, r=sfacklerMazdak Farrokhzad-0/+2
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators. I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so. The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
2019-04-27Stabilized vectored IOSteven Fackler-21/+21
This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452
2019-04-19Add implementations of last in terms of next_back on a bunch of ↵Kyle Huey-0/+2
DoubleEndedIterators. r?Manishearth
2019-04-14Rollup merge of #59852 - alexcrichton:more-vectored, r=sfacklerMazdak Farrokhzad-3/+31
std: Add `{read,write}_vectored` for more types This commit implements the `{read,write}_vectored` methods on more types in the standard library, namely: * `std::fs::File` * `std::process::ChildStd{in,out,err}` * `std::io::Std{in,out,err}` * `std::io::Std{in,out,err}Lock` * `std::io::Std{in,out,err}Raw` Where supported the OS implementations hook up to native support, otherwise it falls back to the already-defaulted implementation.
2019-04-10std: Add `{read,write}_vectored` for more typesAlex Crichton-3/+31
This commit implements the `{read,write}_vectored` methods on more types in the standard library, namely: * `std::fs::File` * `std::process::ChildStd{in,out,err}` * `std::io::Std{in,out,err}` * `std::io::Std{in,out,err}Lock` * `std::io::Std{in,out,err}Raw` Where supported the OS implementations hook up to native support, otherwise it falls back to the already-defaulted implementation.
2019-04-10Eliminate `FnBox` usages from libstd.CrLF0710-2/+1
2019-04-04std: Avoid usage of `Once` in `Instant`Alex Crichton-6/+18
This commit removes usage of `Once` from the internal implementation of time utilities on OSX and Windows. It turns out that we accidentally hit a deadlock today (#59020) via events that look like: * A thread invokes `park_timeout` * Internally, only on OSX, `park_timeout` calls `Instant::elapsed` * Inside of `Instant::elapsed` on OSX we enter a `Once` to initialize global timer data * Inside of `Once`, it attempts to `park` This means on the same stack frame, when there's contention, we're calling `park` from inside `park_timeout`, causing a deadlock! The solution implemented in this commit was to remove usage of `Once` and instead just do a small dance with atomics. There's no real need we need to guarantee that the global information is only learned once, only that it's only *stored* once. This implementation may have multiple threads invoke `mach_timebase_info`, but only one will store the global information which will amortize the cost for all other threads. A similar fix has been applied to windows to be uniform across our implementations, but looking at the code on Windows no deadlock was possible. This is purely just a consistency update for Windows and in theory a slightly leaner implementation. Closes #59020
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-17/+17
2019-03-29implement `AsRawFd` for stdio locksAndy Russell-0/+21