about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-02-05Expose correct items in `os::fortanix_sgx::usercalls::alloc`Jethro Beekman-1/+1
2019-02-05SGX target: handle empty user buffers correctlyJethro Beekman-2/+8
2019-02-04Remove stray FIXMEJethro Beekman-3/+0
2019-02-03Improve error message and docs for non-UTF-8 bytes in stdio on WindowsAustin Bonander-1/+48
cc #23344
2019-02-03Update the future/task APIMatthias Einwag-15/+13
This change updates the future and task API as discussed in the stabilization RFC at https://github.com/rust-lang/rfcs/pull/2592. Changes: - Replacing UnsafeWake with RawWaker and RawWakerVtable - Removal of LocalWaker - Removal of Arc-based Wake trait
2019-02-03Auto merge of #57922 - davidtwco:issue-57410, r=petrochenkovbors-0/+2
Update visibility of intermediate use items. Fixes #57410 and fixes #53925 and fixes #47816. Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This PR ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
2019-02-03POSIX requires async signal safety for fork in signal handlers, not in generalRalf Jung-4/+2
2019-02-03more formattingRalf Jung-4/+8
2019-02-03Auto merge of #58043 - jethrogb:jb/sgx-usercallnrs, r=joshtriplettbors-20/+10
Fix `std::os::fortanix_sgx::usercalls::raw::UsercallNrs` It was 0-indexed but should be 1-indexed. This PR just removes the duplicate code and re-exports the internal enum. Fixes https://github.com/fortanix/rust-sgx/issues/88 r? @joshtriplett
2019-02-02Update visibility of intermediate use items.David Wood-0/+2
Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This commit ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
2019-02-02pre_exec: expand docsRalf Jung-6/+8
2019-02-02deprecate things a bit slowerRalf Jung-2/+2
2019-02-01also replace before_exec by pre_exec on redoxRalf Jung-6/+26
2019-02-01deprecate before_exec in favor of unsafe pre_execRalf Jung-4/+24
2019-02-01Stabilize std::error::Error::type_idSimon Sapin-3/+1
This should have been part of https://github.com/rust-lang/rust/pull/57834 FCP: https://github.com/rust-lang/rust/issues/27745#issuecomment-373906749
2019-02-01Fix `std::os::fortanix_sgx::usercalls::raw::UsercallNrs`Jethro Beekman-20/+10
Fixes https://github.com/fortanix/rust-sgx/issues/88
2019-01-31Simplify lambdasLinus Färnstrand-4/+4
2019-01-31Stabilize the time_checked_add featureLinus Färnstrand-4/+4
2019-01-31Rollup merge of #57971 - jethrogb:jb/sgx-panic, r=alexcrichtonMazdak Farrokhzad-22/+32
SGX target: improve panic & exit handling Implement this part of the spec: > The enclave must not rely on userspace to terminate other threads still running. Similarly, the enclave must not trust that it will no longer be entered by userspace, and it must safeguard against that in the entrypoints. Also use `UserRef` to access panic buffer r? @alexcrichton cc @VardhanThigle
2019-01-29Auto merge of #57808 - gnzlbg:ustdsimd, r=gnzlbgbors-17/+113
Update stdsimd This is the companion PR to https://github.com/rust-lang-nursery/stdsimd/pull/640 r? @alexcrichton
2019-01-29SGX target: improve panic & exit handlingJethro Beekman-22/+32
2019-01-29Update stdsimdgnzlbg-17/+113
2019-01-28Rollup merge of #57833 - jethrogb:jb/thread-spawn-unwrap, r=alexcrichtonMazdak Farrokhzad-1/+1
Print a slightly clearer message when failing to launch a thread As discussed in #46345, the `io::Error` you get when a thread fails to launch is of type `io::ErrorKind::WouldBlock`. This is super uninformative when an arbitrary `thread::spawn` fails somewhere in your code: ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "operation would block" }', src/libcore/result.rs:997:5 ``` This PR improves the situation a little bit by using `expect` instead of `unwrap`. I don't consider this a complete fix for #46345 though.
2019-01-27Change generator trait to use pinningWim Looman-1/+3
2019-01-27Auto merge of #57765 - Mark-Simulacrum:bootstrap-bump, r=alexcrichtonbors-16/+45
Bump bootstrap compiler to 1.33 beta r? @alexcrichton or @pietroalbini cc @rust-lang/release
2019-01-26Replace deprecated ATOMIC_INIT constsMark Rousskov-12/+45
2019-01-26Rollup merge of #57703 - m-ou-se:mutexguard-debug, r=cramertjMazdak Farrokhzad-3/+1
Make MutexGuard's Debug implementation more useful. Fixes #57702.
2019-01-26Bump bootstrap compiler to 1.33 betaMark Rousskov-4/+0
2019-01-24Rollup merge of #57867 - Aaron1011:fix/gen-future-doc, r=CentrilMazdak Farrokhzad-1/+1
Fix std::future::from_generator documentation This function takes a generator and wraps it in a future, not vice-versa.
2019-01-24Rollup merge of #57860 - jethrogb:jb/sgx-os-ffi, r=joshtriplettMazdak Farrokhzad-1/+111
Add os::fortanix_sgx::ffi module This uses the same byte slice accessors that Unix has. The [ABI specifies](https://docs.rs/fortanix-sgx-abi/0.3.2/fortanix_sgx_abi/struct.ByteBuffer.html) byte slices.
2019-01-24Rollup merge of #57803 - jethrogb:jb/sgx-unwind-version, r=alexcrichtonMazdak Farrokhzad-0/+15
Several changes to libunwind for SGX target Two fixes: * #34978 bites again! * __rust_alloc are actually private symbols. Add new public versions. Also, these ones are `extern "C"`. Upstream changes (https://github.com/fortanix/llvm-project/pull/2, https://github.com/fortanix/llvm-project/pull/3): * b7357de Avoid too new relocation types being emitted * 0feefe5 Use new symbol names to call Rust allocator Fixes https://github.com/fortanix/rust-sgx/issues/65
2019-01-24Rollup merge of #57380 - bearcage:master, r=alexcrichtonMazdak Farrokhzad-44/+83
Fix Instant/Duration math precision & associativity on Windows **tl;dr** Addition and subtraction on Duration/Instant are not associative on windows because we use the perfcounter frequency in every calculation instead of just when we measure time. This is my first contrib (PR or Issue) to Rust, so please lmk if I've done this wrong. I followed CONTRIBUTING to the extent I could given my system doesn't seem to be able to build the compiler with changes in the source tree. I also asked about this issue in #rust-beginners a week or so ago, before digging through libstd -- I'm unsure if there's a good way to follow up on that, but I'd be happy to update the docs on the timing structs if this fixes the problem. ## Issue The `Duration` type keeps seconds in the upper-64 and nanoseconds in the lower-32 bits. In theory doing math on these ought to be basically the same as doing math on any other 64 or 32 bit integral number. On windows (and I think macos too), however, our math gets messy because the Instant type stores the current point in time in units of HPET Performance Counter counts, not nanoseconds, and does unit conversions on every math operation, rather than just when we measure the time from the system clock. I tried this code: ``` use std::time::{Duration, Instant}; fn main() { let now = Instant::now(); let offset = Duration::from_millis(5); assert_eq!((now + offset) - now, (now - now) + offset); } ``` On UNIX machines (linux and macos) it behaves as you'd expect -- [no crash](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cf2206c0b7e07d8ecc7767a512364094). On Windows hosts, however, it blows up because of a precision problem in the Instant +/- Duration math: ``` C:\Users\aberg\work\timetest (master -> origin) λ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.02s Running `target\debug\timetest.exe` thread 'main' panicked at 'assertion failed: `(left == right)` left: `4.999914ms`, right: `5ms`', src\main.rs:6:5 note: Run with `RUST_BACKTRACE=1` for a backtrace. error: process didn't exit successfully: `target\debug\timetest.exe` (exit code: 101) C:\Users\aberg\work\timetest (master -> origin) λ cat src\main.rs use std::time::{Duration, Instant}; fn main() { let now = Instant::now(); let offset = Duration::from_millis(5); assert_eq!((now + offset) - now, (now - now) + offset); } ``` On windows I think this is a consequence of doing the HPET-PerfCounter-Unit conversion on each math operation. I suspect the reason it works on macs is that (from what I could find online) most apple machines report timing in nanoseconds anyway. For anyone interested, the equivalent functions on macos, with a little work to fish out the numerator/denominator from a timebase struct: * `QueryPerformanceCounter()` -> `mach_absolute_time()` * `QueryPerformanceFrequency()` -> `mach_timebase_info()` If this PR ends up working as I expect it to when CI runs the tests, I can make the same changes to the macos implementation. ## Potential Fix We ought to be able to sort this out by storing nanoseconds, rather than PerfCounter units, that way intermediate math is done in the most precise units we support and we're only doing unit conversions when we actually measure the system clock (and it might even translate to a small perf gain for people doing tons of Instant/Duration math). I believe this will address the underlying cause of #56034, and make the guessed epsilon constant from #56059 unnecessary. If it's of interest, I can write up how these timing types work on the tier 1 platforms to address #32626 as well, since I'm already in here figuring it out. ## This Patch To that end, I've got this patch, which I think should fix it on windows, but I'm having trouble testing it -- any time I change anything in libstd I start getting this error, which no amount of clean building seems to resolve: ``` C:\Users\aberg\work\rust (master -> origin) λ python x.py test --stage 0 --no-doc src/libstd Updating only changed submodules Submodules updated in 0.27 seconds Finished dev [unoptimized] target(s) in 2.41s Building stage0 std artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc) Finished release [optimized] target(s) in 6.78s Copying stage0 std from stage0 (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc / x86_64-pc-windows-msvc) Building stage0 test artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc) Compiling test v0.0.0 (C:\Users\aberg\work\rust\src\libtest) error[E0460]: found possibly newer version of crate `std` which `getopts` depends on --> src\libtest\lib.rs:36:1 | 36 | extern crate getopts; | ^^^^^^^^^^^^^^^^^^^^^ | = note: perhaps that crate needs to be recompiled? = note: the following crate versions were found: crate `std`: \\?\C:\Users\aberg\work\rust\build\x86_64-pc-windows-msvc\stage0-sysroot\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-d7a80ca2ae113c97.rlib crate `std`: \\?\C:\Users\aberg\work\rust\build\x86_64-pc-windows-msvc\stage0-sysroot\lib\rustlib\x86_64-pc-windows-msvc\lib\std-d7a80ca2ae113c97.dll crate `getopts`: \\?\C:\Users\aberg\work\rust\build\x86_64-pc-windows-msvc\stage0-test\x86_64-pc-windows-msvc\release\deps\libgetopts-ae40a96de5f5d144.rlib error: aborting due to previous error For more information about this error, try `rustc --explain E0460`. error: Could not compile `test`. To learn more, run the command again with --verbose. command did not execute successfully: "C:\\Users\\aberg\\work\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "build" "--target" "x86_64-pc-windows-msvc" "-j" "12" "--release" "--manifest-path" "C:\\Users\\aberg\\work\\rust\\src/libtest/Cargo.toml" "--message-format" "json" expected success, got: exit code: 101 failed to run: C:\Users\aberg\work\rust\build\bootstrap\debug\bootstrap test --stage 0 --no-doc src/libstd Build completed unsuccessfully in 0:00:20 ``` --- Since you wrote the linked PRs and might remember looking at related problems: r? @alexcrichton
2019-01-23Add a comment on the meaning of Instant t: DurationAlex Berghage-0/+2
2019-01-24Rollup merge of #57179 - Xaeroxe:patch-1, r=QuietMisdreavusMazdak Farrokhzad-6/+2
Update std/lib.rs docs to reflect Rust 2018 usage Fixes #56544 This paragraph was written for Rust 2015. Since 2018 has been stable for a while I think we can update it.
2019-01-23Fix std::future::from_generator documentationAaron Hill-1/+1
This function takes a generator and wraps it in a future, not vice-versa.
2019-01-23Add os::fortanix_sgx::ffi moduleJethro Beekman-1/+111
2019-01-22Rebase and fix new instantiation fnAlex Berghage-1/+1
2019-01-22Move Instant backing type to DurationAlex Berghage-22/+14
Per review comments, this commit switches out the backing type for Instant on windows to a Duration. Tests all pass, and the code's a lot simpler (plus it should be portable now, with the exception of the QueryPerformanceWhatever functions).
2019-01-22Simplify units in Duration/Instant math on WindowsAlex Berghage-42/+87
Right now we do unit conversions between PerfCounter measurements and nanoseconds for every add/sub we do between Durations and Instants on Windows machines. This leads to goofy behavior, like this snippet failing: ``` let now = Instant::now(); let offset = Duration::from_millis(5); assert_eq!((now + offset) - now, (now - now) + offset); ``` with precision problems like this: ``` thread 'main' panicked at 'assertion failed: `(left == right)` left: `4.999914ms`, right: `5ms`', src\main.rs:6:5 ``` To fix it, this changeset does the unit conversion once, when we measure the clock, and all the subsequent math in u64 nanoseconds. It also adds an exact associativity test to the `sys/time.rs` test suite to make sure we don't regress on this in the future.
2019-01-22dbg!() without parameters.Clar Fon-0/+6
2019-01-22Remove unused linksJacob Kiesel-2/+0
2019-01-22Print a slightly clearer message when failing to spawn a threadJethro Beekman-1/+1
2019-01-21Expose alloc/dealloc properly for SGX libunwindJethro Beekman-0/+15
2019-01-20Auto merge of #57655 - mtak-:fix-tls-dtors-macos, r=alexcrichtonbors-24/+45
OSX: fix #57534 registering thread dtors while running thread dtors r? @alexcrichton - "fast" `thread_local` destructors get run even on the main thread - "fast" `thread_local` dtors, can initialize other `thread_local`'s One corner case where this fix doesn't work, is when a C++ `thread_local` triggers the initialization of a rust `thread_local`. I did not add any std::thread specific flag to indicate that the thread is currently exiting, which would be checked before registering a new dtor (I didn't really know where to stick that). I think this does the trick tho! Let me know if anything needs tweaking/fixing/etc. resolves this for macos: https://github.com/rust-lang/rust/issues/28129 fixes: https://github.com/rust-lang/rust/issues/57534
2019-01-18Use `to_ne_bytes` for converting IPv4Address to octetsJakub Onderka-2/+1
It is easier and it should be also faster, because `to_ne_bytes` just calls `mem::transmute`.
2019-01-18Rollup merge of #57683 - xfix:patch-15, r=QuietMisdreavusMazdak Farrokhzad-2/+3
Document Unpin in std::prelude documentation
2019-01-18Rollup merge of #57654 - ehuss:fs-links, r=alexcrichtonMazdak Farrokhzad-5/+17
Add some links in std::fs. A few items were referenced, but did not have links.
2019-01-18Rollup merge of #57340 - eqrion:doc/c_variadic, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
Use correct tracking issue for c_variadic Fixes #57306
2019-01-18Auto merge of #56996 - clarcharr:spin_loop_hint, r=KodrAusbors-0/+1
Move spin_loop_hint to core::hint module As mentioned in #55002. The new name is kept unstable to decide whether the function should have `_hint` in its name.
2019-01-17Simplify Debug implementation of MutexGuard.Mara Bos-7/+1
Just transparently print the guarded data, instead of wrapping it in `MutexGuard { lock: Mutex { data: ... } }`.