about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-04-19[fuchsia] Add implementation for `current_exe`David Koloski-1/+21
This implementation returns a best attempt at the current exe path. On fuchsia, fdio will always use `argv[0]` as the process name and if it is not set then an error will be returned. Because this is not guaranteed to be the case, this implementation returns an error if `argv` does not contain any elements.
2022-04-19espidf: fix statScott Mabin-15/+30
* corect type usage with new type definitions in libc
2022-04-19Use futex locks on emscripten.Mara Bos-0/+1
2022-04-19Use futex locks on wasm+atomics.Mara Bos-354/+6
2022-04-19Make std::sys::wasm::futex consistent with unix::futex.Mara Bos-4/+18
2022-04-19Make std::sys::unix::futex consistent on emscripten.Mara Bos-22/+25
2022-04-19Improve AddrParseError descriptionChris Morgan-11/+28
The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address. I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six. I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.
2022-04-18Add a comment explaining the `(())` idiom for empty structs.Dan Gohman-0/+2
2022-04-18Split `NotHandle` into `NullHandleError` and `InvalidHandleError`.Dan Gohman-14/+31
Also, make the display messages more specific, and remove the `Copy` implementation.
2022-04-18Move the `Error` impl for `NotHandle` out of platform-independent code.Dan Gohman-0/+3
2022-04-18Fix an incorrect word in a comment.Dan Gohman-2/+2
2022-04-18Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.Dan Gohman-6/+20
Define a `NotHandle` type, that implements `std::error::Error`, and use it as the error type in `HandleOrNull` and `HandleOrInvalid`.
2022-04-18Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieubors-541/+92
Use a single ReentrantMutex implementation on all platforms. This replaces all platform specific ReentrantMutex implementations by the one I added in #95727 for Linux, since that one does not depend on any platform specific details. r? `@Amanieu`
2022-04-18Remove forgotten reexport of ReentrantMutex in sys::unsupported.Mara Bos-1/+1
2022-04-17Replace sys/unix/weak AtomicUsize with AtomicPtrCAD97-17/+15
2022-04-17Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitorbors-4/+5
fix error handling for pthread_sigmask(3) Errors from `pthread_sigmask(3)` were handled using `cvt()`, which expects a return value of `-1` on error and uses `errno`. However, `pthread_sigmask(3)` returns `0` on success and an error number otherwise. Fix it by replacing `cvt()` with `cvt_nz()`.
2022-04-17move import to fix warning with emscripten targetRalf Sager-1/+2
2022-04-17Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"Erik Desjardins-2/+2
This reverts commit 035a717ee8bf548868fb50b5c7ca562fc4a657a7, reversing changes made to 761e8884858759b21f3374ad610494e68c087a38.
2022-04-17Remove unnecessary functiondylni-20/+18
2022-04-17Improve Windows path prefix parsingdylni-37/+124
2022-04-16Document rounding for floating-point primitive operationsMatthew Woodcraft-0/+13
State that the four primitive operations honour IEEE 754 roundTiesToEven. Documenting under "Primitive Type f32"; f64 refers to that.
2022-04-16Use a single ReentrantMutex implementation on all platforms.Mara Bos-540/+91
2022-04-15Rollup merge of #96040 - m-ou-se:futex-u32, r=AmanieuDylan DPC-53/+55
Use u32 instead of i32 for futexes. This changes futexes from i32 to u32. The [Linux man page](https://man7.org/linux/man-pages/man2/futex.2.html) uses `uint32_t` for them, so I'm not sure why I used i32 for them. Maybe because I first used them for thread parkers, where I used -1, 0, and 1 as the states. (Wasm's `memory.atomic.wait32` does use `i32`, because wasm doesn't support `u32`.) It doesn't matter much, but using the unsigned type probably results in fewer surprises when shifting bits around or using comparison operators. r? ```@Amanieu```
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-0/+15
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-15Auto merge of #94079 - petrochenkov:cstr, r=joshtriplettbors-1965/+67
library: Move `CStr` to libcore, and `CString` to liballoc Closes https://github.com/rust-lang/rust/issues/46736 Interesting points: - Stability: - To make `CStr(ing)` from libcore/liballoc unusable without enabling features I had to make these structures unstable, and reexport them from libstd using stable type aliases instead of `pub use` reexports. (Because stability of `use` items is not checked.) - Relying on target ABI in libcore is ok: - https://github.com/rust-lang/rust/pull/94079#issuecomment-1044263371 - `trait CStrExt` (UPDATE: used only in `cfg(bootstrap)` mode, otherwise lang items are used instead) - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 - `strlen` - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 Otherwise it's just a code move + some minor hackery usual for liballoc in `cfg(test)` mode.
2022-04-15Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-sebors-1/+50
Windows: Use a pipe relay for chaining pipes Fixes #95759 This fixes the issue by chaining pipes synchronously and manually pumping messages between them. It's not ideal but it has the advantage of not costing anything if pipes are not chained ("don't pay for what you don't use") and it also avoids breaking existing code that rely on our end of the pipe being asynchronous (which includes rustc's own testing framework). Libraries can avoid needing this by using their own pipes to chain commands.
2022-04-14library: Remove definitions and reexports of `strlen` from libstdVadim Petrochenkov-40/+0
2022-04-14library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstableVadim Petrochenkov-4/+16
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-1925/+55
2022-04-14Use u32 instead of i32 for futexes.Mara Bos-53/+55
2022-04-14Remove use of `#[rustc_deprecated]`Jacob Pratt-163/+157
2022-04-13Auto merge of #96015 - Dylan-DPC:rollup-vhdprid, r=Dylan-DPCbors-0/+10
Rollup of 6 pull requests Successful merges: - #93217 (Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers) - #95885 (Improve error message in case of missing checksum) - #95962 (Document that DirEntry holds the directory open) - #95991 (fix: wrong trait import suggestion for T:) - #96005 (Add missing article to fix "few" to "a few".) - #96006 (Add a missing article) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-13Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPCDylan DPC-0/+10
Document that DirEntry holds the directory open I had a bug where holding onto DirEntry structs caused file descriptor exhaustion, and thought it would be good to document this.
2022-04-13Auto merge of #95727 - m-ou-se:futex-reentrantmutex, r=Amanieubors-7/+101
Replace ReentrantMutex by a futex-based one on Linux. Tracking issue: https://github.com/rust-lang/rust/issues/93740 r? `@Amanieu`
2022-04-12Rollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrumfee1-dead-4/+4
Fix documentation for wasm32-unknown-unknown Fixes https://github.com/rust-lang/rust/issues/76526#issuecomment-1094208720
2022-04-12Add missing unsafe marker.Mara Bos-1/+1
This is now necessary because of deny(unsafe_op_in_unsafe_fn).
2022-04-12Allow cvt_nz to be unused on some platforms.Mara Bos-0/+1
2022-04-12Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).Mara Bos-0/+1
This avoids 'unused unsafe' warnings when using this feature inside std.
2022-04-12Add debug asserts to futex ReentrantMutex impl.Mara Bos-0/+2
2022-04-12Initialize thread local with const{}.Mara Bos-1/+1
2022-04-12Move current_thread_unique_ptr to the only module that uses it.Mara Bos-10/+9
2022-04-12Make current_thread_unique_ptr work during thread destruction.Mara Bos-1/+3
Otherwise we can't use println!() within atexit handlers etc.
2022-04-12Add futex-based ReentrantMutex on Linux.Mara Bos-6/+88
2022-04-12Add current_thread_unique_ptr() in std::sys_common.Mara Bos-0/+7
2022-04-11Document that DirEntry holds the directory openMartin Pool-0/+10
2022-04-11Rollup merge of #95801 - m-ou-se:futex-rwlock, r=AmanieuDylan DPC-8/+329
Replace RwLock by a futex based one on Linux This replaces the pthread-based RwLock on Linux by a futex based one. This implementation is similar to [the algorithm](https://gist.github.com/kprotty/3042436aa55620d8ebcddf2bf25668bc) suggested by `@kprotty,` but modified to prefer writers and spin before sleeping. It uses two futexes: One for the readers to wait on, and one for the writers to wait on. The readers futex contains the state of the RwLock: The number of readers, a bit indicating whether writers are waiting, and a bit indicating whether readers are waiting. The writers futex is used as a simple condition variable and its contents are meaningless; it just needs to be changed on every notification. Using two futexes rather than one has the obvious advantage of allowing a separate queue for readers and writers, but it also means we avoid the problem a single-futex RwLock would have of making it hard for a writer to go to sleep while the number of readers is rapidly changing up and down, as the writers futex is only changed when we actually want to wake up a writer. It always prefers writers, as we decided [here](https://github.com/rust-lang/rust/issues/93740#issuecomment-1070696128). To be able to prefer writers, it relies on futex_wake to return the number of awoken threads to be able to handle write-unlocking while both the readers-waiting and writers-waiting bits are set. Instead of waking both and letting them race, it first wakes writers and only continues to wake the readers too if futex_wake reported there were no writers to wake up. r? `@Amanieu`
2022-04-11Fix documentation for wasm32-unknown-unknownO01eg-4/+4
2022-04-11Use is_ or has_ prefix for pure `-> bool` functions.Mara Bos-23/+25
2022-04-11Use compare_exchange_weak in futex rwlock implementation.Mara Bos-4/+11
2022-04-11Add comments to futex rwlock implementation.Mara Bos-1/+12