Rollup merge of #126792 - wooden-worm:master, r=Mark-Simulacrum · model-checking/verify-rust-std@5dfdef7 (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ where
30 30 use core::arch::arm::{uint8x8_t, vtbl1_u8};
31 31 #[cfg(target_arch = "wasm32")]
32 32 use core::arch::wasm32 as wasm;
33 +#[cfg(target_arch = "wasm64")]
34 +use core::arch::wasm64 as wasm;
33 35 #[cfg(target_arch = "x86")]
34 36 use core::arch::x86;
35 37 #[cfg(target_arch = "x86_64")]
Original file line number Diff line number Diff line change
@@ -266,6 +266,7 @@
266 266 )]
267 267 #![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
268 268 #![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
269 +#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
269 270 #![cfg_attr(
270 271 all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"),
271 272 feature(stdarch_x86_has_cpuid)
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
1 -use crate::arch::wasm32;
1 +#[cfg(target_arch = "wasm32")]
2 +use core::arch::wasm32 as wasm;
3 +#[cfg(target_arch = "wasm64")]
4 +use core::arch::wasm64 as wasm;
5 +
2 6 use crate::sync::atomic::AtomicU32;
3 7 use crate::time::Duration;
4 8
@@ -10,11 +14,8 @@ use crate::time::Duration;
10 14 pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
11 15 let timeout = timeout.and_then(|t
12 16 unsafe {
13 - wasm32::memory_atomic_wait32(
14 - futex as *const AtomicU32 as *mut i32,
15 - expected as i32,
16 - timeout,
17 -) < 2
17 + wasm::memory_atomic_wait32(futex as *const AtomicU32 as *mut i32, expected as i32, timeout)
18 + < 2
18 19 }
19 20 }
20 21
@@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) -
23 24 /// Returns true if this actually woke up such a thread,
24 25 /// or false if no thread was waiting on this futex.
25 26 pub fn futex_wake(futex: &AtomicU32) -> bool {
26 -unsafe { wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
27 +unsafe { wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
27 28 }
28 29
29 30 /// Wake up all threads that are waiting on futex_wait on this futex.
30 31 pub fn futex_wake_all(futex: &AtomicU32) {
31 32 unsafe {
32 -wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
33 +wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
33 34 }
34 35 }
Original file line number Diff line number Diff line change
@@ -19,7 +19,11 @@ impl Thread {
19 19 pub fn set_name(_name: &CStr) {}
20 20
21 21 pub fn sleep(dur: Duration) {
22 -use crate::arch::wasm32;
22 +#[cfg(target_arch = "wasm32")]
23 +use core::arch::wasm32 as wasm;
24 +#[cfg(target_arch = "wasm64")]
25 +use core::arch::wasm64 as wasm;
26 +
23 27 use crate::cmp;
24 28
25 29 // Use an atomic wait to block the current thread artificially with a
@@ -31,7 +35,7 @@ impl Thread {
31 35 while nanos > 0 {
32 36 let amt = cmp::min(i64::MAX as u128, nanos);
33 37 let mut x = 0;
34 -let val = unsafe { wasm32::memory_atomic_wait32(&mut x, 0, amt as i64) };
38 +let val = unsafe { wasm::memory_atomic_wait32(&mut x, 0, amt as i64) };
35 39 debug_assert_eq!(val, 2);
36 40 nanos -= amt;
37 41 }