Handle std::sync::atomic::spin_loop_hint()

This commit is contained in:
David Cook 2020-04-16 23:24:57 -05:00
parent 9b4af73eb0
commit 57c7119315
2 changed files with 19 additions and 4 deletions

View File

@ -434,10 +434,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
}
// Target-specific shims
_ => match this.tcx.sess.target.target.target_os.as_str() {
"linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
"windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
target => throw_unsup_format!("the target `{}` is not supported", target),
_ => {
match this.tcx.sess.target.target.arch.as_str() {
"x86" | "x86_64" => match link_name {
"llvm.x86.sse2.pause" => return Ok(true),
_ => {}
}
_ => {}
}
match this.tcx.sess.target.target.target_os.as_str() {
"linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
"windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
target => throw_unsup_format!("the target `{}` is not supported", target),
}
}
};

View File

@ -1,6 +1,7 @@
#![feature(rustc_private)]
use std::sync::{Mutex, TryLockError};
use std::sync::atomic;
fn main() {
test_mutex_stdlib();
@ -8,6 +9,7 @@ fn main() {
{
test_rwlock_stdlib();
}
test_spin_loop_hint();
}
fn test_mutex_stdlib() {
@ -50,3 +52,7 @@ impl<T> TryLockErrorExt<T> for TryLockError<T> {
}
}
}
fn test_spin_loop_hint() {
atomic::spin_loop_hint();
}