Implement TryEnterCriticalSection

This commit is contained in:
David Cook
2020-03-28 10:16:08 -05:00
parent bb06a0cf0e
commit 37ddde9f70
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -233,6 +233,11 @@ fn emulate_foreign_item_by_name(
// (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),
}
+2 -1
View File
@@ -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();