about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-05-05Implement [OsStr]::joinest31-0/+33
2022-05-05Remove condvar::two_mutexes test.Mara Bos-21/+0
We don't guarantee this panics. On most platforms it doesn't anymore.
2022-05-05Auto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-sebors-1/+4
Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback
2022-05-05Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, ↵Yuki Okushi-2/+8
r=m-ou-se Relax memory ordering used in SameMutexCheck `SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
2022-05-05Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplettYuki Okushi-2/+2
Relax memory ordering used in `min_stack` `min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.
2022-05-05Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopbackTobias Bucher-1/+4
2022-05-04update `jemallocator` example to use 2018 edition import syntaxkraktus-2/+0
2022-05-03std::io: Modify some ReadBuf method signatures to return `&mut Self`Nick Cameron-7/+11
This allows using `ReadBuf` in a builder-like style and to setup a `ReadBuf` and pass it to `read_buf` in a single expression, e.g., ``` // With this PR: reader.read_buf(ReadBuf::uninit(buf).assume_init(init_len))?; // Previously: let mut buf = ReadBuf::uninit(buf); buf.assume_init(init_len); reader.read_buf(&mut buf)?; ``` Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-05-03Remove hard links from `env::current_exe` security exampleMartin Geisler-30/+17
The security example shows that `env::current_exe` will return the path used when the program was started. This is not really surprising considering how hard links work: after `ln foo bar`, the two files are _equivalent_. It is _not_ the case that `bar` is a “link” to `foo`, nor is `foo` a link to `bar`. They are simply two names for the same underlying data. The security vulnerability linked to seems to be different: there an attacker would start a SUID binary from a directory under the control of the attacker. The binary would respawn itself by executing the program found at `/proc/self/exe` (which the attacker can control). This is a real problem. In my opinion, the example given here doesn’t really show the same problem, it just shows a misunderstanding of what hard links are. I looked through the history a bit and found that the example was introduced in #33526. That PR actually has two commits, and the first (8478d48dad949b3b1374569a5391089a49094eeb) explains the race condition at the root of the linked security vulnerability. The second commit proceeds to replace the explanation with the example we have today. This commit reverts most of the second commit from #33526.
2022-05-03Round timeouts up to infinite in futex_wait on DragonFlyBSD.Mara Bos-9/+8
2022-05-03Add #[cfg] in cfg_if for linux in unix/futex.Mara Bos-3/+5
2022-05-03Don't use futexes on netbsd.Mara Bos-44/+5
The latest NetBSD release doesn't include the futex syscall yet.
2022-05-02Fix nitsPyry Kontio-2/+2
2022-05-01Add commentAustin Kiekintveld-0/+2
2022-05-01Fix formattingAustin Kiekintveld-2/+6
2022-05-01Relax memory ordering used in SameMutexCheckAustin Kiekintveld-1/+1
`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
2022-05-01Relax memory ordering used in `min_stack`Austin Kiekintveld-2/+2
`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.
2022-05-01Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomezbors-0/+7
rustdoc: Resolve doc links referring to `macro_rules` items cc https://github.com/rust-lang/rust/issues/81633 UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrumbors-6/+6
Make [e]println macros eagerly drop temporaries (for backport) This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434. My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61. argument position | before #94868 | after #94868 | after this PR --- |:---:|:---:|:---: `write!($tmp, "…", …)` | :rage: | :rage: | :rage: `write!(…, "…", $tmp)` | :rage: | :rage: | :rage: `writeln!($tmp, "…", …)` | :rage: | :rage: | :rage: `writeln!(…, "…", $tmp)` | :rage: | :rage: | :rage: `print!("…", $tmp)` | :rage: | :rage: | :rage: `println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `eprint!("…", $tmp)` | :rage: | :rage: | :rage: `eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:
2022-05-01Fix some links in the standard libraryVadim Petrochenkov-0/+7
2022-04-30add aliases for std::fs::canonicalizejulio-0/+2
2022-04-29Disable pthread thread parker on futex platforms.Mara Bos-1/+5
2022-04-29Always return false in futex_wake on {Free,DragonFly}BSD.Mara Bos-16/+13
2022-04-29Use futex-based locks and thread parker on FreeBSD.Mara Bos-4/+60
2022-04-29Use futex-based locks and thread parker on DragonFlyBSD.Mara Bos-1/+44
2022-04-29Use futex-based locks and thread parker on NetBSD.Mara Bos-24/+53
2022-04-29Use futex-based locks and thread parker on OpenBSD.Mara Bos-1/+53
2022-04-29Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahcDylan DPC-10/+0
Revert "Re-export core::ffi types from std::ffi" This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d. Fixes https://github.com/rust-lang/rust/issues/96435 , a regression in crates doing `use std::ffi::*;` and `use std::os::raw::*;`. We can re-add this re-export once the `core::ffi` types are stable, and thus the `std::os::raw` types can become re-exports as well, which will avoid the conflict. (Type aliases to the same type still conflict, but re-exports of the same type don't.)
2022-04-29Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplettDylan DPC-1/+1
HashMap doc: Don't use monospace font for 'Entry Api'
2022-04-29Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-sebors-31/+119
Windows: Make stdin pipes synchronous Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous. r? `@m-ou-se`
2022-04-28Auto merge of #96393 - joboet:pthread_parker, r=thomccbors-30/+336
std: directly use pthread in UNIX parker implementation `Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways. This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives. I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-28Add more diagnostic itemsSerial-0/+1
2022-04-28Yield the thread when waiting to delete a fileChris Denton-0/+3
2022-04-28std: simplify UNIX parker timeoutsjoboet-59/+21
2022-04-28Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnayDylan DPC-1/+4
Make EncodeWide implement FusedIterator [`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr. When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose. This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance. Fixes https://github.com/rust-lang/rust/issues/96368
2022-04-27Revert "Re-export core::ffi types from std::ffi"Josh Triplett-10/+0
This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d. Fixes https://github.com/rust-lang/rust/issues/96435 , a regression in crates doing `use std::ffi::*;` and `use std::os::raw::*;`. We can re-add this re-export once the `core::ffi` types are stable, and thus the `std::os::raw` types can become re-exports as well, which will avoid the conflict. (Type aliases to the same type still conflict, but re-exports of the same type don't.)
2022-04-27Make [e]println macros eagerly drop temporaries (for backport)David Tolnay-6/+6
2022-04-27HashMap doc: Don't use monospace font for 'Entry Api'Nixon Enraght-Moony-1/+1
2022-04-27Note the importance of using sync pipesChris Denton-1/+19
2022-04-27Add tracking issue number for mutex_unpoisonThayne McCombs-2/+2
2022-04-27Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, ↵bors-8/+44
r=joshtriplett Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`. Define `NullHandleError` and `InvalidHandleError` types, that implement std::error::Error, and use them as the error types in `HandleOrNull` and `HandleOrInvalid`, This addresses [this concern](https://github.com/rust-lang/rust/issues/87074#issuecomment-1080031167). This is the same as #95387. r? `@joshtriplett`
2022-04-26Windows: Make stdin pipes synchronousChris Denton-31/+85
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-26Add `set_inheritable` for Windows `Handle`sChris Denton-0/+16
2022-04-26Add functions to un-poison Mutex and RwLockThayne McCombs-0/+73
See discussion at https://internals.rust-lang.org/t/unpoisoning-a-mutex/16521/3
2022-04-26Retry deleting a directoryChris Denton-2/+15
It's possible that a file in the directory is pending deletion. In that case we might succeed after a few attempts.
2022-04-25Remove references to git.ioEric Huss-1/+2
2022-04-26Windows: Iterative `remove_dir_all`Chris Denton-77/+67
This will allow better strategies for use of memory and File handles. However, fully taking advantage of that is left to future work.
2022-04-25Make EncodeWide implement FusedIteratorAron Parker-1/+4
2022-04-25std: directly use pthread in UNIX parker implementationjoboet-28/+372
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-25Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplettbors-91/+212
Windows Command: Don't run batch files using verbatim paths Fixes #95178 Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.