summary refs log tree commit diff
path: root/src/libcore/sync
AgeCommit message (Collapse)AuthorLines
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
2018-10-27Make the Atomic types repr(C) to ensure newtypeSimonas Kazlauskas-5/+5
2018-10-27Correct alignment of atomic types and (re)add Atomic{I,U}128Oliver Middleton-0/+56
LLVM requires that atomic loads and stores be aligned to at least the size of the type.
2018-09-24std: Start implementing wasm32 atomicsAlex Crichton-0/+8
This commit is an initial start at implementing the standard library for wasm32-unknown-unknown with the experimental `atomics` feature enabled. None of these changes will be visible to users of the wasm32-unknown-unknown target because they all require recompiling the standard library. The hope with this is that we can get this support into the standard library and start iterating on it in-tree to enable experimentation. Currently there's a few components in this PR: * Atomic fences are disabled on wasm as there's no corresponding atomic op and it's not clear yet what the convention should be, but this will change in the future! * Implementations of `Mutex`, `Condvar`, and `RwLock` were all added based on the atomic intrinsics that wasm has. * The `ReentrantMutex` and thread-local-storage implementations panic currently as there's no great way to get a handle on the current thread's "id" yet. Right now the wasm32 target with atomics is unfortunately pretty unusable, requiring a lot of manual things here and there to actually get it operational. This will likely continue to evolve as the story for atomics and wasm unfolds, but we also need more LLVM support for some operations like custom `global` directives for this to work best.
2018-09-16remove (more) CAS API from Atomic* types where not natively supportedJorge Aparicio-0/+23
closes #54276
2018-09-05Remove `#[repr(transparent)]` from atomicsAlex Crichton-3/+0
Added in #52149 the discussion in #53514 is showing how we may not want to actually add this attribute to the atomic types. While we continue to debate #53514 this commit reverts the addition of the `transparent` attribute. This should be a more conservative route which leaves us the ability to tweak this in the future but in the meantime allows us to continue discussion as well.
2018-08-15Make core::sync::atomic::Ordering #[non_exhaustive]varkor-24/+1
2018-08-07document mode possibilities for all RMW operationsRalf Jung-29/+226
2018-08-07list possible orderings for load and storeRalf Jung-26/+43
2018-08-07forgot to add comment for some atomic typesRalf Jung-2/+4