about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/sgx/abi/usercalls/mod.rs6
-rw-r--r--src/libstd/sys/sgx/time.rs6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs
index 3614e1293c1..2bc32c9fefb 100644
--- a/src/libstd/sys/sgx/abi/usercalls/mod.rs
+++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs
@@ -11,6 +11,7 @@
 pub use fortanix_sgx_abi::*;
 
 use io::{Error as IoError, Result as IoResult};
+use time::Duration;
 
 pub mod alloc;
 #[macro_use]
@@ -126,6 +127,11 @@ pub fn send(event_set: u64, tcs: Option<Tcs>) -> IoResult<()> {
     unsafe { raw::send(event_set, tcs).from_sgx_result() }
 }
 
+pub fn insecure_time() -> Duration {
+    let t = unsafe { raw::insecure_time() };
+    Duration::new(t / 1_000_000_000, (t % 1_000_000_000) as _)
+}
+
 pub fn alloc(size: usize, alignment: usize) -> IoResult<*mut u8> {
     unsafe { raw::alloc(size, alignment).from_sgx_result() }
 }
diff --git a/src/libstd/sys/sgx/time.rs b/src/libstd/sys/sgx/time.rs
index 894680b0b65..b01c992768e 100644
--- a/src/libstd/sys/sgx/time.rs
+++ b/src/libstd/sys/sgx/time.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use time::Duration;
-use sys::unsupported_err;
+use super::abi::usercalls;
 
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
 pub struct Instant(Duration);
@@ -21,7 +21,7 @@ pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0));
 
 impl Instant {
     pub fn now() -> Instant {
-        panic!("{}", unsupported_err());
+        Instant(usercalls::insecure_time())
     }
 
     pub fn sub_instant(&self, other: &Instant) -> Duration {
@@ -39,7 +39,7 @@ impl Instant {
 
 impl SystemTime {
     pub fn now() -> SystemTime {
-        panic!("{}", unsupported_err());
+        SystemTime(usercalls::insecure_time())
     }
 
     pub fn sub_time(&self, other: &SystemTime)