Skip to content
Snippets Groups Projects
Unverified Commit 3d1a66f2 authored by Moses Miller's avatar Moses Miller
Browse files

Add CLOCKS_PER_SEC

parent 9d875800
No related branches found
No related tags found
No related merge requests found
...@@ -47,3 +47,5 @@ pub(crate) const CLOCK_REALTIME: clockid_t = 0; ...@@ -47,3 +47,5 @@ pub(crate) const CLOCK_REALTIME: clockid_t = 0;
pub(crate) const CLOCK_MONOTONIC: clockid_t = 1; pub(crate) const CLOCK_MONOTONIC: clockid_t = 1;
pub(crate) const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; pub(crate) const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
pub(crate) const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; pub(crate) const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
pub(crate) const CLOCKS_PER_SEC: time_t = 1_000_000;
\ No newline at end of file
...@@ -104,13 +104,13 @@ pub extern "C" fn clock() -> clock_t { ...@@ -104,13 +104,13 @@ pub extern "C" fn clock() -> clock_t {
return -1; return -1;
} }
if ts.tv_sec > time_t::max_value() / 1_000_000 if ts.tv_sec > time_t::max_value() / CLOCKS_PER_SEC
|| ts.tv_nsec / 1000 > time_t::max_value() - 1_000_000 * ts.tv_sec || ts.tv_nsec / 1000 > time_t::max_value() - CLOCKS_PER_SEC * ts.tv_sec
{ {
return -1; return -1;
} }
return ts.tv_sec * 1_000_000 + ts.tv_nsec / 1000; return ts.tv_sec * CLOCKS_PER_SEC + ts.tv_nsec / 1000;
} }
#[no_mangle] #[no_mangle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment