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 authored and sebcrozet committed Jun 27, 2021
1 parent eff71cf commit ebce2bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ 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")))]
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 ebce2bb

Please sign in to comment.