about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-06-02Clarify the difference between get_mut and into_mut for OccupiedEntryPhlosioneer-2/+6
The examples for both hash_map::OccupiedEntry::get_mut and hash_map::OccupiedEntry::into_mut were almost identical. This led to some confusion over the difference, namely why you would ever use get_mut when into_mut gives alonger lifetime. Reddit thread: https://www.reddit.com/r/rust/comments/8a5swr/why_does_hashmaps This commit adds two lines and a comment to the example, to show that the entry object can be re-used after calling get_mut.
2018-06-02removes tabsPslydhh-8/+6
2018-06-02remove trailing whitespacePslydhh-6/+6
remove trailing whitespace
2018-06-02park():prohibit spurious wakeups in next parkPslydhh-2/+10
should consume this notification, so prohibit spurious wakeups in next park
2018-06-02Auto merge of #51270 - nicokoch:issue-51266, r=TimNNbors-5/+12
fs: copy: Add EPERM to fallback error conditions Fixes #51266
2018-06-01Rollup merge of #51272 - steveklabnik:remove_feature_flag, r=QuietMisdreavusMark Simulacrum-2/+0
Remove feature flag from fs::read_to_string example This is stable, and so no longer needed
2018-06-01Simplify HashMap layout calculation by using LayoutAmanieu d'Antras-107/+13
2018-06-01Auto merge of #51264 - glandium:oom, r=alexcrichtonbors-10/+12
Make the OOM hook return `()` rather than `!` Per discussion in https://github.com/rust-lang/rust/issues/51245#issuecomment-393651083 This allows more flexibility in what can be done with the API. This also splits `rtabort!` into `dumb_print` happening in the default hook and `abort_internal`, happening in the actual oom handler after calling the hook. Registering an empty function thus makes the oom handler not print anything but still abort. Cc: @alexcrichton
2018-06-01Remove feature flag from fs::read_to_string examplesteveklabnik-2/+0
This is stable, and so no longer needed
2018-06-01fs: copy: Add EPERM to fallback error conditionsNicolas Koch-5/+12
Fixes #51266
2018-06-01Make the OOM hook return `()` rather than `!`Mike Hommey-10/+12
Per discussion in https://github.com/rust-lang/rust/issues/51245#issuecomment-393651083 This allows more flexibility in what can be done with the API. This also splits `rtabort!` into `dumb_print` happening in the default hook and `abort_internal`, happening in the actual oom handler after calling the hook. Registering an empty function thus makes the oom handler not print anything but still abort. Cc: @alexcrichton
2018-05-31Rollup merge of #51213 - nicokoch:copy_permissions, r=cramertjGuillaume Gomez-5/+5
fs: copy: Use File::set_permissions instead of fs::set_permissions We already got the open file descriptor at this point. Don't make the kernel resolve the path again.
2018-05-31Fix confusing error message for sub_instantClaudio Bley-1/+1
When subtracting an Instant from another, the function will panick when `RHS > self`, but the error message confusingly displays a different error: ```rust let i = Instant::now(); let other = Instant::now(); if other > i { println!("{:?}", i - other); } ``` This results in a panic: ``` thread 'test_instant' panicked at 'other was less than the current instant', libstd/sys/unix/time.rs:292:17 ```
2018-05-31libstd/sys/unix/fs.rs: fix compilation on fuchsiaGuillaume Girol-1/+1
2018-05-30std::fs::DirEntry.metadata(): use fstatat instead of lstat when possibleGuillaume Girol-11/+32
2018-05-30Auto merge of #50955 - steveklabnik:update-libbacktrace, r=alexcrichtonbors-23/+53
Update libbacktrace We haven't updated libbacktrace in two years. This is just blindly updating to the latest HEAD; I'd like to see what travis says. It at least builds on my machine, running some tests... This perpetuates the patches from https://github.com/rust-lang/rust/pull/30908
2018-05-30Replace libbacktrace with a submoduleAlex Crichton-23/+53
While we're at it update the `backtrace` crate from crates.io. It turns out that the submodule's configure script has gotten a lot more finnicky as of late so also switch over to using the `cc` crate manually which allows to avoid some hacks around the configure script as well
2018-05-30Auto merge of #50880 - glandium:oom, r=SimonSapinbors-24/+108
OOM handling changes As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent. This does have codegen implications. Even without the hooks, and with a handler that ignores the arguments, the compiler doesn't eliminate calling `rust_oom` with the `Layout`. Even if it managed to eliminate that, with the hooks, I don't know if the compiler would be able to figure out it can skip it if the hook is never set. A couple implementation notes: - I went with explicit enums rather than bools because it makes it clearer in callers what is being requested. - I didn't know what `feature` to put the hook setting functions behind. (and surprisingly, the compile went through without any annotation on the functions) - There's probably some bikeshedding to do on the naming. Cc: @Simonsapin, @sfackler
2018-05-30Remobve unused importNicolas Koch-1/+1
2018-05-30fs: copy: Use File::set_permissions instead of fs::set_permissionsNicolas Koch-4/+4
We already got the open file descriptor at this point. Don't make the kernel resolve the path again.
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