about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2019-02-28Fix #[macro_use] extern crate in sys/cloudabiTaiki Endo-2/+1
2019-02-28libstd => 2018Taiki Endo-1243/+1241
2019-02-26Auto merge of #58357 - sfackler:vectored-io, r=alexcrichtonbors-81/+525
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 redoxSteven Fackler-3/+3
2019-02-24Fix sgxSteven Fackler-3/+3
2019-02-24Fix cloudabiSteven Fackler-1/+9
2019-02-24Rollup merge of #58454 - pitdicker:windows_stdio, r=alexcrichtonMazdak Farrokhzad-241/+273
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-24Rollup merge of #58442 - cuviper:unix-weak, r=alexcrichtonMazdak Farrokhzad-8/+7
Simplify the unix `Weak` functionality - We can avoid allocation by adding a NUL to the function name. - We can get `Option<F>` directly, rather than aliasing the inner `AtomicUsize`.
2019-02-23Correct OpenOptions::security_qos_flags documentationPaul Dicker-6/+20
2019-02-23Remove pub(crate) from stderr_rawPaul Dicker-4/+4
2019-02-23Rollup merge of #58453 - jethrogb:jb/sgx-panic-abort, r=nagisaMazdak Farrokhzad-0/+1
SGX target: fix panic = abort What is the difference between `no_mangle` and `rustc_std_internal_symbol`?
2019-02-22Rollup merge of #58059 - RalfJung:before_exec, r=alexcrichtonMazdak Farrokhzad-12/+56
deprecate before_exec in favor of unsafe pre_exec Fixes https://github.com/rust-lang/rust/issues/39575 As per the [lang team decision](https://github.com/rust-lang/rust/issues/39575#issuecomment-442993358): > The language team agreed that before_exec should be unsafe, and leaves the details of a transition plan to the libs team. Cc @alexcrichton @rust-lang/libs how would you like to proceed?
2019-02-20Use standard Read/Write traits in sys::stdioPaul Dicker-75/+114
2019-02-20Address review commentsPaul Dicker-22/+36
2019-02-20Refactor Windows stdio and remove stdin double bufferingPaul Dicker-116/+178
2019-02-20Remove unused Read implementation on sys::Windows::StdinPaul Dicker-9/+0
2019-02-20Remove sys::*::Stderr Write implementationPaul Dicker-78/+4
2019-02-16Rollup merge of #58438 - cuviper:posix_spawn_file_actions_addchdir_np, ↵kennytm-2/+22
r=alexcrichton Use posix_spawn_file_actions_addchdir_np when possible This is a non-POSIX extension implemented in Solaris and in glibc 2.29. With this we can still use `posix_spawn()` when `Command::current_dir()` has been set, otherwise we fallback to `fork(); chdir(); exec()`.
2019-02-15Fix SECURITY_SQOS_PRESENT missingPaul Dicker-2/+5
if security_qos_flags(SECURITY_ANONYMOUS) is set
2019-02-14SGX target: fix panic = abortJethro Beekman-0/+1
2019-02-13impl Deref/DerefMut for IoVec typesSteven Fackler-22/+22
Returning &'a mut [u8] was unsound, and we may as well just have them directly deref to their slices to make it easier to work with them.
2019-02-13Add vectored read and write supportSteven Fackler-79/+515
This functionality has lived for a while in the tokio ecosystem, where it can improve performance by minimizing copies.
2019-02-13Return without a reference in unix Weak::get()Josh Stone-5/+4
2019-02-13Avoid allocation in std::sys::unix::weakJosh Stone-3/+3
If we add a terminating NUL to the name in the `weak!` macro, then `fetch()` can use `CStr::from_bytes_with_nul()` instead of `CString`.
2019-02-13Use posix_spawn_file_actions_addchdir_np when possibleJosh Stone-2/+22
This is a non-POSIX extension implemented in Solaris and in glibc 2.29. With this we can still use `posix_spawn()` when `Command::current_dir()` has been set, otherwise we fallback to `fork(); chdir(); exec()`.
2019-02-13Auto merge of #58235 - jethrogb:jb/sgx-usercall-internals, r=alexcrichtonbors-81/+59
SGX target: simplify usercall internals This moves logic from assembly to Rust and removes the special case for exit/panic handling, merging it with regular usercall handling. Also, this fixes a bug in the exit usercall introduced in a75ae00. The bug would make regular exits look like panics with high probability. It would also with some probability leak information through uncleared registers. cc @VardhanThigle r? @alexcrichton
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-137/+142
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-11remove "experimental" wording from std::os::unixAndy Russell-1/+1
2019-02-10libs: doc commentsAlexander Regueiro-125/+130
2019-02-10tests: doc commentsAlexander Regueiro-12/+12
2019-02-10Auto merge of #58361 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-3/+3
Rollup of 16 pull requests Successful merges: - #57259 (Update reference of rlibc crate to compiler-builtins crate) - #57740 (Use `to_ne_bytes` for converting IPv4Addr to octets) - #57926 (Tiny expansion to docs for `core::convert`.) - #58157 (Add Cargo.lock automatically adding message) - #58203 (rustdoc: display sugared return types for async functions) - #58243 (Add trait alias support in rustdoc) - #58262 (Add #[must_use] message to Fn* traits) - #58295 (std::sys::unix::stdio: explain why we do into_raw) - #58297 (Cleanup JS a bit) - #58317 (Some writing improvement, conciseness of intro) - #58324 (miri: give non-generic functions a stable address) - #58332 (operand-to-place copies should never be overlapping) - #58345 (When there are multiple filenames, print what got interpreted as filenames) - #58346 (rpath computation: explain why we pop()) - #58350 (Fix failing tidy (line endings on Windows)) - #58352 (miri value visitor: use `?` in macro) Failed merges: r? @ghost
2019-02-10Rollup merge of #58295 - RalfJung:stdio, r=alexcrichtonGuillaume Gomez-3/+3
std::sys::unix::stdio: explain why we do into_raw I was quite puzzled why someone would call `into_raw` and then ignore the result.
2019-02-10Auto merge of #58129 - RalfJung:maybe-uninit, r=cramertjbors-2/+2
MaybeUninit: some docs, rename into_inner -> into_initialized, return &mut from set
2019-02-10fix SGX build failuresRalf Jung-2/+2
2019-02-08std::sys::unix::stdio: explain why we do into_rawRalf Jung-3/+3
2019-02-07Rollup merge of #58136 - abonander:doc-win-stdio-unicode, r=dtolnaykennytm-1/+3
Improve error message and docs for non-UTF-8 bytes in stdio on Windows This should make debugging problems like abonander/multipart#106 significantly more straightforward in the future. cc #23344, @retep998 @alexcrichton Not sure who do r? so I'll let rust-highfive pick one.
2019-02-06SGX target: simplify usercall internalsJethro Beekman-81/+59
This moves logic from assembly to Rust and removes the special case for exit/panic handling, merging it with regular usercall handling. Also, this fixes a bug in the exit usercall introduced in a75ae00. The bug would make regular exits look like panics with high probability. It would also with some probability leak information through uncleared registers.
2019-02-06Rollup merge of #58182 - jethrogb:jb/sgx-bytebuffer-len-0, r=joshtriplettkennytm-2/+8
SGX target: handle empty user buffers correctly Also, expose correct items in `os::fortanix_sgx::usercalls::alloc` * [read_alloc documentation](https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.read_alloc) * [Clarified ByteBuffer documentation](https://github.com/fortanix/rust-sgx/pull/94/files#diff-ca843ad9e25cacd63a80579c0f7efa56) r? @joshtriplett
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/+3
cc #23344
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-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-01Fix `std::os::fortanix_sgx::usercalls::raw::UsercallNrs`Jethro Beekman-4/+9
Fixes https://github.com/fortanix/rust-sgx/issues/88