From d1a541e34290364681550e82fe606d21c7235345 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 14 Feb 2021 11:31:33 +0100 Subject: [PATCH 1/3] Add tests for Atomic*::fetch_{min,max} --- library/core/tests/atomic.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs index 2d1e4496aeef7..762642aecdab6 100644 --- a/library/core/tests/atomic.rs +++ b/library/core/tests/atomic.rs @@ -59,6 +59,24 @@ fn uint_xor() { assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f); } +#[test] +fn uint_min() { + let x = AtomicUsize::new(0xf731); + assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), 0x137f); + assert_eq!(x.fetch_min(0xf731, SeqCst), 0x137f); + assert_eq!(x.load(SeqCst), 0x137f); +} + +#[test] +fn uint_max() { + let x = AtomicUsize::new(0x137f); + assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f); + assert_eq!(x.load(SeqCst), 0xf731); + assert_eq!(x.fetch_max(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), 0xf731); +} + #[test] fn int_and() { let x = AtomicIsize::new(0xf731); @@ -87,6 +105,24 @@ fn int_xor() { assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f); } +#[test] +fn int_min() { + let x = AtomicIsize::new(0xf731); + assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), 0x137f); + assert_eq!(x.fetch_min(0xf731, SeqCst), 0x137f); + assert_eq!(x.load(SeqCst), 0x137f); +} + +#[test] +fn int_max() { + let x = AtomicIsize::new(0x137f); + assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f); + assert_eq!(x.load(SeqCst), 0xf731); + assert_eq!(x.fetch_max(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), 0xf731); +} + static S_FALSE: AtomicBool = AtomicBool::new(false); static S_TRUE: AtomicBool = AtomicBool::new(true); static S_INT: AtomicIsize = AtomicIsize::new(0); From dfdadad228e0885d43ced8117978c77d6973f05e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Feb 2021 09:45:27 +0100 Subject: [PATCH 2/3] Ignore Atomic*::fetch_{min,max} tests on ARM --- library/core/tests/atomic.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs index 762642aecdab6..901b752502dd8 100644 --- a/library/core/tests/atomic.rs +++ b/library/core/tests/atomic.rs @@ -60,6 +60,7 @@ fn uint_xor() { } #[test] +#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins fn uint_min() { let x = AtomicUsize::new(0xf731); assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); @@ -69,6 +70,7 @@ fn uint_min() { } #[test] +#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins fn uint_max() { let x = AtomicUsize::new(0x137f); assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f); @@ -106,6 +108,7 @@ fn int_xor() { } #[test] +#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins fn int_min() { let x = AtomicIsize::new(0xf731); assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); @@ -115,6 +118,7 @@ fn int_min() { } #[test] +#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins fn int_max() { let x = AtomicIsize::new(0x137f); assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f); From 4fa9e08e3dc10acdb322490d5ac24e937c0f43f5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 17 Feb 2021 10:01:29 +0100 Subject: [PATCH 3/3] Enable the tests on Arm Linux too --- library/core/tests/atomic.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs index 901b752502dd8..b735957666fc5 100644 --- a/library/core/tests/atomic.rs +++ b/library/core/tests/atomic.rs @@ -60,7 +60,7 @@ fn uint_xor() { } #[test] -#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins +#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins fn uint_min() { let x = AtomicUsize::new(0xf731); assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); @@ -70,7 +70,7 @@ fn uint_min() { } #[test] -#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins +#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins fn uint_max() { let x = AtomicUsize::new(0x137f); assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f); @@ -108,7 +108,7 @@ fn int_xor() { } #[test] -#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins +#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins fn int_min() { let x = AtomicIsize::new(0xf731); assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731); @@ -118,7 +118,7 @@ fn int_min() { } #[test] -#[cfg(not(target_arch = "arm"))] // Missing intrinsic in compiler-builtins +#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins fn int_max() { let x = AtomicIsize::new(0x137f); assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f);