-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
use crate::arch::wasm32; | ||
use crate::convert::TryInto; | ||
use crate::sync::atomic::AtomicI32; | ||
use crate::sync::atomic::AtomicU32; | ||
use crate::time::Duration; | ||
|
||
pub fn futex_wait(futex: &AtomicI32, expected: i32, timeout: Option<Duration>) { | ||
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) { | ||
let timeout = timeout.and_then(|t| t.as_nanos().try_into().ok()).unwrap_or(-1); | ||
unsafe { | ||
wasm32::memory_atomic_wait32(futex as *const AtomicI32 as *mut i32, expected, timeout); | ||
wasm32::memory_atomic_wait32( | ||
futex as *const AtomicU32 as *mut i32, | ||
expected as i32, | ||
timeout, | ||
); | ||
} | ||
} | ||
|
||
pub fn futex_wake(futex: &AtomicI32) { | ||
pub fn futex_wake(futex: &AtomicU32) { | ||
unsafe { | ||
wasm32::memory_atomic_notify(futex as *const AtomicI32 as *mut i32, 1); | ||
wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters