Skip to content

Commit 57c7119

Browse files
committed
Handle std::sync::atomic::spin_loop_hint()
1 parent 9b4af73 commit 57c7119

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/shims/foreign_items.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
434434
}
435435

436436
// Target-specific shims
437-
_ => match this.tcx.sess.target.target.target_os.as_str() {
438-
"linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
439-
"windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
440-
target => throw_unsup_format!("the target `{}` is not supported", target),
437+
_ => {
438+
match this.tcx.sess.target.target.arch.as_str() {
439+
"x86" | "x86_64" => match link_name {
440+
"llvm.x86.sse2.pause" => return Ok(true),
441+
_ => {}
442+
}
443+
_ => {}
444+
}
445+
match this.tcx.sess.target.target.target_os.as_str() {
446+
"linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
447+
"windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
448+
target => throw_unsup_format!("the target `{}` is not supported", target),
449+
}
441450
}
442451
};
443452

tests/run-pass/sync.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#![feature(rustc_private)]
22

33
use std::sync::{Mutex, TryLockError};
4+
use std::sync::atomic;
45

56
fn main() {
67
test_mutex_stdlib();
78
#[cfg(not(target_os = "windows"))] // TODO: implement RwLock on Windows
89
{
910
test_rwlock_stdlib();
1011
}
12+
test_spin_loop_hint();
1113
}
1214

1315
fn test_mutex_stdlib() {
@@ -50,3 +52,7 @@ impl<T> TryLockErrorExt<T> for TryLockError<T> {
5052
}
5153
}
5254
}
55+
56+
fn test_spin_loop_hint() {
57+
atomic::spin_loop_hint();
58+
}

0 commit comments

Comments
 (0)