-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved atomic intrinsics tests, added description * Add support for `atomic_nand*` * Support for `atomic_singlethreadfence` and variants * Add missing test for `atomic_cxchgweak` * Add negative tests for min & max atomics * Update doc with missing intrinsics
- Loading branch information
1 parent
a55d94c
commit c361394
Showing
47 changed files
with
710 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/kani/Atomics/Stable/Fence/main.rs → ...ni/Intrinsics/Atomic/Stable/Fence/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/kani/Atomics/Stable/Load/main.rs → ...ani/Intrinsics/Atomic/Stable/Load/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/kani/Atomics/Stable/Store/main.rs → ...ni/Intrinsics/Atomic/Stable/Store/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...s/kani/Atomics/Unstable/AtomicAdd/main.rs → ...rinsics/Atomic/Unstable/AtomicAdd/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...s/kani/Atomics/Unstable/AtomicAnd/main.rs → ...rinsics/Atomic/Unstable/AtomicAnd/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...kani/Atomics/Unstable/AtomicCxchg/main.rs → ...nsics/Atomic/Unstable/AtomicCxchg/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
tests/kani/Intrinsics/Atomic/Unstable/AtomicCxchgWeak/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that `atomic_cxchgweak` and other variants (unstable version) return | ||
// the expected result. | ||
|
||
#![feature(core_intrinsics)] | ||
use std::intrinsics::{ | ||
atomic_cxchgweak, atomic_cxchgweak_acq, atomic_cxchgweak_acq_failrelaxed, | ||
atomic_cxchgweak_acqrel, atomic_cxchgweak_acqrel_failrelaxed, atomic_cxchgweak_failacq, | ||
atomic_cxchgweak_failrelaxed, atomic_cxchgweak_rel, atomic_cxchgweak_relaxed, | ||
}; | ||
|
||
fn main() { | ||
let mut a1 = 0 as u8; | ||
let mut a2 = 0 as u8; | ||
let mut a3 = 0 as u8; | ||
let mut a4 = 0 as u8; | ||
let mut a5 = 0 as u8; | ||
let mut a6 = 0 as u8; | ||
let mut a7 = 0 as u8; | ||
let mut a8 = 0 as u8; | ||
let mut a9 = 0 as u8; | ||
|
||
let ptr_a1: *mut u8 = &mut a1; | ||
let ptr_a2: *mut u8 = &mut a2; | ||
let ptr_a3: *mut u8 = &mut a3; | ||
let ptr_a4: *mut u8 = &mut a4; | ||
let ptr_a5: *mut u8 = &mut a5; | ||
let ptr_a6: *mut u8 = &mut a6; | ||
let ptr_a7: *mut u8 = &mut a7; | ||
let ptr_a8: *mut u8 = &mut a8; | ||
let ptr_a9: *mut u8 = &mut a9; | ||
|
||
unsafe { | ||
// Stores a value if the current value is the same as the old value | ||
// Returns (val, ok) where | ||
// * val: the old value | ||
// * ok: bool indicating whether the operation was successful or not | ||
let x1 = atomic_cxchgweak(ptr_a1, 0, 1); | ||
let x2 = atomic_cxchgweak_acq(ptr_a2, 0, 1); | ||
let x3 = atomic_cxchgweak_acq_failrelaxed(ptr_a3, 0, 1); | ||
let x4 = atomic_cxchgweak_acqrel(ptr_a4, 0, 1); | ||
let x5 = atomic_cxchgweak_acqrel_failrelaxed(ptr_a5, 0, 1); | ||
let x6 = atomic_cxchgweak_failacq(ptr_a6, 0, 1); | ||
let x7 = atomic_cxchgweak_failrelaxed(ptr_a7, 0, 1); | ||
let x8 = atomic_cxchgweak_rel(ptr_a8, 0, 1); | ||
let x9 = atomic_cxchgweak_relaxed(ptr_a9, 0, 1); | ||
|
||
assert!(x1 == (0, true)); | ||
assert!(x2 == (0, true)); | ||
assert!(x3 == (0, true)); | ||
assert!(x4 == (0, true)); | ||
assert!(x5 == (0, true)); | ||
assert!(x6 == (0, true)); | ||
assert!(x7 == (0, true)); | ||
assert!(x8 == (0, true)); | ||
assert!(x9 == (0, true)); | ||
|
||
let y1 = atomic_cxchgweak(ptr_a1, 1, 1); | ||
let y2 = atomic_cxchgweak_acq(ptr_a2, 1, 1); | ||
let y3 = atomic_cxchgweak_acq_failrelaxed(ptr_a3, 1, 1); | ||
let y4 = atomic_cxchgweak_acqrel(ptr_a4, 1, 1); | ||
let y5 = atomic_cxchgweak_acqrel_failrelaxed(ptr_a5, 1, 1); | ||
let y6 = atomic_cxchgweak_failacq(ptr_a6, 1, 1); | ||
let y7 = atomic_cxchgweak_failrelaxed(ptr_a7, 1, 1); | ||
let y8 = atomic_cxchgweak_rel(ptr_a8, 1, 1); | ||
let y9 = atomic_cxchgweak_relaxed(ptr_a9, 1, 1); | ||
|
||
assert!(y1 == (1, true)); | ||
assert!(y2 == (1, true)); | ||
assert!(y3 == (1, true)); | ||
assert!(y4 == (1, true)); | ||
assert!(y5 == (1, true)); | ||
assert!(y6 == (1, true)); | ||
assert!(y7 == (1, true)); | ||
assert!(y8 == (1, true)); | ||
assert!(y9 == (1, true)); | ||
} | ||
} |
Oops, something went wrong.