Commit Graph

122 Commits

Author SHA1 Message Date
Michal 'vorner' Vaner
cc63bd47ef
atomic::Ordering: Get rid of misleading parts of intro
Remove the parts of atomic::Ordering's intro that wrongly claimed that
SeqCst prevents all reorderings around it.

Closes #55196
2018-11-18 11:12:01 +01:00
Simonas Kazlauskas
99f7dc451f Do not Atomic{I,U}128 in stage0 2018-11-05 18:54:17 +02:00
Simonas Kazlauskas
5e50acf443 Make the Atomic types repr(C) to ensure newtype 2018-10-27 13:47:12 +03:00
Oliver Middleton
01674fbe06 Correct alignment of atomic types and (re)add Atomic{I,U}128
LLVM requires that atomic loads and stores be aligned to at least the size of the type.
2018-10-27 13:47:11 +03:00
Alex Crichton
b4877edd67 std: Start implementing wasm32 atomics
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-24 15:55:35 -07:00
Jorge Aparicio
828289610b remove (more) CAS API from Atomic* types where not natively supported
closes #54276
2018-09-16 23:04:11 +02:00
Alex Crichton
0338d340c4 Remove #[repr(transparent)] from atomics
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-09-05 15:41:44 -07:00
varkor
bbf0b159b7 Make core::sync::atomic::Ordering #[non_exhaustive] 2018-08-15 17:11:42 +01:00
Ralf Jung
6a018a03df document mode possibilities for all RMW operations 2018-08-07 11:57:43 +02:00
Ralf Jung
1733bd3cbd list possible orderings for load and store 2018-08-07 11:33:20 +02:00
Ralf Jung
110bcc9798 forgot to add comment for some atomic types 2018-08-07 11:26:05 +02:00
Ralf Jung
e9a86a2e1a fix link label; use more https 2018-08-07 11:23:30 +02:00
Ralf Jung
621d06481d atomic ordering docs 2018-08-06 12:05:59 +02:00
Mark Rousskov
683a3db01f Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00
willmo
e769deca99
Add #[repr(transparent)] to Atomic* types
This allows them to be used in #[repr(C)] structs without warnings. Since rust-lang/rfcs#1649 and rust-lang/rust#35603 they are already documented to have "the same in-memory representation as" their corresponding primitive types. This just makes that explicit.
2018-07-07 20:09:34 -07:00
Jorge Aparicio
0ed32313a2 #[cfg(target_has_atomic_cas)] -> #[cfg(target_has_atomic = "cas")] 2018-07-05 16:52:46 -05:00
Jorge Aparicio
bbf688a84d enable Atomic*.{load,store} for ARMv6-M / MSP430
closes #45085

this commit adds an `atomic_cas` target option and an unstable `#[cfg(target_has_atomic_cas)]`
attribute to enable a subset of the `Atomic*` API on architectures that don't support atomic CAS
natively, like MSP430 and ARMv6-M.
2018-07-05 16:44:29 -05:00
bors
230b97af1c Auto merge of #48553 - seanmonstar:atomic-debug, r=alexcrichton
atomic: remove 'Atomic*' from Debug output

For the same reason that we don't show `Vec { data: [0, 1, 2, 3] }`, but just the array, the `AtomicUsize(1000)` is noisy, and seeing just `1000` is likely better.
2018-04-19 23:08:16 +00:00
bors
532764cb79 Auto merge of #49963 - llogiq:stabilize-13226, r=kennytm
stabilize fetch_nand

This closes #13226 and makes `Atomic*.fetch_nand` stable.
2018-04-16 07:44:25 +00:00
Andre Bogus
c68c90a232 stabilize fetch_nand 2018-04-14 15:51:31 +02:00
Andre Bogus
2f603413ab improve Atomic*::fetch_update docs 2018-04-12 22:48:48 +02:00
kennytm
920249abdd
Rollup merge of #48658 - llogiq:no-more-cas, r=kennytm
Add a generic CAS loop to std::sync::Atomic*

This adds two new methods to both `AtomicIsize` and `AtomicUsize` with optimized safe compare-and-set loops, so users will no longer need to write their own, except in *very* strange circumstances.

`update_and_fetch` will apply the function and return its result, whereas `fetch_and_update` will apply the function and return the previous value.

This solves #48384 with `x.update_and_fetch(|x| x.max(y))`. It also relates to #48655 (which I misuse as tracking issue for now)..

*note* This *might* need a crater run because the functions could clash with third party extension traits.
2018-04-05 16:51:16 +08:00
Andre Bogus
0f5e419163 Add a generic CAS loop to std::sync::Atomic*
This adds a new method to all numeric `Atomic*` types with a
safe compare-and-set loop, so users will no longer need to write
their own, except in *very* strange circumstances.

