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.
This commit is contained in:
Jorge Aparicio
2018-06-30 14:56:08 -05:00
parent 94eb176055
commit bbf688a84d
9 changed files with 45 additions and 7 deletions

View File

@@ -12,10 +12,12 @@
pub use core::task::*;
#[cfg(target_has_atomic = "ptr")]
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
pub use self::if_arc::*;
#[cfg(target_has_atomic = "ptr")]
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
mod if_arc {
use super::*;
use core::marker::PhantomData;
@@ -47,7 +49,8 @@ mod if_arc {
}
}
#[cfg(target_has_atomic = "ptr")]
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
struct ArcWrapped<T>(PhantomData<T>);
unsafe impl<T: Wake + 'static> UnsafeWake for ArcWrapped<T> {