about summary refs log tree commit diff
path: root/src/libcore/sync
AgeCommit message (Collapse)AuthorLines
2020-03-18Use copy bound in atomic operations to generate simpler MIRTomasz Miąsko-15/+15
2020-02-11Document stable versions of `f32` and `f64` intrinsicsLeSeulArtichaut-2/+2
Fix links
2020-01-16Add SAFETY comment for atomic examplePhoebe Bell-1/+3
2020-01-16Elaborate on SAFETY commentsPhoebe Bell-31/+33
2020-01-16Document unsafe blocks in core::{cell, str, sync}Phoebe Bell-2/+31
2020-01-05Add more nuanced advice about spin_loop_hintAleksey Kladov-2/+4
2020-01-02Remove wrong advice about spin locks from `spin_loop_hint` docsAleksey Kladov-10/+2
Using a pure spin lock for a critical section in a preemptable thread is always wrong, however short the critical section may be. The thread might be preempted, which will cause all other threads to hammer busily at the core for the whole quant. Moreover, if threads have different priorities, this might lead to a priority inversion problem and a deadlock. More generally, a spinlock is not more efficient than a well-written mutex, which typically does several spin iterations at the start anyway. The advise about UP vs SMP is also irrelevant in the context of preemptive threads.
2019-12-22Format the worldMark Rousskov-60/+76
2019-12-18Propagate cfg bootstrapMark Rousskov-3/+3
2019-12-15use Self alias in place of macrosLzu Tao-1/+1
2019-12-13The constness of 128 bit atomics will be stabilized together with the atomicsOliver Scherer-2/+2
2019-12-13Address review commentsOliver Scherer-65/+0
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+81
functions with a `const` modifier
2019-12-05Rollup merge of #67005 - andrewbanchich:master, r=joshtriplettMazdak Farrokhzad-1/+1
capitalize Rust Capitalize "Rust" in docs.
2019-12-03capitalize RustAndrew Banchich-1/+1
2019-11-30Rollup merge of #66705 - pitdicker:atomic_mut_ptr, r=KodrAusMazdak Farrokhzad-0/+74
Atomic as_mut_ptr I encountered the following pattern a few times: In Rust we use some atomic type like `AtomicI32`, and an FFI interface exposes this as `*mut i32` (or some similar `libc` type). It was not obvious to me if a just transmuting a pointer to the atomic was acceptable, or if this should use a cast that goes through an `UnsafeCell`. See https://github.com/rust-lang/rust/issues/66136#issuecomment-557802477 Transmuting the pointer directly: ```rust let atomic = AtomicI32::new(1); let ptr = &atomic as *const AtomicI32 as *mut i32; unsafe { ffi(ptr); } ``` A dance with `UnsafeCell`: ```rust let atomic = AtomicI32::new(1); unsafe { let ptr = (&*(&atomic as *const AtomicI32 as *const UnsafeCell<i32>)).get(); ffi(ptr); } ``` Maybe in the end both ways could be valid. But why not expose a direct method to get a pointer from the standard library? An `as_mut_ptr` method on atomics can be safe, because only the use of the resulting pointer is where things can get unsafe. I documented its use for FFI, and "Doing non-atomic reads and writes on the resulting integer can be a data race." The standard library could make use this method in a few places in the WASM module. cc @RalfJung as you answered my original question.
2019-11-30Fill tracking issuePaul Dicker-2/+2
2019-11-30Document why as_mut_ptr is safePaul Dicker-0/+12
2019-11-23Add as_mut_ptr method to atomic types.Paul Dicker-0/+62
2019-11-12Snap cfgsMark Rousskov-35/+29
2019-11-06Have tidy ensure that we document all `unsafe` blocks in libcoreOliver Scherer-0/+2
2019-10-13Rollup merge of #65214 - Amanieu:cfg_atomic, r=alexcrichtonMazdak Farrokhzad-70/+92
Split non-CAS atomic support off into target_has_atomic_load_store This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s: * `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations). * ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS). cc #32976 r? @alexcrichton
2019-10-12fix link targetsRalf Jung-12/+12
2019-10-12it's C++20Ralf Jung-7/+7
2019-10-12do not reference LLVM for our concurrency memory modelRalf Jung-25/+27
2019-10-08Split non-CAS atomic support off into target_has_atomic_load_storeAmanieu d'Antras-70/+92
2019-09-18Rollup merge of #64348 - arnohaase:pr_documentation_spin_loop_hint, ↵Tyler Mandry-12/+15
r=alexcrichton PR: documentation spin loop hint The documentation for 'spin loop hint' explains that yield is better if the lock holder is running on the same CPU. I suggest that 'CPU or core' would be clearer.
2019-09-18broken hyperlinks in documentationArno Haase-1/+1
2019-09-17newly phrased documentation for spin loop hintsArno Haase-12/+15
2019-09-10fixed linter errorArno Haase-7/+7
2019-09-10documentation for AtomicPtr CAS operationsArno Haase-4/+2
2019-09-10documentation enhancement for 'spin loop hint': replace 'CPU' with 'CPU or core'Arno Haase-3/+3
2019-06-04Remove unneeded feature attr from atomic integers doctestsLzu Tao-8/+8
2019-04-19libcore: deny more...Mazdak Farrokhzad-4/+4
2019-04-18libcore => 2018Taiki Endo-5/+5
2019-04-03Updated the documentation of core::hints::spin_loop and ↵Christian-7/+20
core::sync::spin_loop_hint
2019-03-02Bootstrap compiler update for 1.35 releaseMark Rousskov-12/+4
2019-02-21Destabilize fixed-width const defined atomic integersMahmut Bulut-1/+14
* With this PR 1.34.0 onwards const declarations of atomic integers will be unstable.
2019-01-30Add suggestions to deprecation lintsOliver Scherer-2/+31
2019-01-26Replace deprecated ATOMIC_INIT constsMark Rousskov-3/+2
2019-01-25std: Stabilize fixed-width integer atomicsAlex Crichton-55/+96
This commit stabilizes the `Atomic{I,U}{8,16,32,64}` APIs in the `std::sync::atomic` and `core::sync::atomic` modules. Proposed in #56753 and tracked in #32976 this feature has been unstable for quite some time and is hopefully ready to go over the finish line now! The API is being stabilized as-is. The API of `AtomicU8` and friends mirrors that of `AtomicUsize`. A list of changes made here are: * A portability documentation section has been added to describe the current state of affairs. * Emulation of smaller-size atomics with larger-size atomics has been documented. * As an added bonus, `ATOMIC_*_INIT` is now scheduled for deprecation across the board in 1.34.0 now that `const` functions can be invoked in statics. Note that the 128-bit atomic types are omitted from this stabilization explicitly. They have far less platform support than the other atomic types, and will likely require further discussion about their best location. Closes #32976 Closes #56753
2019-01-15Move spin_loop_hint to core::hint moduleClar Fon-9/+3
2018-12-25Remove licensesMark Rousskov-20/+0
2018-12-19Rollup merge of #56881 - Amanieu:ordering_eq, r=alexcrichtonPietro Albini-1/+1
Implement Eq, PartialEq and Hash for atomic::Ordering r? @alexcrichton
2018-12-16Implement Eq, PartialEq and Hash for atomic::OrderingAmanieu d'Antras-1/+1
2018-12-16Rollup merge of #53506 - phungleson:fix-from-docs-atomic, r=KodrAusMazdak Farrokhzad-2/+15
Documentation for impl From for AtomicBool and other Atomic types As part of issue #51430 (cc @skade). The impl is very simple, so not sure if we need to go into any details.
2018-12-12Bump to 1.33.0Alex Crichton-2/+2
* Update bootstrap compiler * Update version to 1.33.0 * Remove some `#[cfg(stage0)]` annotations Actually updating the version number is blocked on updating Cargo
2018-12-12Documentation for impl From for AtomicBool and other Atomic typesSon-2/+15
2018-11-18atomic::Ordering: Get rid of misleading parts of introMichal 'vorner' Vaner-7/+9
Remove the parts of atomic::Ordering's intro that wrongly claimed that SeqCst prevents all reorderings around it. Closes #55196
2018-11-05Do not Atomic{I,U}128 in stage0Simonas Kazlauskas-2/+2