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+
26use crate :: sync:: atomic:: AtomicU32 ;
37use crate :: time:: Duration ;
48
@@ -10,11 +14,8 @@ use crate::time::Duration;
1014pub fn futex_wait ( futex : & AtomicU32 , expected : u32 , timeout : Option < Duration > ) -> bool {
1115 let timeout = timeout. and_then ( |t| t. as_nanos ( ) . try_into ( ) . ok ( ) ) . unwrap_or ( -1 ) ;
1216 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
1819 }
1920}
2021
@@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
2324/// Returns true if this actually woke up such a thread,
2425/// or false if no thread was waiting on this futex.
2526pub 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 }
2728}
2829
2930/// Wake up all threads that are waiting on futex_wait on this futex.
3031pub fn futex_wake_all ( futex : & AtomicU32 ) {
3132 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 ) ;
3334 }
3435}
0 commit comments