]> git.lizzy.rs Git - rust.git/commitdiff
Windows lock primitives: check that we are truly sinle-threaded
authorRalf Jung <post@ralfj.de>
Mon, 4 May 2020 07:37:40 +0000 (09:37 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 4 May 2020 07:37:40 +0000 (09:37 +0200)
src/shims/foreign_items/windows.rs

index a58444b21bff1d6bbd37a25e93f4b373a13aacda..f55b5b8450e04f47ba98e0494531d4f30a3e97fa 100644 (file)
@@ -236,12 +236,14 @@ fn emulate_foreign_item_by_name(
             | "LeaveCriticalSection"
             | "DeleteCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::")
             => {
+                assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
                 // Nothing to do, not even a return value.
                 // (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::")
             => {
+                assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
                 // There is only one thread, so this always succeeds and returns TRUE
                 this.write_scalar(Scalar::from_i32(1), dest)?;
             }