about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2018-05-17Rollup merge of #50726 - udoprog:read2-inner-fn, r=alexcrichtonkennytm-18/+19
read2: Use inner function instead of closure Very minor thing, but there doesn't appear to be a reason to use a closure here. Generated code is identical in my tests, but I believe it's clearer that nothing from the environment is being used.
2018-05-16Rollup merge of #50638 - tbu-:pr_open_cloexec_once, r=nagisakennytm-4/+44
Don't unconditionally set CLOEXEC twice on every fd we open on Linux Previously, every `open64` was accompanied by a `ioctl(…, FIOCLEX)`, because some old Linux version would ignore the `O_CLOEXEC` flag we pass to the `open64` function. Now, we check whether the `CLOEXEC` flag is set on the first file we open – if it is, we won't do extra syscalls for every opened file. If it is not set, we fall back to the old behavior of unconditionally calling `ioctl(…, FIOCLEX)` on newly opened files. On old Linuxes, this amounts to one extra syscall per process, namely the `fcntl(…, F_GETFD)` call to check the `CLOEXEC` flag. On new Linuxes, this reduces the number of syscalls per opened file by one, except for the first file, where it does the same number of syscalls as before (`fcntl(…, F_GETFD)` to check the flag instead of `ioctl(…, FIOCLEX)` to set it).
2018-05-16Fix large file copies on 32 bit platformsNicolas Koch-2/+6
2018-05-16Adjust len in every iterationNicolas Koch-1/+2
2018-05-16Add clarifying comment about offset argumentNicolas Koch-0/+2
2018-05-16Use copy_file_range on android alsoNicolas Koch-3/+3
2018-05-15fs: use copy_file_range on linuxNicolas Koch-0/+67
2018-05-14Don't unconditionally set CLOEXEC twice on every fd we open on LinuxTobias Bucher-4/+44
Previously, every `open64` was accompanied by a `ioctl(…, FIOCLEX)`, because some old Linux version would ignore the `O_CLOEXEC` flag we pass to the `open64` function. Now, we check whether the `CLOEXEC` flag is set on the first file we open – if it is, we won't do extra syscalls for every opened file. If it is not set, we fall back to the old behavior of unconditionally calling `ioctl(…, FIOCLEX)` on newly opened files. On old Linuxes, this amounts to one extra syscall per process, namely the `fcntl(…, F_GETFD)` call to check the `CLOEXEC` flag. On new Linuxes, this reduces the number of syscalls per opened file by one, except for the first file, where it does the same number of syscalls as before (`fcntl(…, F_GETFD)` to check the flag instead of `ioctl(…, FIOCLEX)` to set it).
2018-05-14read2: Use inner function instead of closureJohn-John Tedro-18/+19
2018-05-12Do not silently truncate offsets for `read_at`/`write_at` on emscriptenTobias Bucher-2/+16
Generate an IO error if the offset is out of bounds for the system call.
2018-05-12Rollup merge of #50550 - llogiq:fmt-result, r=petrochenkovMark Simulacrum-2/+2
use fmt::Result where applicable This is a quite boring PR, but I think the type alias improves readability, so why not use it?
2018-05-09use fmt::Result where applicableAndre Bogus-2/+2
2018-05-02Add comments and unify guard page setup.Martin Husemann-16/+13
While currently only NetBSD seems to be affected, all systems implementing PAX MPROTECT in strict mode need this treatment, and it does not hurt others.
2018-04-30Map the stack guard page with max protection on NetBSDMartin Husemann-4/+16
On NetBSD the initial mmap() protection of a mapping can not be made less restrictive with mprotect(). So when mapping a stack guard page, use the maximum protection we ever want to use, then mprotect() it to the permission we want it to have initially.
2018-04-24Auto merge of #50079 - NickAtAccuPS:android_abstract_socket, r=sfacklerbors-1/+4
Android abstract unix domain sockets AddressKind correction The prior check causes abstract unix domain sockets to return AddressKind::Unnamed instead of AddressKind::Abstract on Android. Other than the immediately proceeding comment "macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses" the check as-implemented does not seem to have alternative explanation. I couldn't find an alternative explanation while stepping though git blame. I suspect the AddressKind::Unnamed nonzero check should instead be if macos, length 16, and zeroed array. @sfackler could you comment on this, the code as-is is the same from your initial addition of abstract uds support.
2018-04-24Rollup merge of #49829 - ecstatic-morse:os-docs, r=steveklabnikkennytm-47/+96
Add doc links to `std::os` extension traits Addresses a small subset of #29367. This adds documentation links to the original type for various OS-specific extension traits, and uses a common sentence for introducing such traits (which now consistently ends in a period).
2018-04-19Rustfmt result (for relevant changes) to satisfy Travis line length check.Nicholas Rishel-1/+4
Signed-off-by: Nicholas Rishel <nick@accups.com>
2018-04-19The prior check causes abstract unix domain sockets to return unnamed on ↵Nicholas Rishel-1/+1
Android. Signed-off-by: Nicholas Rishel <nick@accups.com>
2018-04-16Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfacklerbors-2/+22
std: Minimize size of panicking on wasm This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-17Rollup merge of #49646 - glandium:uninitialized-box, r=alexcrichtonkennytm-1/+1
Use box syntax instead of Box::new in Mutex::remutex on Windows The Box::new(mem::uninitialized()) pattern actually actively copies uninitialized bytes from the stack into the box, which is a waste of time. Using the box syntax instead avoids the useless copy.
2018-04-17Rollup merge of #49606 - varkor:pipe-repair, r=alexcrichtonkennytm-2/+2
Prevent broken pipes causing ICEs As the private `std::io::print_to` panics if there is an I/O error, which is used by `println!`, the compiler would ICE if one attempted to use a broken pipe (e.g. `rustc --help | false`). This introduces a new (private) macro `try_println!` which allows us to avoid this. As a side note, it seems this macro might be useful publicly (and actually there seems to be [a crate specifically for this purpose](https://crates.io/crates/try_print/)), though that can probably be left for a future discussion. One slight alternative approach would be to simply early exit without an error (i.e. exit code `0`), which [this comment](https://github.com/rust-lang/rust/issues/34376#issuecomment-377822526) suggests is the usual approach. I've opted not to take that approach initially, because I think it's more helpful to know when there is a broken pipe. Fixes #34376.
2018-04-14Prefer unprefixed paths for well known structsDylan MacKenzie-23/+23
2018-04-14Add doc links to `std::os` extension traitsDylan MacKenzie-51/+100
Add documentation links to the original type for various OS-specific extension traits and normalize the language for introducing such traits. Also, remove some outdated comments around the extension trait definitions.
2018-04-13std: Minimize size of panicking on wasmAlex Crichton-2/+22
This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-12Import the `alloc` crate as `alloc_crate` in stdSimon Sapin-6/+6
… to make the name `alloc` available.
2018-04-12Move Utf8Lossy decoder to libcoreSimon Sapin-3/+3
2018-04-11Prevent EPIPE causing ICEs in rustc and rustdocvarkor-2/+2
2018-04-07Rollup merge of #49702 - alexcrichton:inline-methods, r=Mark-Simulacrumkennytm-0/+2
std: Inline some Termination-related methods These were showing up in tests and in binaries but are trivially optimize-able away, so add `#[inline]` attributes so LLVM has an opportunity to optimize them out.
2018-04-05Rollup merge of #49686 - memoryleak47:typo, r=alexcrichtonAlex Crichton-1/+1
typos
2018-04-05std: Inline some Termination-related methodsAlex Crichton-0/+2
These were showing up in tests and in binaries but are trivially optimize-able away, so add `#[inline]` attributes so LLVM has an opportunity to optimize them out.
2018-04-05typosmemoryleak47-1/+1
2018-04-05Rollup merge of #49637 - tmccombs:parent-id-stabilize, r=sfacklerkennytm-1/+1
Stabilize parent_id() Fixes #46104
2018-04-04Use box syntax instead of Box::new in Mutex::remutex on WindowsMike Hommey-1/+1
The Box::new(mem::uninitialized()) pattern actually actively copies uninitialized bytes from the stack into the box, which is a waste of time. Using the box syntax instead avoids the useless copy.
2018-04-04Auto merge of #48575 - ishitatsuyuki:unix-no-thread, r=alexcrichtonbors-10/+42
rustc_driver: get rid of the extra thread **Do not rollup** We can alter the stack size afterwards on Unix. Having a separate thread causes poor debugging experience when interrupting with signals. I have to get the backtrace of the all thread, as the main thread is waiting to join doing nothing else. This patch allows me to just run `bt` to get the desired backtrace.
2018-04-03Stabilize parent_id()Thayne McCombs-1/+1
Fixes #46104
2018-04-03Fix importsTatsuyuki Ishi-1/+1
2018-03-28Auto merge of #49460 - kennytm:rollup, r=kennytmbors-0/+20
Rollup of 12 pull requests - Successful merges: #49243, #49329, #49364, #49400, #49405, #49427, #49428, #49429, #49439, #49442, #49444, #49452 - Failed merges:
2018-03-28Auto merge of #49357 - frewsxcv:frewsxcv-termination-doc-examples, ↵bors-238/+240
r=GuillaumeGomez Remove hidden `foo` functions from doc examples; use `Termination` trait. Fixes https://github.com/rust-lang/rust/issues/49233. Easier to review with the white-space ignoring `?w=1` feature: https://github.com/rust-lang/rust/pull/49357/files?w=1
2018-03-28Rollup merge of #49400 - Diggsey:shrink-to, r=joshtriplettkennytm-0/+20
Implement `shrink_to` method on collections Fixes #49385
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-238/+240
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-03-28Use mprotect instead of mmapTatsuyuki Ishi-3/+2
2018-03-27Implement `shrink_to` method on collectionsDiggory Blake-0/+20
2018-03-25Use a more conservative way to deinit stack guardTatsuyuki Ishi-5/+15
2018-03-25Auto merge of #49315 - TheDan64:smaller_unsafe_block, r=joshtriplettbors-7/+5
Reduce scope of unsafe block in sun_path_offset I reduced the scope of the unsafe block to the `uninitialized` call which is the only actual unsafe bit.
2018-03-24Fix build on non-Unix platformsTatsuyuki Ishi-0/+5
2018-03-23Reduce scope of unsafe block in sun_path_offsetDaniel Kolsoi-7/+5
2018-03-23Rollup merge of #48624 - bdrewery:freebsd-posix-spawn, r=alexcrichtonAlex Crichton-28/+159
Command: Support posix_spawn() on FreeBSD/OSX/GNU Linux
2018-03-22Command::env_saw_path() may be unused on platforms not using posix_spawn()Bryan Drewery-0/+1
2018-03-21Deprecate the AsciiExt trait in favor of inherent methodsSimon Sapin-1/+0
The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes https://github.com/rust-lang/rust/issues/39658
2018-03-20Refactor the stack addr aligning code into a functionTatsuyuki Ishi-16/+16