about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwooden-worm <93303706+wooden-worm@users.noreply.github.com>2024-06-23 22:58:30 -0700
committerwooden-worm <93303706+wooden-worm@users.noreply.github.com>2024-06-23 22:58:30 -0700
commit82c5cdc6b1de77634d63faacd6b606c99e816316 (patch)
treeb55b848d9df33766cab0ebbdb4ff168d164c9338
parent25c9f2ca06d6d8d5f314362ffd17e71a8df55546 (diff)
downloadrust-82c5cdc6b1de77634d63faacd6b606c99e816316.tar.gz
rust-82c5cdc6b1de77634d63faacd6b606c99e816316.zip
wasm64 build with target-feature=+simd128,+atomics
-rw-r--r--library/portable-simd/crates/core_simd/src/swizzle_dyn.rs2
-rw-r--r--library/std/src/lib.rs1
-rw-r--r--library/std/src/sys/pal/wasm/atomics/futex.rs17
-rw-r--r--library/std/src/sys/pal/wasm/atomics/thread.rs8
4 files changed, 18 insertions, 10 deletions
diff --git a/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs b/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs
index 8a1079042f0..3b6388d0f27 100644
--- a/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs
+++ b/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs
@@ -30,6 +30,8 @@ where
         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")]
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 80f67838ac0..f67e4a050cf 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -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)
diff --git a/library/std/src/sys/pal/wasm/atomics/futex.rs b/library/std/src/sys/pal/wasm/atomics/futex.rs
index f4fbe9f4855..a21b71efbbc 100644
--- a/library/std/src/sys/pal/wasm/atomics/futex.rs
+++ b/library/std/src/sys/pal/wasm/atomics/futex.rs
@@ -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 @@ use crate::time::Duration;
 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);
     }
 }
diff --git a/library/std/src/sys/pal/wasm/atomics/thread.rs b/library/std/src/sys/pal/wasm/atomics/thread.rs
index 484bd08495e..afdb159fe6f 100644
--- a/library/std/src/sys/pal/wasm/atomics/thread.rs
+++ b/library/std/src/sys/pal/wasm/atomics/thread.rs
@@ -19,7 +19,11 @@ impl Thread {
     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 @@ impl Thread {
         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;
         }