about summary refs log tree commit diff
path: root/src/libstd/sys/sgx
AgeCommit message (Collapse)AuthorLines
2019-10-25forgot pushfq/popqfq: fixedRaoul Strackx-0/+2
2019-10-25cleaning up codeRaoul Strackx-9/+4
2019-10-25removed unnecessary pushRaoul Strackx-1/+0
2019-10-21fixed ac vulnerabilityRaoul Strackx-0/+10
2019-09-05std: Improve downstream codegen in `Command::env`Alex Crichton-3/+5
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-30Fix unlock ordering in SGX synchronization primitivesJethro Beekman-20/+32
2019-08-08Use associated_type_bounds where applicable - closes #61738Ilija Tovilo-2/+10
2019-08-03Add {IoSlice, IoSliceMut}::advanceThomas de Zeeuw-0/+14
2019-07-05Remove last use of mem::uninitialized in SGXJethro Beekman-3/+1
2019-07-04Permit use of mem::uninitialized via allow(deprecated)Mark Rousskov-0/+2
2019-05-25std: Depend on `backtrace` crate from crates.ioAlex Crichton-100/+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-02Fix potential integer overflow in SGX memory range calculation.Jethro Beekman-7/+17
Thanks to Eduard Marin and David Oswald at the University of Burmingham, and Jo Van Bulck at KU Leuven for discovering this issue.
2019-04-29SGX target: implemented vectored I/OJethro Beekman-13/+50
2019-04-29SGX target: don't unwind on usercall index out of boundsJethro Beekman-2/+10
2019-04-27Stabilized vectored IOSteven Fackler-17/+17
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-16SGX target: change re-entry abort logicJethro Beekman-19/+11
2019-04-14Rollup merge of #59852 - alexcrichton:more-vectored, r=sfacklerMazdak Farrokhzad-6/+19
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-14Rollup merge of #59818 - crlf0710:eliminate_libstd_fnbox, r=cramertjMazdak Farrokhzad-5/+3
Eliminate `FnBox` usages from libstd.
2019-04-10SGX target: fix cfg(test) buildJethro Beekman-3/+3
2019-04-10std: Add `{read,write}_vectored` for more typesAlex Crichton-6/+19
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-5/+3
2019-04-06Rollup merge of #59624 - jethrogb:jb/sgx-unwind-syms, r=alexcrichtonMazdak Farrokhzad-41/+44
SGX target: Use linker option to avoid code CGU assignment kludge cc @VardhanThigle @faern
2019-04-01SGX target: Use linker option to avoid code CGU assignment kludgeJethro Beekman-41/+44
2019-04-01SGX target: convert a bunch of panics to abortsJethro Beekman-48/+52
2019-03-31libstd: deny(elided_lifetimes_in_paths), fixes in sgxMazdak Farrokhzad-19/+20
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-14/+14
2019-03-28Fix missed fn rename in #59284Jethro Beekman-1/+1
2019-03-27Rollup merge of #59284 - RalfJung:maybe-uninit, r=sfacklerJosh Stone-5/+5
adjust MaybeUninit API to discussions uninitialized -> uninit into_initialized -> assume_init read_initialized -> read set -> write
2019-03-26fix some uses I missedRalf Jung-5/+5
2019-03-26Rollup merge of #59374 - faern:simplify-checked-duration-since, r=shepmasterMazdak Farrokhzad-2/+2
Simplify checked_duration_since This follows the same design as we updated to in #56490. Internally, all the system specific time implementations are checked, no panics. Then the panicking publicly exported API can just call the checked version of itself and make do with a single panic (`expect`) at the top. Since the internal sys implementations are now checked, this gets rid of the extra `if self >= &earlier` check in `checked_duration_since`. Except likely making the generated machine code simpler, it also reduces the algorithm from "Check panic condition -> call possibly panicking method" to just "call non panicking method". Added two test cases: * Edge case: Make sure `checked_duration_since` on two equal `Instant`s produce a zero duration, not a `None`. * Most common/intended usage: Make sure `later.checked_duration_since(earlier)`, returns an expected value.
2019-03-26Auto merge of #59136 - jethrogb:jb/sgx-std-test, r=sanxiynbors-59/+137
SGX target: fix std unit tests This fixes some tests and some code in the SGX sys implementation to make the `std` unit test suite pass. #59009 must be merged first.
2019-03-25SGX target: fix std unit testsJethro Beekman-59/+137
2019-03-22Update sys::time impls to have checked_sub_instantLinus Färnstrand-2/+2
2019-03-22Auto merge of #59370 - Centril:rollup, r=Centrilbors-0/+4
Rollup of 18 pull requests Successful merges: - #59106 (Add peer_addr function to UdpSocket) - #59170 (Add const generics to rustdoc) - #59172 (Update and clean up several parts of CONTRIBUTING.md) - #59190 (consistent naming for Rhs type parameter in libcore/ops) - #59236 (Rename miri component to miri-preview) - #59266 (Do not complain about non-existing fields after parse recovery) - #59273 (some small HIR doc improvements) - #59291 (Make Option<ThreadId> no larger than ThreadId, with NonZeroU64) - #59297 (convert field/method confusion help to suggestions) - #59304 (Move some bench tests back from libtest) - #59309 (Add messages for different verbosity levels. Output copy actions.) - #59321 (Unify E0109, E0110 and E0111) - #59322 (Tweak incorrect escaped char diagnostic) - #59323 (use suggestions for "enum instead of variant" error) - #59327 (Add NAN test to docs) - #59329 (cleanup: Remove compile-fail-fulldeps directory again) - #59347 (Move one test from run-make-fulldeps to ui) - #59360 (Add tracking issue number for `seek_convenience`) Failed merges: r? @ghost
2019-03-22Rollup merge of #59106 - LinusU:udp-peer-addr, r=kennytmMazdak Farrokhzad-0/+4
Add peer_addr function to UdpSocket Fixes #59104 This is my first pull request to Rust, so opening early for some feedback. My biggest question is: where do I add tests? Any comments very much appreciated!
2019-03-22Auto merge of #58953 - jethrogb:jb/unify-ffi, r=alexcrichtonbors-285/+35
Unify OsString/OsStr for byte-based implementations As requested in #57860 r? @joshtriplett
2019-03-21Unify OsString/OsStr for byte-based implementationsJethro Beekman-285/+35
2019-03-16Rollup merge of #59009 - sfackler:fix-sgx-vectors, r=alexcrichtonkennytm-12/+4
Fix SGX implementations of read/write_vectored.
2019-03-16Add peer_addr function to UdpSocketLinus Unnebäck-0/+4
2019-03-16Rollup merge of #58949 - jethrogb:jb/sgx-thread-id, r=joshtriplettkennytm-0/+1
SGX target: Expose thread id function in os module In order to call `std::os::fortanix_sgx::usercalls::send`, you need the thread id. This exposes it through another function in `std::os::fortanix_sgx`. I looked at how other platforms do this. On Windows and `cfg(unix)` you can get the OS handle from a `thread::JoinHandle`, but that's not sufficient, I need it for a `thread::Thread`. In the future, this functionality could be added to `thread::Thread` and this platform can follow suit. r? @joshtriplett
2019-03-09Use lifetime contravariance to elide more lifetimes in core+alloc+stdScott McMurray-2/+2
2019-03-07Always call read/write from default vectored io methodsSteven Fackler-8/+2
2019-03-07Fix SGX implementations of read/write_vectored.Steven Fackler-12/+10
2019-03-05SGX target: Expose thread id function in os moduleJethro Beekman-0/+1
2019-02-28Fix some imports and pathsTaiki Endo-1/+1
2019-02-28libstd => 2018Taiki Endo-161/+162
2019-02-26Auto merge of #58357 - sfackler:vectored-io, r=alexcrichtonbors-27/+75
Add vectored read and write support This functionality has lived for a while in the tokio ecosystem, where it can improve performance by minimizing copies. r? @alexcrichton
2019-02-24Fix sgxSteven Fackler-3/+3
2019-02-24Rollup merge of #58454 - pitdicker:windows_stdio, r=alexcrichtonMazdak Farrokhzad-19/+12
Refactor Windows stdio and remove stdin double buffering I was looking for something nice and small to work on, tried to tackle a few FIXME's in Windows stdio, and things grew from there. This part of the standard library contains some tricky code, and has changed over the years to handle more corner cases. It could use some refactoring and extra comments. Changes/fixes: - Made `StderrRaw` `pub(crate)`, to remove the `Write` implementations on `sys::Stderr` (used unsynchronised for panic output). - Remove the unused `Read` implementation on `sys::windows::stdin` - The `windows::stdio::Output` enum made sense when we cached the handles, but we can use simple functions like `is_console` now that we get the handle on every read/write - `write` can now calculate the number of written bytes as UTF-8 when we can't write all `u16`s. - If `write` could only write one half of a surrogate pair, attempt another write for the other because user code can't reslice in any way that would allow us to write it otherwise. - Removed the double buffering on stdin. Documentation on the unexposed `StdinRaw` says: 'This handle is not synchronized or buffered in any fashion'; which is now true. - `sys::windows::Stdin` now always only partially fills its buffer, so we can guarantee any arbitrary UTF-16 can be re-encoded without losing any data. - `sys::windows::STDIN_BUF_SIZE` is slightly larger to compensate. There should be no real change in the number of syscalls the buffered `Stdin` does. This buffer is a little larger, while the extra buffer on Stdin is gone. - `sys::windows::Stdin` now attempts to handle unpaired surrogates at its buffer boundary. - `sys::windows::Stdin` no langer allocates for its buffer, but the UTF-16 decoding still does. ### Testing I did some manual testing of reading and writing to console. The console does support UTF-16 in some sense, but doesn't supporting displaying characters outside the BMP. - compile stage 1 stdlib with a tiny value for `MAX_BUFFER_SIZE` to make it easier to catch corner cases - run a simple test program that reads on stdin, and echo's to stdout - write some lines with plenty of ASCII and emoji in a text editor - copy and paste in console to stdin - return with `\r\n\` or CTRL-Z - copy and paste in text editor - check it round-trips ----- Fixes https://github.com/rust-lang/rust/issues/23344. All but one of the suggestions in that issue are now implemented. the missing one is: > * When reading data, we require the entire set of input to be valid UTF-16. We should instead attempt to read as much of the input as possible as valid UTF-16, only returning an error for the actual invalid elements. For example if we read 10 elements, 5 of which are valid UTF-16, the 6th is bad, and then the remaining are all valid UTF-16, we should probably return the first 5 on a call to `read`, then return an error, then return the remaining on the next call to `read`. Stdin in Console mode is dealing with text directly input by a user. In my opinion getting an unpaired surrogate is quite unlikely in that case, and a valid reason to error on the entire line of input (which is probably short). Dealing with it is incompatible with an unbuffered stdin, which seems the more interesting guarantee to me.
2019-02-20Use standard Read/Write traits in sys::stdioPaul Dicker-8/+14