Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 219c018

Browse files
committed
std: Move platform-specific code out of libstd/lib.rs
1 parent 6d54cd4 commit 219c018

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

src/libstd/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,7 @@ mod memchr;
458458
#[macro_use]
459459
#[path = "sys/common/mod.rs"] mod sys_common;
460460

461-
#[cfg(unix)]
462-
#[path = "sys/unix/mod.rs"] mod sys;
463-
#[cfg(windows)]
464-
#[path = "sys/windows/mod.rs"] mod sys;
461+
mod sys;
465462

466463
pub mod rt;
467464
mod panicking;

src/libstd/sys/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub use self::imp::*;
12+
13+
#[cfg(unix)]
14+
#[path = "unix/mod.rs"]
15+
mod imp;
16+
17+
#[cfg(windows)]
18+
#[path = "windows/mod.rs"]
19+
mod imp;

src/libstd/sys/windows/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
179179
}
180180
}
181181

182-
trait IsZero {
182+
pub trait IsZero {
183183
fn is_zero(&self) -> bool;
184184
}
185185

@@ -193,15 +193,15 @@ macro_rules! impl_is_zero {
193193

194194
impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
195195

196-
fn cvt<I: IsZero>(i: I) -> io::Result<I> {
196+
pub fn cvt<I: IsZero>(i: I) -> io::Result<I> {
197197
if i.is_zero() {
198198
Err(io::Error::last_os_error())
199199
} else {
200200
Ok(i)
201201
}
202202
}
203203

204-
fn dur2timeout(dur: Duration) -> c::DWORD {
204+
pub fn dur2timeout(dur: Duration) -> c::DWORD {
205205
// Note that a duration is a (u64, u32) (seconds, nanoseconds) pair, and the
206206
// timeouts in windows APIs are typically u32 milliseconds. To translate, we
207207
// have two pieces to take care of:

src/tools/tidy/src/pal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
5757
"src/libpanic_abort",
5858
"src/libpanic_unwind",
5959
"src/libunwind",
60-
"src/libstd/sys/unix", // This is where platform-specific code for std should live
61-
"src/libstd/sys/windows", // Ditto
60+
"src/libstd/sys/unix", // This is where platform-specific code for unix
61+
"src/libstd/sys/windows", // Ditto for windows
62+
"src/libstd/sys/mod.rs", // This file chooses the platform
6263
"src/libstd/os", // Platform-specific public interfaces
6364
"src/rtstartup", // Not sure what to do about this. magic stuff for mingw
6465

6566
// temporary exceptions
66-
"src/libstd/lib.rs", // This could probably be done within the sys directory
6767
"src/libstd/rtdeps.rs", // Until rustbuild replaces make
6868
"src/libstd/path.rs",
6969
"src/libstd/num/f32.rs",

0 commit comments

Comments
 (0)