From ceba87603f43965d52f3011898d02363482970ce Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Tue, 4 Aug 2020 20:15:02 +0200 Subject: [PATCH] Bump MSRV to 1.45.0 and therefore remove the has_fetch_min configuration flag. --- .travis.yml | 2 +- build.rs | 5 ----- src/ops.rs | 43 ++++++++++++++++--------------------------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19bef58..60d629b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ rust: - nightly - beta - stable -- 1.31.0 +- 1.45.0 before_script: - | diff --git a/build.rs b/build.rs index 1bc2c01..fb7c6c5 100644 --- a/build.rs +++ b/build.rs @@ -23,10 +23,5 @@ fn main() { &format!("has_atomic_i{}", size), ); } - - ac.emit_expression_cfg( - &format!("{}::sync::atomic::AtomicUsize::fetch_min", root), - "has_fetch_min", - ); } } diff --git a/src/ops.rs b/src/ops.rs index 40a50da..23bd8ac 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -96,13 +96,14 @@ macro_rules! match_signed_atomic { #[inline] pub const fn atomic_is_lock_free() -> bool { - (cfg!(has_atomic_u8) & (mem::size_of::() == 1) & (mem::align_of::() >= 1)) - | (cfg!(has_atomic_u16) & (mem::size_of::() == 2) & (mem::align_of::() >= 2)) - | (cfg!(has_atomic_u32) & (mem::size_of::() == 4) & (mem::align_of::() >= 4)) - | (cfg!(has_atomic_u64) & (mem::size_of::() == 8) & (mem::align_of::() >= 8)) - | (cfg!(has_atomic_usize) - & (mem::size_of::() == mem::size_of::()) - & (mem::align_of::() >= mem::align_of::())) + let size = mem::size_of::(); + let align = mem::align_of::(); + + (cfg!(has_atomic_u8) & (size == 1) & (align >= 1)) + | (cfg!(has_atomic_u16) & (size == 2) & (align >= 2)) + | (cfg!(has_atomic_u32) & (size == 4) & (align >= 4)) + | (cfg!(has_atomic_u64) & (size == 8) & (align >= 8)) + | (cfg!(has_atomic_usize) & (size == SIZEOF_USIZE) & (align >= ALIGNOF_USIZE)) } #[inline] @@ -255,52 +256,40 @@ pub unsafe fn atomic_xor>( #[inline] pub unsafe fn atomic_min(dst: *mut T, val: T, order: Ordering) -> T { - #[cfg(has_fetch_min)] - return match_signed_atomic!( + match_signed_atomic!( T, A, mem::transmute_copy(&(*(dst as *const A)).fetch_min(mem::transmute_copy(&val), order),), fallback::atomic_min(dst, val) - ); - #[cfg(not(has_fetch_min))] - return fallback::atomic_min(dst, val); + ) } #[inline] pub unsafe fn atomic_max(dst: *mut T, val: T, order: Ordering) -> T { - #[cfg(has_fetch_min)] - return match_signed_atomic!( + match_signed_atomic!( T, A, mem::transmute_copy(&(*(dst as *const A)).fetch_max(mem::transmute_copy(&val), order),), fallback::atomic_max(dst, val) - ); - #[cfg(not(has_fetch_min))] - return fallback::atomic_max(dst, val); + ) } #[inline] pub unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { - #[cfg(has_fetch_min)] - return match_atomic!( + match_atomic!( T, A, mem::transmute_copy(&(*(dst as *const A)).fetch_min(mem::transmute_copy(&val), order),), fallback::atomic_min(dst, val) - ); - #[cfg(not(has_fetch_min))] - return fallback::atomic_min(dst, val); + ) } #[inline] pub unsafe fn atomic_umax(dst: *mut T, val: T, order: Ordering) -> T { - #[cfg(has_fetch_min)] - return match_atomic!( + match_atomic!( T, A, mem::transmute_copy(&(*(dst as *const A)).fetch_max(mem::transmute_copy(&val), order),), fallback::atomic_max(dst, val) - ); - #[cfg(not(has_fetch_min))] - fallback::atomic_max(dst, val) + ) }