Rollup merge of #126792 - wooden-worm:master, r=Mark-Simulacrum
wasm64 build with target-feature=+simd128,+atomics Fixes https://github.com/rust-lang/rust/issues/126778
This commit is contained in:
commit
6cf34c0cfd
@ -30,6 +30,8 @@ pub fn swizzle_dyn(self, idxs: Simd<u8, N>) -> Self {
|
||||
use core::arch::arm::{uint8x8_t, vtbl1_u8};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use core::arch::wasm32 as wasm;
|
||||
#[cfg(target_arch = "wasm64")]
|
||||
use core::arch::wasm64 as wasm;
|
||||
#[cfg(target_arch = "x86")]
|
||||
use core::arch::x86;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
@ -266,6 +266,7 @@
|
||||
)]
|
||||
#![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
|
||||
#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
|
||||
#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
|
||||
#![cfg_attr(
|
||||
all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"),
|
||||
feature(stdarch_x86_has_cpuid)
|
||||
|
@ -1,4 +1,8 @@
|
||||
use crate::arch::wasm32;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use core::arch::wasm32 as wasm;
|
||||
#[cfg(target_arch = "wasm64")]
|
||||
use core::arch::wasm64 as wasm;
|
||||
|
||||
use crate::sync::atomic::AtomicU32;
|
||||
use crate::time::Duration;
|
||||
|
||||
@ -10,11 +14,8 @@
|
||||
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
|
||||
let timeout = timeout.and_then(|t| t.as_nanos().try_into().ok()).unwrap_or(-1);
|
||||
unsafe {
|
||||
wasm32::memory_atomic_wait32(
|
||||
futex as *const AtomicU32 as *mut i32,
|
||||
expected as i32,
|
||||
timeout,
|
||||
) < 2
|
||||
wasm::memory_atomic_wait32(futex as *const AtomicU32 as *mut i32, expected as i32, timeout)
|
||||
< 2
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
|
||||
/// Returns true if this actually woke up such a thread,
|
||||
/// or false if no thread was waiting on this futex.
|
||||
pub fn futex_wake(futex: &AtomicU32) -> bool {
|
||||
unsafe { wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
|
||||
unsafe { wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
|
||||
}
|
||||
|
||||
/// Wake up all threads that are waiting on futex_wait on this futex.
|
||||
pub fn futex_wake_all(futex: &AtomicU32) {
|
||||
unsafe {
|
||||
wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
|
||||
wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,11 @@ pub fn yield_now() {}
|
||||
pub fn set_name(_name: &CStr) {}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
use crate::arch::wasm32;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use core::arch::wasm32 as wasm;
|
||||
#[cfg(target_arch = "wasm64")]
|
||||
use core::arch::wasm64 as wasm;
|
||||
|
||||
use crate::cmp;
|
||||
|
||||
// Use an atomic wait to block the current thread artificially with a
|
||||
@ -31,7 +35,7 @@ pub fn sleep(dur: Duration) {
|
||||
while nanos > 0 {
|
||||
let amt = cmp::min(i64::MAX as u128, nanos);
|
||||
let mut x = 0;
|
||||
let val = unsafe { wasm32::memory_atomic_wait32(&mut x, 0, amt as i64) };
|
||||
let val = unsafe { wasm::memory_atomic_wait32(&mut x, 0, amt as i64) };
|
||||
debug_assert_eq!(val, 2);
|
||||
nanos -= amt;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user