cci_inrinsic tets: do not use atomic intrinsic
This commit is contained in:
parent
2a3a6150d4
commit
52824052d7
3 changed files with 14 additions and 29 deletions
|
|
@ -1,24 +1,12 @@
|
|||
#![feature(intrinsics, adt_const_params)]
|
||||
|
||||
pub mod rusti {
|
||||
use std::marker::ConstParamTy;
|
||||
|
||||
#[derive(Debug, ConstParamTy, PartialEq, Eq)]
|
||||
pub enum AtomicOrdering {
|
||||
// These values must match the compiler's `AtomicOrdering` defined in
|
||||
// `rustc_middle/src/ty/consts/int.rs`!
|
||||
Relaxed = 0,
|
||||
Release = 1,
|
||||
Acquire = 2,
|
||||
AcqRel = 3,
|
||||
SeqCst = 4,
|
||||
}
|
||||
|
||||
mod rusti {
|
||||
#[rustc_intrinsic]
|
||||
pub unsafe fn atomic_xchg<T, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
|
||||
pub unsafe fn size_of_val<T: ?Sized>(ptr: *const T) -> usize;
|
||||
}
|
||||
|
||||
// A monomorphic function, inlined cross-crate, referencing an intrinsic.
|
||||
#[inline(always)]
|
||||
pub fn atomic_xchg_seqcst(dst: *mut isize, src: isize) -> isize {
|
||||
unsafe { rusti::atomic_xchg::<_, { rusti::AtomicOrdering::SeqCst }>(dst, src) }
|
||||
pub fn size_of_val(val: &[u8]) -> usize {
|
||||
unsafe { rusti::size_of_val(val) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
//@ run-pass
|
||||
//@ aux-build:cci_intrinsic.rs
|
||||
|
||||
|
||||
extern crate cci_intrinsic;
|
||||
use cci_intrinsic::atomic_xchg_seqcst;
|
||||
|
||||
pub fn main() {
|
||||
let mut x = 1;
|
||||
atomic_xchg_seqcst(&mut x, 5);
|
||||
assert_eq!(x, 5);
|
||||
}
|
||||
9
tests/ui/intrinsics/intrinsic-inline-cc.rs
Normal file
9
tests/ui/intrinsics/intrinsic-inline-cc.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//@ run-pass
|
||||
//@ aux-build:cci_intrinsic.rs
|
||||
|
||||
extern crate cci_intrinsic;
|
||||
|
||||
pub fn main() {
|
||||
let val = cci_intrinsic::size_of_val(&[1u8, 2, 3]);
|
||||
assert_eq!(val, 3);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue