Skip to content

Commit

Permalink
fix emscripten now method
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Jun 27, 2021
1 parent eff71cf commit 8a6117c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,18 @@ pub fn now() -> f64 {
#[cfg(not(any(feature = "wasm-bindgen", feature = "stdweb")))]
mod js {
extern "C" {
#[cfg(not(target_os = "emscripten"))]
pub fn now() -> f64;
#[cfg(target_os = "emscripten")]
pub fn _emscripten_get_now() -> f64;
}
}
// Make the unsafe extern function "safe" so it can be called like the other 'now' functions
#[cfg(not(any(feature = "wasm-bindgen", feature = "stdweb")))]
#[cfg(not(target_os = "emscripten"))]
pub fn now() -> f64 {
unsafe { js::now() }
#[cfg(not(target_os = "emscripten"))]
return unsafe { js::now() };
#[cfg(target_os = "emscripten")]
return unsafe { js::_emscripten_get_now() };
}

0 comments on commit 8a6117c

Please sign in to comment.