This solves #48384 with `x.fetch_max(_)`/`x.fetch_min(_)`. It
also relates to #48655 (which I misuse as tracking issue for now).

*note* This *might* need a crater run because the functions could
clash with third party extension traits.
2018-03-30 12:27:14 +02:00
Tim Neumann
9e4d5cf0ce
Rollup merge of #49170 - steveklabnik:gh49127, r=nagisa
Clarify AcqRel's docs

This implied things that are not true.

Fixes #49127
2018-03-26 15:14:57 +02:00
Steve Klabnik
23013c791c
update wording as per feedback 2018-03-25 14:19:27 +02:00
Guillaume Gomez
2b64799365 Make Atomic doc examples specific to each type 2018-03-19 21:43:45 +01:00
steveklabnik
deae8de673 Clarify AcqRel's docs
This implied things that are not true.

Fixes #49127
2018-03-19 14:34:51 +01:00
Sean McArthur
c689db2c46 atomic: remove 'Atomic*' from Debug output 2018-02-26 11:35:36 -08:00
Stefan Schindler
e812da0ed0 Force the link to std:🧵:yield_now() 2018-02-16 12:20:54 +01:00
Stefan Schindler
3bf989f4c9 Add link to yield_now 2018-02-16 10:30:31 +01:00
Mark Simulacrum
1335b3da5a Add fetch_nand.
cc #13226 (the tracking issue)
2018-02-09 16:04:41 -07:00
bors
21882aad72 Auto merge of #47204 - varkor:unsafecell-into_inner-safe, r=alexcrichton
Make UnsafeCell::into_inner safe

This fixes #35067. It will require a Crater run as discussed in that
issue.
2018-01-28 19:01:51 +00:00
varkor
4829d502cc Make UnsafeCell::into_inner safe
This fixes #35067. It will require a Crater run as discussed in that
issue.
2018-01-05 01:11:20 +00:00
Oliver Middleton
a8d107be25 Correct a few stability attributes 2017-12-27 14:11:05 +00:00
varkor
e4dc11d98d Add std::fmt::Pointer implementation for AtomicPtr
Resolves #29212.
2017-12-10 23:21:26 +00:00
kennytm
fc9abbd7b7 Rollup merge of #46293 - ollie27:atomic_bool_from, r=BurntSushi
impl From<bool> for AtomicBool

This seems like an obvious omission from #45610. ~~I've used the same feature name and version in the hope that this can be backported to beta so it's stabilized with the other impls. If it can't be I'll change it to `1.24.0`.~~
2017-11-29 18:37:50 +08:00
kennytm
0e78c29bea Rollup merge of #46287 - SimonSapin:stable-constness, r=aturon
Stabilize const-calling existing const-fns in std

Fixes #46038
2017-11-29 18:37:47 +08:00
Oliver Middleton
71d766bd55
Change version number for impl From<bool> for AtomicBool to 1.24.0 2017-11-27 21:26:19 +00:00
Stjepan Glavina
d5e8b61054 Change the stabilization version to 1.24.0 2017-11-27 19:24:13 +01:00
Oliver Middleton
652a4bd26c impl From<bool> for AtomicBool 2017-11-27 01:23:04 +00:00
Simon Sapin
6c5f53e65e Stabilize const-calling existing const-fns in std
Fixes #46038
2017-11-26 23:43:44 +01:00
Stjepan Glavina
6ceb5f4bec Stabilize spin_loop_hint 2017-11-22 00:00:01 +01:00
Jorge Aparicio
47ed4738d9 fix core for targets with max-atomic-width = 0
closes #45802
2017-11-09 00:20:55 +01:00
M Farkas-Dyck
be21779072 since = "1.23.0" 2017-10-31 11:15:10 -08:00
M Farkas-Dyck
80a3191215 feature = "atomic_from" 2017-10-29 14:41:03 -08:00
M Farkas-Dyck
5c21637f9a impl From<T> for AtomicT 2017-10-29 01:28:54 -08:00
Alex Crichton
ca18537197 Bump to 1.23 and update bootstrap
This commit updates the bootstrap compiler, bumps the version to 1.23, updates
Cargo, updates books, and updates crates.io dependencies
2017-10-26 13:59:18 -07:00
Guillaume Gomez
98045fdaca Add missing links for AtomicBool 2017-10-05 23:20:58 +02:00
Mark Simulacrum
7756d39dca Rollup merge of #44854 - lucasem:atomic-docs, r=steveklabnik
docs improvement sync::atomic::Atomic*

Addresses the `Atomic*` part of #29377.
r? @steveklabnik
2017-09-29 17:59:02 -06:00
Lucas Morales
f7fd04ae65
docs improvement sync::atomic::Atomic* 2017-09-25 19:39:52 -04:00