Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated usage of the time crate #4652

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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