From 766e00c69e00a050a42b811797c2e2114c5fdb71 Mon Sep 17 00:00:00 2001
From: Moses Miller <majora320@gmail.com>
Date: Fri, 11 May 2018 17:22:01 -0700
Subject: [PATCH] Implement conversion of nanoseconds to clocks in terms of
 CLOCKS_PER_SEC

---
 src/time/src/lib.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/time/src/lib.rs b/src/time/src/lib.rs
index e93f4c752..32cc4ef7c 100644
--- a/src/time/src/lib.rs
+++ b/src/time/src/lib.rs
@@ -105,12 +105,12 @@ pub extern "C" fn clock() -> clock_t {
     }
 
     if ts.tv_sec > time_t::max_value() / CLOCKS_PER_SEC
-        || ts.tv_nsec / 1000 > time_t::max_value() - CLOCKS_PER_SEC * ts.tv_sec
+        || ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC) > time_t::max_value() - CLOCKS_PER_SEC * ts.tv_sec
     {
         return -1;
     }
 
-    return ts.tv_sec * CLOCKS_PER_SEC + ts.tv_nsec / 1000;
+    return ts.tv_sec * CLOCKS_PER_SEC + ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC);
 }
 
 #[no_mangle]
-- 
GitLab