-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for atomic_min*
and atomic_umin*
intrinsics
#1212
Changes from all commits
ec60b1b
43d3743
4b833aa
59ffdd5
b9faf99
d7bf342
fdf5aa4
5585467
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that `atomic_min` and other variants (unstable version) return the | ||
// expected result. | ||
|
||
#![feature(core_intrinsics)] | ||
use std::intrinsics::{ | ||
atomic_min, atomic_min_acq, atomic_min_acqrel, atomic_min_rel, atomic_min_relaxed, | ||
}; | ||
|
||
#[kani::proof] | ||
fn main() { | ||
let mut a1 = 1 as u8; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we only test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's pending in #25. But I'd like to do it once all atomic tests are in. |
||
let mut a2 = 1 as u8; | ||
let mut a3 = 1 as u8; | ||
let mut a4 = 1 as u8; | ||
let mut a5 = 1 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 b = 0 as u8; | ||
|
||
unsafe { | ||
let x1 = atomic_min(ptr_a1, b); | ||
let x2 = atomic_min_acq(ptr_a2, b); | ||
let x3 = atomic_min_acqrel(ptr_a3, b); | ||
let x4 = atomic_min_rel(ptr_a4, b); | ||
let x5 = atomic_min_relaxed(ptr_a5, b); | ||
|
||
assert!(x1 == 1); | ||
assert!(x2 == 1); | ||
assert!(x3 == 1); | ||
assert!(x4 == 1); | ||
assert!(x5 == 1); | ||
|
||
assert!(*ptr_a1 == b); | ||
assert!(*ptr_a2 == b); | ||
assert!(*ptr_a3 == b); | ||
assert!(*ptr_a4 == b); | ||
assert!(*ptr_a5 == b); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that `atomic_umin` and other variants (unstable version) return the | ||
// expected result. | ||
|
||
#![feature(core_intrinsics)] | ||
use std::intrinsics::{ | ||
atomic_umin, atomic_umin_acq, atomic_umin_acqrel, atomic_umin_rel, atomic_umin_relaxed, | ||
}; | ||
|
||
#[kani::proof] | ||
fn main() { | ||
let mut a1 = 1 as u8; | ||
let mut a2 = 1 as u8; | ||
let mut a3 = 1 as u8; | ||
let mut a4 = 1 as u8; | ||
let mut a5 = 1 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 b = 0 as u8; | ||
|
||
unsafe { | ||
let x1 = atomic_umin(ptr_a1, b); | ||
let x2 = atomic_umin_acq(ptr_a2, b); | ||
let x3 = atomic_umin_acqrel(ptr_a3, b); | ||
let x4 = atomic_umin_rel(ptr_a4, b); | ||
let x5 = atomic_umin_relaxed(ptr_a5, b); | ||
|
||
assert!(x1 == 1); | ||
assert!(x2 == 1); | ||
assert!(x3 == 1); | ||
assert!(x4 == 1); | ||
assert!(x5 == 1); | ||
|
||
assert!(*ptr_a1 == b); | ||
assert!(*ptr_a2 == b); | ||
assert!(*ptr_a3 == b); | ||
assert!(*ptr_a4 == b); | ||
assert!(*ptr_a5 == b); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are side effects, this will evaluate them twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the new changes, which complete the definition for
is_side_effect
and assert that neither of these cause side effects.