diff --git a/src/shims/foreign_items/windows.rs b/src/shims/foreign_items/windows.rs index cfc94bfd9b71..3c819fddc410 100644 --- a/src/shims/foreign_items/windows.rs +++ b/src/shims/foreign_items/windows.rs @@ -233,6 +233,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // (Windows locks are reentrant, and we have only 1 thread, // so not doing any futher checks here is at least not incorrect.) } + "TryEnterCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::") + => { + // There is only one thread, so this always succeeds and returns TRUE + this.write_scalar(Scalar::from_int(1, dest.layout.size), dest)?; + } _ => throw_unsup_format!("can't call foreign function: {}", link_name), } diff --git a/tests/run-pass/sync.rs b/tests/run-pass/sync.rs index 24d7b0be5342..0ddf429fad9c 100644 --- a/tests/run-pass/sync.rs +++ b/tests/run-pass/sync.rs @@ -1,6 +1,6 @@ #![feature(rustc_private)] -use std::sync::{Mutex, RwLock, TryLockError}; +use std::sync::{Mutex, TryLockError}; extern crate libc; @@ -86,6 +86,7 @@ fn test_mutex_libc_static_initializer_recursive() { #[cfg(not(target_os = "windows"))] fn test_rwlock_stdlib() { + use std::sync::RwLock; let rw = RwLock::new(0); { let _read_guard = rw.read().unwrap();