about summary refs log tree commit diff
path: root/library/std/src/sys/sync/mutex
AgeCommit message (Collapse)AuthorLines
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-11/+18
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-05-28Add comments to diagnostic itemsPatrick-6-0/+6
2025-05-28Make pthread Mutex internals less publicPatrick-6-1/+1
2025-05-28Add diagnostic items to sys::MutexPatrick-6-0/+6
2025-05-05collect all Fuchsia bindings into the `fuchsia` modulejoboet-3/+3
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally: * deduplicates the definitions * makes the error names consistent * marks some extern functions as safe * removes unused items (there's no need to maintain these bindings if we're not going to use them) * removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
2025-04-27use generic Atomic type where possibleChristopher Durham-5/+5
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-02-19Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306Li Keqing-1/+1
2024-12-01Rollup merge of #128184 - joboet:refactor_pthread_sync, r=workingjubileeMatthias Krüger-129/+32
std: refactor `pthread`-based synchronization The non-trivial code for `pthread_condvar` is duplicated across the thread parking and the `Mutex`/`Condvar` implementations. This PR moves that code into `sys::pal`, which now exposes an `unsafe` wrapper type for `pthread_mutex_t` and `pthread_condvar_t`.
2024-11-30std: clarify comments about initializationjoboet-1/+1
2024-11-27update cfgsBoxy-1/+0
2024-10-29xous: sync: remove `rustc_const_stable` attributeSean Cross-1/+0
These functions had `#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]` on them because they were originally taken from `no_threads`. with d066dfd these no longer compile. Since other platforms do not have this attribute, remove it. This fixes the build for Xous. Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-28std: refactor `pthread`-based synchronizationjoboet-129/+32
The non-trivial code for `pthread_condvar` is duplicated across the thread parking and the `Mutex`/`Condvar` implementations. This PR moves that code into `sys::pal`, which now exposes a non-movable wrapper type for `pthread_mutex_t` and `pthread_condvar_t`.
2024-10-28we can now enable the 'const stable fn must be stable' checkRalf Jung-1/+1
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-2/+2
2024-10-17Abstract the state type for futexesPaul Menage-3/+3
In the same way that we expose SmallAtomic and SmallPrimitive to allow Windows to use a value other than an AtomicU32 for its futex state, this patch switches the primary futex state type from AtomicU32 to futex::Atomic. The futex::Atomic type should be usable as an atomic value with underlying primitive type equal to futex::Primitive. This allows supporting the futex API on systems where the underlying kernel futex implementation requires more state than simply an AtomicU32. All in-tree futex implementations simply define {Atomic,Primitive} directly as {AtomicU32,u32}.
2024-10-01std: replace `LazyBox` with `OnceBox`joboet-49/+62
This PR replaces the `LazyBox` wrapper used to allocate the pthread primitives with `OnceBox`, which has a more familiar API mirroring that of `OnceLock`. This cleans up the code in preparation for larger changes like #128184 (from which this PR was split) and allows some neat optimizations, like avoid an acquire-load of the allocation pointer in `Mutex::unlock`, where the initialization of the allocation must have already been observed. Additionally, I've gotten rid of the TEEOS `Condvar` code, it's just a duplicate of the pthread one anyway and I didn't want to repeat myself.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+7
2024-07-29Reformat `use` declarations.Nicholas Nethercote-13/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-2/+2
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-19kmc-solid: forbid(unsafe_op_in_unsafe_fn)Jubilee Young-0/+1
2024-07-16Use futex.rs for Windows thread parkingChris Denton-16/+5
2024-07-15Remove PSRWLOCKChris Denton-1/+1
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-03-19SeqCst->{Release,Acquire} in xous mutex.Mara Bos-4/+7
No need for SeqCst. Release+Acquire is the right memory ordering for a mutex.
2024-03-12std: move `Once` implementations to `sys`joboet-0/+782