Skip to content

Commit

Permalink
Fix deprecated usage of the time crate (#4652)
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej authored May 9, 2024
2 parents 6de6b0f + af0e6f9 commit ba763c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/emscripten/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::utils::{copy_cstr_into_wasm, write_to_buf};
use crate::{allocate_on_stack, lazy_static, EmEnv};
use libc::{c_char, c_int};
use time::ext::InstantExt;
// use libc::{c_char, c_int, clock_getres, clock_settime};
use std::mem;
use std::time::SystemTime;
Expand Down Expand Up @@ -100,10 +101,10 @@ pub fn _clock_gettime(ctx: FunctionEnvMut<EmEnv>, clk_id: clockid_t, tp: c_int)

CLOCK_MONOTONIC | CLOCK_MONOTONIC_COARSE => {
lazy_static! {
static ref PRECISE0: time::Instant = time::Instant::now();
static ref PRECISE0: std::time::Instant = std::time::Instant::now();
};
let precise_ns = *PRECISE0;
(time::Instant::now() - precise_ns).whole_nanoseconds()
(std::time::Instant::now().signed_duration_since(precise_ns)).whole_nanoseconds()
}
_ => panic!("Clock with id \"{}\" is not supported.", clk_id),
};
Expand Down

0 comments on commit ba763c0

Please sign in to comment.