about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-05-30Add hooks allowing to override the `oom` behaviorMike Hommey-2/+46
2018-05-29Auto merge of #50772 - nicokoch:fastcopy, r=alexcrichtonbors-0/+88
fs: copy: use copy_file_range on Linux Linux 4.5 introduced a new system call [copy_file_range](http://man7.org/linux/man-pages/man2/copy_file_range.2.html) to copy data from one file to another. This PR uses the new system call (if available). This has several advantages: 1. No need to constantly copy data from userspace to kernel space, if the buffer is small or the file is large 2. On some filesystems, like BTRFS, the kernel can leverage internal fs mechanisms for huge performance gains 3. Filesystems on the network dont need to copy data between the host and the client machine (they have to in the current read/write implementation) I have created a small library that also implements the new system call for some huge performance gains here: https://github.com/nicokoch/fastcopy Benchmark results are in the README
2018-05-29Fix additional nits:Nicolas Koch-7/+3
- compute bytes_to_copy more elegantly - add assert that written is 0 in fallback case
2018-05-30Pass a `Layout` to `oom`Mike Hommey-23/+63
As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent, there are use-cases where the OOM handler needs to know the size of the allocation that failed. The alignment might also be a cause for allocation failure, so providing it as well can be useful.
2018-05-28Stabilize SystemTime::UNIX_EPOCHThayne McCombs-2/+1
2018-05-28Use FIXME instead of TODO; Move bytes_to_copy calculation inside ifNicolas Koch-6/+7
branch
2018-05-26Rollup merge of #51056 - tbu-:pr_once_new, r=dtolnaykennytm-11/+12
Mention and use `Once::new` instead of `ONCE_INIT`
2018-05-26Rollup merge of #51014 - GuillaumeGomez:env_docs, r=QuietMisdreavuskennytm-2/+15
Add documentation about env! second argument Fixes #48044. r? @QuietMisdreavus
2018-05-24Add documentation about env! second argumentGuillaume Gomez-2/+15
2018-05-24Implement suggestions from the PRNicolas Koch-1/+3
- Move loading of atomic bool outside the loop - Add comment about TryFrom for future improvement
2018-05-24Update the `Once` docs to use `Once::new`Tobias Bucher-10/+10
2018-05-24Add `Once::new` as a way of constructing a `Once`Tobias Bucher-1/+2
2018-05-24remove collections::range::RangeArgumentCory Sherman-8/+0
was already moved to ops::RangeBounds (see #30877)
2018-05-17Switch to 1.26 bootstrap compilerMark Simulacrum-91/+3
2018-05-17Store ENOSYS in a global to avoid unnecessary system callsNicolas Koch-10/+25
2018-05-17Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichtonkennytm-0/+80
Implement From for more types on Cow This is basically https://github.com/rust-lang/rust/pull/48191, except that it should be implemented in a way that doesn't break third party crates.
2018-05-17Rollup merge of #50808 - SimonSapin:nonzero, r=alexcrichtonkennytm-7/+2
Stabilize num::NonZeroU* Tracking issue: https://github.com/rust-lang/rust/issues/49137
2018-05-17Rollup merge of #50736 - udoprog:env-try-op, r=shepmasterkennytm-12/+21
env: remove unwrap in examples in favor of try op
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-16Stabilize num::NonZeroU*Simon Sapin-3/+1
Tracking issue: https://github.com/rust-lang/rust/issues/49137
2018-05-16Remove unstable deprecated num::NonZeroI* typesSimon Sapin-4/+1
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-14env: remove unwrap in examples in favor of try opJohn-John Tedro-12/+21
2018-05-14read2: Use inner function instead of closureJohn-John Tedro-18/+19
2018-05-13Add “Examples” section header in f32/f64 doc comments.Corey Farwell-0/+152
This is recommend by [RFC 0505] and as far as I know, the only primitive types without this heading. [RFC 0505]: https://github.com/rust-lang/rfcs/blob/c892139be692586e0846fbf934be6fceec17f329/text/0505-api-comment-conventions.md#using-markdown
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-12fs::write: Add example writing a &strAaron DeVore-0/+1
2018-05-12Rollup merge of #50602 - Screwtapello:update-canonicalize-docs, r=cramertjMark Simulacrum-4/+11
Update canonicalize docs I was recently working with file-paths in Rust, and I felt let down by the `std::fs::canonicalize` docs, so I figured I should submit a PR with some suggestions. I was looking for a method to turn a relative path into an absolute path. The `canonicalize` docs didn't mention the words "relative" or "absolute", but they did mention resolving symlinks (which is a kind of canonicalisation and does not imply converting to absolute), so I assumed that's all it did. To remedy this, I've added the word "absolute" to the description of both `std::fs::canonicalize` and `std::path::Path::canonicalize`. After calling `canonicalize` on Windows, I ran into a bunch of other problems I would not have expected from the function's behaviour on Linux. Specifically, if you call `canonicalize` on a path: - it's allowed to be much longer than it otherwise would - `.join("a/slash/delimited/path")` gives you a broken path that Windows can't use, where the same operation would have worked perfectly without `canonicalize` (if the path were short enough) - the resulting path may confuse other Windows programs if you pass it to them on the command-line, or write it to a config file that they read, etc. ...so I tried to summarize those behaviours too. If I understand correctly, those behaviours are a side-effect of calling `GetFinalPathNameByHandle`, and the documentation says `canonicalize` might not call that function in future, so maybe those side-effects shouldn't be part of the function's documentation. However, I bet there's a lot of applications deliberately calling `canonicalize` just for the path-length-extension alone, so that particular side-effect is de-facto part of the `canonicalize` interface.
2018-05-12Rollup merge of #50550 - llogiq:fmt-result, r=petrochenkovMark Simulacrum-5/+5
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-10Auto merge of #50611 - alexcrichton:rollup, r=alexcrichtonbors-21/+23
Rollup of 18 pull requests Successful merges: - #49423 (Extend tests for RFC1598 (GAT)) - #50010 (Give SliceIndex impls a test suite of girth befitting the implementation (and fix a UTF8 boundary check)) - #50447 (Fix update-references for tests within subdirectories.) - #50514 (Pull in a wasm fix from LLVM upstream) - #50524 (Make DepGraph::previous_work_products immutable) - #50532 (Don't use Lock for heavily accessed CrateMetadata::cnum_map.) - #50538 ( Make CrateNum allocation more thread-safe. ) - #50564 (Inline `Span` methods.) - #50565 (Use SmallVec for DepNodeIndex within dep_graph.) - #50569 (Allow for specifying a linker plugin for cross-language LTO) - #50572 (Clarify in the docs that `mul_add` is not always faster.) - #50574 (add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022)) - #50575 (std: Avoid `ptr::copy` if unnecessary in `vec::Drain`) - #50588 (Move "See also" disambiguation links for primitive types to top) - #50590 (Fix tuple struct field spans) - #50591 (Restore RawVec::reserve* documentation) - #50598 (Remove unnecessary mutable borrow and resizing in DepGraph::serialize) - #50606 (Retry when downloading the Docker cache.) Failed merges: - #50161 (added missing implementation hint) - #50558 (Remove all reference to DepGraph::work_products)
2018-05-10Auto merge of #50331 - MartinHusemann:master, r=Kimundibors-2/+11
Map the stack guard page with max protection on NetBSD 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. Fixes #50313
2018-05-10Rollup merge of #50588 - ExpHP:i-can-see-my-house-from-here, r=frewsxcvAlex Crichton-17/+15
Move "See also" disambiguation links for primitive types to top Closes #50384. <details> <summary>Images</summary> ![rust-slice](https://user-images.githubusercontent.com/1411280/39843148-caa41c3e-53b7-11e8-8123-b57c25a4d9e0.png) ![rust-isize](https://user-images.githubusercontent.com/1411280/39843146-ca94b384-53b7-11e8-85f3-3f5e5d353a05.png) </details> r? @steveklabnik
2018-05-10Rollup merge of #50572 - frewsxcv:frewsxcv-fma, r=sfacklerAlex Crichton-4/+8
Clarify in the docs that `mul_add` is not always faster. Fixes https://github.com/rust-lang/rust/issues/49842. Other resources: - https://users.rust-lang.org/t/why-does-the-mul-add-method-produce-a-more-accurate-result-with-better-performance/1626 - https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
2018-05-10fs::canonicalize has some important portability concerns.Tim Allen-0/+7
2018-05-10Mention that fs::canonicalize makes paths absolute.Tim Allen-4/+4
2018-05-09make std::str link into See also linkMichael Lamparski-5/+3
also make a drive-by typo fix
2018-05-09move See also links to topMichael Lamparski-12/+12
2018-05-09Clarify in the docs that `mul_add` is not always faster.Corey Farwell-4/+8
Fixes https://github.com/rust-lang/rust/issues/49842. Other resources: - https://users.rust-lang.org/t/why-does-the-mul-add-method-produce-a-more-accurate-result-with-better-performance/1626 - https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
2018-05-09Rollup merge of #50511 - Manishearth:must-use, r=QuietMisdreavuskennytm-4/+4
Add some explanations for #[must_use] `#[must_use]` can be given a string argument which is shown whilst warning for things. We should add a string argument to most of the user-exposed ones. I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
2018-05-09Rollup merge of #49988 - clarcharr:never_docs, r=steveklabnikkennytm-0/+53
Mention Result<!, E> in never docs. Fixes #48096.
2018-05-09Fix typoGeorge Burton-1/+1
2018-05-09Update features to 1.28.0George Burton-10/+10
2018-05-09use fmt::Result where applicableAndre Bogus-5/+5
2018-05-07Add explanation for #[must_use] on mutex guardsManish Goregaokar-4/+4