rustc: add new intrinsics - atomic_cxchg{_acq,_rel}

This commit is contained in:
Luqman Aden 2012-10-21 22:23:50 -04:00
parent 082d3d5167
commit e1db959ec2
9 changed files with 73 additions and 6 deletions

View file

@ -1,6 +1,10 @@
#[abi = "rust-intrinsic"]
extern mod rusti {
#[legacy_exports];
fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
fn atomic_xchg(dst: &mut int, src: int) -> int;
fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
@ -17,6 +21,15 @@ extern mod rusti {
fn main() {
let x = ~mut 1;
assert rusti::atomic_cxchg(x, 1, 2) == 1;
assert *x == 2;
assert rusti::atomic_cxchg_acq(x, 1, 3) == 2;
assert *x == 2;
assert rusti::atomic_cxchg_rel(x, 2, 1) == 2;
assert *x == 1;
assert rusti::atomic_xchg(x, 0) == 1;
assert *x == 0;