2 #![feature(intrinsics)]
5 extern "rust-intrinsic" {
6 pub fn atomic_cxchg_seqcst_seqcst<T>(dst: *mut T, old: T, src: T) -> (T, bool);
7 pub fn atomic_cxchg_acquire_acquire<T>(dst: *mut T, old: T, src: T) -> (T, bool);
8 pub fn atomic_cxchg_release_relaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);
10 pub fn atomic_cxchgweak_seqcst_seqcst<T>(dst: *mut T, old: T, src: T) -> (T, bool);
11 pub fn atomic_cxchgweak_acquire_acquire<T>(dst: *mut T, old: T, src: T) -> (T, bool);
12 pub fn atomic_cxchgweak_release_relaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);
14 pub fn atomic_load_seqcst<T>(src: *const T) -> T;
15 pub fn atomic_load_acquire<T>(src: *const T) -> T;
17 pub fn atomic_store_seqcst<T>(dst: *mut T, val: T);
18 pub fn atomic_store_release<T>(dst: *mut T, val: T);
20 pub fn atomic_xchg_seqcst<T>(dst: *mut T, src: T) -> T;
21 pub fn atomic_xchg_acquire<T>(dst: *mut T, src: T) -> T;
22 pub fn atomic_xchg_release<T>(dst: *mut T, src: T) -> T;
24 pub fn atomic_xadd_seqcst<T>(dst: *mut T, src: T) -> T;
25 pub fn atomic_xadd_acquire<T>(dst: *mut T, src: T) -> T;
26 pub fn atomic_xadd_release<T>(dst: *mut T, src: T) -> T;
28 pub fn atomic_xsub_seqcst<T>(dst: *mut T, src: T) -> T;
29 pub fn atomic_xsub_acquire<T>(dst: *mut T, src: T) -> T;
30 pub fn atomic_xsub_release<T>(dst: *mut T, src: T) -> T;
36 let mut x: Box<_> = Box::new(1);
38 assert_eq!(rusti::atomic_load_seqcst(&*x), 1);
40 assert_eq!(rusti::atomic_load_acquire(&*x), 5);
42 rusti::atomic_store_seqcst(&mut *x,3);
44 rusti::atomic_store_release(&mut *x,1);
47 assert_eq!(rusti::atomic_cxchg_seqcst_seqcst(&mut *x, 1, 2), (1, true));
50 assert_eq!(rusti::atomic_cxchg_acquire_acquire(&mut *x, 1, 3), (2, false));
53 assert_eq!(rusti::atomic_cxchg_release_relaxed(&mut *x, 2, 1), (2, true));
56 assert_eq!(rusti::atomic_xchg_seqcst(&mut *x, 0), 1);
59 assert_eq!(rusti::atomic_xchg_acquire(&mut *x, 1), 0);
62 assert_eq!(rusti::atomic_xchg_release(&mut *x, 0), 1);
65 assert_eq!(rusti::atomic_xadd_seqcst(&mut *x, 1), 0);
66 assert_eq!(rusti::atomic_xadd_acquire(&mut *x, 1), 1);
67 assert_eq!(rusti::atomic_xadd_release(&mut *x, 1), 2);
70 assert_eq!(rusti::atomic_xsub_seqcst(&mut *x, 1), 3);
71 assert_eq!(rusti::atomic_xsub_acquire(&mut *x, 1), 2);
72 assert_eq!(rusti::atomic_xsub_release(&mut *x, 1), 1);
76 let res = rusti::atomic_cxchgweak_seqcst_seqcst(&mut *x, 0, 1);
85 let res = rusti::atomic_cxchgweak_acquire_acquire(&mut *x, 1, 2);
94 let res = rusti::atomic_cxchgweak_release_relaxed(&mut *x, 2, 3);