about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2016-09-30 22:11:46 +0000
committerBrian Anderson <banderson@mozilla.com>2016-11-01 17:08:24 +0000
commit219c018894b31fec7059ca89bb1ab0606068aeaf (patch)
treeb18b2913d5b8aca124d2306e1790c5ab46a2252d
parent6d54cd4b2cd864fbd6f2f8d036903f88b6ea79b4 (diff)
downloadrust-219c018894b31fec7059ca89bb1ab0606068aeaf.tar.gz
rust-219c018894b31fec7059ca89bb1ab0606068aeaf.zip
std: Move platform-specific code out of libstd/lib.rs
-rw-r--r--src/libstd/lib.rs5
-rw-r--r--src/libstd/sys/mod.rs19
-rw-r--r--src/libstd/sys/windows/mod.rs6
-rw-r--r--src/tools/tidy/src/pal.rs6
4 files changed, 26 insertions, 10 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index e470690b7c6..1d6c2403c2f 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -458,10 +458,7 @@ mod memchr;
 #[macro_use]
 #[path = "sys/common/mod.rs"] mod sys_common;
 
-#[cfg(unix)]
-#[path = "sys/unix/mod.rs"] mod sys;
-#[cfg(windows)]
-#[path = "sys/windows/mod.rs"] mod sys;
+mod sys;
 
 pub mod rt;
 mod panicking;
diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs
new file mode 100644
index 00000000000..f7e1a0a075a
--- /dev/null
+++ b/src/libstd/sys/mod.rs
@@ -0,0 +1,19 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub use self::imp::*;
+
+#[cfg(unix)]
+#[path = "unix/mod.rs"]
+mod imp;
+
+#[cfg(windows)]
+#[path = "windows/mod.rs"]
+mod imp;
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 9cd6e6ca176..0610a0245ea 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -179,7 +179,7 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
     }
 }
 
-trait IsZero {
+pub trait IsZero {
     fn is_zero(&self) -> bool;
 }
 
@@ -193,7 +193,7 @@ macro_rules! impl_is_zero {
 
 impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
 
-fn cvt<I: IsZero>(i: I) -> io::Result<I> {
+pub fn cvt<I: IsZero>(i: I) -> io::Result<I> {
     if i.is_zero() {
         Err(io::Error::last_os_error())
     } else {
@@ -201,7 +201,7 @@ fn cvt<I: IsZero>(i: I) -> io::Result<I> {
     }
 }
 
-fn dur2timeout(dur: Duration) -> c::DWORD {
+pub fn dur2timeout(dur: Duration) -> c::DWORD {
     // Note that a duration is a (u64, u32) (seconds, nanoseconds) pair, and the
     // timeouts in windows APIs are typically u32 milliseconds. To translate, we
     // have two pieces to take care of:
diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs
index 6ce5f7ee7fe..5caa7f8af44 100644
--- a/src/tools/tidy/src/pal.rs
+++ b/src/tools/tidy/src/pal.rs
@@ -57,13 +57,13 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
     "src/libpanic_abort",
     "src/libpanic_unwind",
     "src/libunwind",
-    "src/libstd/sys/unix", // This is where platform-specific code for std should live
-    "src/libstd/sys/windows", // Ditto
+    "src/libstd/sys/unix", // This is where platform-specific code for unix
+    "src/libstd/sys/windows", // Ditto for windows
+    "src/libstd/sys/mod.rs", // This file chooses the platform
     "src/libstd/os", // Platform-specific public interfaces
     "src/rtstartup", // Not sure what to do about this. magic stuff for mingw
 
     // temporary exceptions
-    "src/libstd/lib.rs", // This could probably be done within the sys directory
     "src/libstd/rtdeps.rs", // Until rustbuild replaces make
     "src/libstd/path.rs",
     "src/libstd/num/f32.rs",