From 0c24c8c1483e17b4c7974c68dbb29d609d9c699b Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Sun, 21 Apr 2019 20:10:40 -0600
Subject: [PATCH] Remove special casing for Redox, as it is now supported by
 Unix target family

---
 Cargo.toml |   3 --
 src/lib.rs |   1 -
 src/sys.rs | 138 -----------------------------------------------------
 3 files changed, 142 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index aebf714..a0fb9dd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,9 +15,6 @@ Utilities for working with time-related functions in Rust.
 libc = "0.2.1"
 rustc-serialize = { version = "0.3", optional = true }
 
-[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = "0.1"
-
 [target.'cfg(windows)'.dependencies]
 winapi = { version = "0.3.0", features = ["std", "minwinbase", "minwindef", "ntdef", "profileapi", "sysinfoapi", "timezoneapi"] }
 
diff --git a/src/lib.rs b/src/lib.rs
index 791af59..07c38e4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -38,7 +38,6 @@
 #![allow(trivial_numeric_casts)]
 #![cfg_attr(test, deny(warnings))]
 
-#[cfg(target_os = "redox")] extern crate syscall;
 #[cfg(unix)] extern crate libc;
 #[cfg(windows)] extern crate winapi;
 #[cfg(feature = "rustc-serialize")] extern crate rustc_serialize;
diff --git a/src/sys.rs b/src/sys.rs
index 5ab79b0..4bc5db7 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -4,7 +4,6 @@ pub use self::inner::*;
 
 #[cfg(any(
     all(target_arch = "wasm32", not(target_os = "emscripten")),
-    target_os = "redox",
     target_env = "sgx"
 ))]
 mod common {
@@ -134,143 +133,6 @@ mod inner {
     }
 }
 
-#[cfg(target_os = "redox")]
-mod inner {
-    use std::fmt;
-    use std::cmp::Ordering;
-    use std::ops::{Add, Sub};
-    use syscall;
-    use super::common::{time_to_tm, tm_to_time};
-
-    use Duration;
-    use Tm;
-
-    pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) {
-        time_to_tm(sec, tm);
-    }
-
-    pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
-        // FIXME: Add timezone logic
-        time_to_tm(sec, tm);
-    }
-
-    pub fn utc_tm_to_time(tm: &Tm) -> i64 {
-        tm_to_time(tm)
-    }
-
-    pub fn local_tm_to_time(tm: &Tm) -> i64 {
-        // FIXME: Add timezone logic
-        tm_to_time(tm)
-    }
-
-    pub fn get_time() -> (i64, i32) {
-        let mut tv = syscall::TimeSpec { tv_sec: 0, tv_nsec: 0 };
-        syscall::clock_gettime(syscall::CLOCK_REALTIME, &mut tv).unwrap();
-        (tv.tv_sec as i64, tv.tv_nsec as i32)
-    }
-
-    pub fn get_precise_ns() -> u64 {
-        let mut ts = syscall::TimeSpec { tv_sec: 0, tv_nsec: 0 };
-        syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut ts).unwrap();
-        (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64)
-    }
-
-    #[derive(Copy)]
-    pub struct SteadyTime {
-        t: syscall::TimeSpec,
-    }
-
-    impl fmt::Debug for SteadyTime {
-        fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-            write!(fmt, "SteadyTime {{ tv_sec: {:?}, tv_nsec: {:?} }}",
-                   self.t.tv_sec, self.t.tv_nsec)
-        }
-    }
-
-    impl Clone for SteadyTime {
-        fn clone(&self) -> SteadyTime {
-            SteadyTime { t: self.t }
-        }
-    }
-
-    impl SteadyTime {
-        pub fn now() -> SteadyTime {
-            let mut t = SteadyTime {
-                t: syscall::TimeSpec {
-                    tv_sec: 0,
-                    tv_nsec: 0,
-                }
-            };
-            syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut t.t).unwrap();
-            t
-        }
-    }
-
-    impl Sub for SteadyTime {
-        type Output = Duration;
-        fn sub(self, other: SteadyTime) -> Duration {
-            if self.t.tv_nsec >= other.t.tv_nsec {
-                Duration::seconds(self.t.tv_sec as i64 - other.t.tv_sec as i64) +
-                    Duration::nanoseconds(self.t.tv_nsec as i64 - other.t.tv_nsec as i64)
-            } else {
-                Duration::seconds(self.t.tv_sec as i64 - 1 - other.t.tv_sec as i64) +
-                    Duration::nanoseconds(self.t.tv_nsec as i64 + ::NSEC_PER_SEC as i64 -
-                                          other.t.tv_nsec as i64)
-            }
-        }
-    }
-
-    impl Sub<Duration> for SteadyTime {
-        type Output = SteadyTime;
-        fn sub(self, other: Duration) -> SteadyTime {
-            self + -other
-        }
-    }
-
-    impl Add<Duration> for SteadyTime {
-        type Output = SteadyTime;
-        fn add(mut self, other: Duration) -> SteadyTime {
-            let seconds = other.num_seconds();
-            let nanoseconds = other - Duration::seconds(seconds);
-            let nanoseconds = nanoseconds.num_nanoseconds().unwrap();
-            self.t.tv_sec += seconds;
-            self.t.tv_nsec += nanoseconds as i32;
-            if self.t.tv_nsec >= ::NSEC_PER_SEC {
-                self.t.tv_nsec -= ::NSEC_PER_SEC;
-                self.t.tv_sec += 1;
-            } else if self.t.tv_nsec < 0 {
-                self.t.tv_sec -= 1;
-                self.t.tv_nsec += ::NSEC_PER_SEC;
-            }
-            self
-        }
-    }
-
-    impl PartialOrd for SteadyTime {
-        fn partial_cmp(&self, other: &SteadyTime) -> Option<Ordering> {
-            Some(self.cmp(other))
-        }
-    }
-
-    impl Ord for SteadyTime {
-        fn cmp(&self, other: &SteadyTime) -> Ordering {
-            match self.t.tv_sec.cmp(&other.t.tv_sec) {
-                Ordering::Equal => self.t.tv_nsec.cmp(&other.t.tv_nsec),
-                ord => ord
-            }
-        }
-    }
-
-    impl PartialEq for SteadyTime {
-        fn eq(&self, other: &SteadyTime) -> bool {
-            self.t.tv_sec == other.t.tv_sec &&
-                self.t.tv_nsec == other.t.tv_nsec
-        }
-    }
-
-    impl Eq for SteadyTime {}
-}
-
 #[cfg(target_env = "sgx")]
 mod inner {
     use std::ops::{Add, Sub};
-- 
GitLab