Run rustfmt on libcore/sync folder
This commit is contained in:
parent
6dc035ed91
commit
5afd6d8206
@ -277,7 +277,9 @@ impl AtomicBool {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn store(&self, val: bool, order: Ordering) {
|
pub fn store(&self, val: bool, order: Ordering) {
|
||||||
unsafe { atomic_store(self.v.get(), val as u8, order); }
|
unsafe {
|
||||||
|
atomic_store(self.v.get(), val as u8, order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a value into the bool, returning the old value.
|
/// Stores a value into the bool, returning the old value.
|
||||||
@ -366,9 +368,11 @@ impl AtomicBool {
|
|||||||
current: bool,
|
current: bool,
|
||||||
new: bool,
|
new: bool,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<bool, bool> {
|
failure: Ordering)
|
||||||
match unsafe { atomic_compare_exchange(self.v.get(), current as u8, new as u8,
|
-> Result<bool, bool> {
|
||||||
success, failure) } {
|
match unsafe {
|
||||||
|
atomic_compare_exchange(self.v.get(), current as u8, new as u8, success, failure)
|
||||||
|
} {
|
||||||
Ok(x) => Ok(x != 0),
|
Ok(x) => Ok(x != 0),
|
||||||
Err(x) => Err(x != 0),
|
Err(x) => Err(x != 0),
|
||||||
}
|
}
|
||||||
@ -409,9 +413,11 @@ impl AtomicBool {
|
|||||||
current: bool,
|
current: bool,
|
||||||
new: bool,
|
new: bool,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<bool, bool> {
|
failure: Ordering)
|
||||||
match unsafe { atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8,
|
-> Result<bool, bool> {
|
||||||
success, failure) } {
|
match unsafe {
|
||||||
|
atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8, success, failure)
|
||||||
|
} {
|
||||||
Ok(x) => Ok(x != 0),
|
Ok(x) => Ok(x != 0),
|
||||||
Err(x) => Err(x != 0),
|
Err(x) => Err(x != 0),
|
||||||
}
|
}
|
||||||
@ -632,9 +638,7 @@ impl<T> AtomicPtr<T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn load(&self, order: Ordering) -> *mut T {
|
pub fn load(&self, order: Ordering) -> *mut T {
|
||||||
unsafe {
|
unsafe { atomic_load(self.p.get() as *mut usize, order) as *mut T }
|
||||||
atomic_load(self.p.get() as *mut usize, order) as *mut T
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a value into the pointer.
|
/// Stores a value into the pointer.
|
||||||
@ -660,7 +664,9 @@ impl<T> AtomicPtr<T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn store(&self, ptr: *mut T, order: Ordering) {
|
pub fn store(&self, ptr: *mut T, order: Ordering) {
|
||||||
unsafe { atomic_store(self.p.get() as *mut usize, ptr as usize, order); }
|
unsafe {
|
||||||
|
atomic_store(self.p.get() as *mut usize, ptr as usize, order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a value into the pointer, returning the old value.
|
/// Stores a value into the pointer, returning the old value.
|
||||||
@ -745,7 +751,8 @@ impl<T> AtomicPtr<T> {
|
|||||||
current: *mut T,
|
current: *mut T,
|
||||||
new: *mut T,
|
new: *mut T,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<*mut T, *mut T> {
|
failure: Ordering)
|
||||||
|
-> Result<*mut T, *mut T> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let res = atomic_compare_exchange(self.p.get() as *mut usize,
|
let res = atomic_compare_exchange(self.p.get() as *mut usize,
|
||||||
current as usize,
|
current as usize,
|
||||||
@ -794,7 +801,8 @@ impl<T> AtomicPtr<T> {
|
|||||||
current: *mut T,
|
current: *mut T,
|
||||||
new: *mut T,
|
new: *mut T,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<*mut T, *mut T> {
|
failure: Ordering)
|
||||||
|
-> Result<*mut T, *mut T> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let res = atomic_compare_exchange_weak(self.p.get() as *mut usize,
|
let res = atomic_compare_exchange_weak(self.p.get() as *mut usize,
|
||||||
current as usize,
|
current as usize,
|
||||||
@ -1301,7 +1309,7 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_xchg_rel(dst, val),
|
Release => intrinsics::atomic_xchg_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_xchg(dst, val)
|
SeqCst => intrinsics::atomic_xchg(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,7 +1321,7 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_xadd_rel(dst, val),
|
Release => intrinsics::atomic_xadd_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_xadd_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_xadd_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_xadd(dst, val)
|
SeqCst => intrinsics::atomic_xadd(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1325,7 +1333,7 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_xsub_rel(dst, val),
|
Release => intrinsics::atomic_xsub_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_xsub_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_xsub_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_xsub(dst, val)
|
SeqCst => intrinsics::atomic_xsub(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1334,7 +1342,8 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
|
|||||||
old: T,
|
old: T,
|
||||||
new: T,
|
new: T,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<T, T> {
|
failure: Ordering)
|
||||||
|
-> Result<T, T> {
|
||||||
let (val, ok) = match (success, failure) {
|
let (val, ok) = match (success, failure) {
|
||||||
(Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new),
|
(Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new),
|
||||||
(Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new),
|
(Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new),
|
||||||
@ -1349,11 +1358,7 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
|
|||||||
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
||||||
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
||||||
};
|
};
|
||||||
if ok {
|
if ok { Ok(val) } else { Err(val) }
|
||||||
Ok(val)
|
|
||||||
} else {
|
|
||||||
Err(val)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1361,7 +1366,8 @@ unsafe fn atomic_compare_exchange_weak<T>(dst: *mut T,
|
|||||||
old: T,
|
old: T,
|
||||||
new: T,
|
new: T,
|
||||||
success: Ordering,
|
success: Ordering,
|
||||||
failure: Ordering) -> Result<T, T> {
|
failure: Ordering)
|
||||||
|
-> Result<T, T> {
|
||||||
let (val, ok) = match (success, failure) {
|
let (val, ok) = match (success, failure) {
|
||||||
(Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new),
|
(Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new),
|
||||||
(Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new),
|
(Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new),
|
||||||
@ -1376,11 +1382,7 @@ unsafe fn atomic_compare_exchange_weak<T>(dst: *mut T,
|
|||||||
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
||||||
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
||||||
};
|
};
|
||||||
if ok {
|
if ok { Ok(val) } else { Err(val) }
|
||||||
Ok(val)
|
|
||||||
} else {
|
|
||||||
Err(val)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1390,7 +1392,7 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_and_rel(dst, val),
|
Release => intrinsics::atomic_and_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_and_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_and_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_and_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_and_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_and(dst, val)
|
SeqCst => intrinsics::atomic_and(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,7 +1403,7 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_or_rel(dst, val),
|
Release => intrinsics::atomic_or_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_or_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_or_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_or_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_or_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_or(dst, val)
|
SeqCst => intrinsics::atomic_or(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,7 +1414,7 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
Release => intrinsics::atomic_xor_rel(dst, val),
|
Release => intrinsics::atomic_xor_rel(dst, val),
|
||||||
AcqRel => intrinsics::atomic_xor_acqrel(dst, val),
|
AcqRel => intrinsics::atomic_xor_acqrel(dst, val),
|
||||||
Relaxed => intrinsics::atomic_xor_relaxed(dst, val),
|
Relaxed => intrinsics::atomic_xor_relaxed(dst, val),
|
||||||
SeqCst => intrinsics::atomic_xor(dst, val)
|
SeqCst => intrinsics::atomic_xor(dst, val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1445,7 +1447,7 @@ pub fn fence(order: Ordering) {
|
|||||||
Release => intrinsics::atomic_fence_rel(),
|
Release => intrinsics::atomic_fence_rel(),
|
||||||
AcqRel => intrinsics::atomic_fence_acqrel(),
|
AcqRel => intrinsics::atomic_fence_acqrel(),
|
||||||
SeqCst => intrinsics::atomic_fence(),
|
SeqCst => intrinsics::atomic_fence(),
|
||||||
Relaxed => panic!("there is no such thing as a relaxed fence")
|
Relaxed => panic!("there is no such thing as a relaxed fence"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user