Skip to content

std: Cleanup the sys module a bit #25136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use fmt;
use ffi::OsString;
use io::{self, Error, ErrorKind, SeekFrom, Seek, Read, Write};
use path::{Path, PathBuf};
use sys::fs2 as fs_imp;
use sys::fs as fs_imp;
use sys_common::{AsInnerMut, FromInner, AsInner};
use vec::Vec;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use prelude::v1::*;

use io::{self, Error, ErrorKind};
use sys_common::net2 as net_imp;
use sys_common::net as net_imp;

pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use io::prelude::*;
use fmt;
use io;
use net::{ToSocketAddrs, SocketAddr, Shutdown};
use sys_common::net2 as net_imp;
use sys_common::net as net_imp;
use sys_common::{AsInner, FromInner};

/// A structure which represents a TCP stream between a local socket and a
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use prelude::v1::*;
use fmt;
use io::{self, Error, ErrorKind};
use net::{ToSocketAddrs, SocketAddr, IpAddr};
use sys_common::net2 as net_imp;
use sys_common::net as net_imp;
use sys_common::{AsInner, FromInner};

/// A User Datagram Protocol socket.
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/os/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/bitrig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/nacl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
2 changes: 1 addition & 1 deletion src/libstd/os/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
pub mod raw;

pub mod fs {
pub use sys::fs2::MetadataExt;
pub use sys::fs::MetadataExt;
}
12 changes: 6 additions & 6 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use fmt;
use io::{self, Error, ErrorKind};
use path;
use sync::mpsc::{channel, Receiver};
use sys::pipe2::{self, AnonPipe};
use sys::process2::Command as CommandImp;
use sys::process2::Process as ProcessImp;
use sys::process2::ExitStatus as ExitStatusImp;
use sys::process2::Stdio as StdioImp2;
use sys::pipe::{self, AnonPipe};
use sys::process::Command as CommandImp;
use sys::process::Process as ProcessImp;
use sys::process::ExitStatus as ExitStatusImp;
use sys::process::Stdio as StdioImp2;
use sys_common::{AsInner, AsInnerMut};
use thread;

Expand Down Expand Up @@ -334,7 +334,7 @@ fn setup_io(io: &StdioImp, readable: bool)
Null => (StdioImp2::None, None),
Inherit => (StdioImp2::Inherit, None),
Piped => {
let (reader, writer) = try!(pipe2::anon_pipe());
let (reader, writer) = try!(pipe::anon_pipe());
if readable {
(StdioImp2::Piped(reader), Some(writer))
} else {
Expand Down
170 changes: 0 additions & 170 deletions src/libstd/sys/common/helper_thread.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/libstd/sys/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use prelude::v1::*;
pub mod backtrace;
pub mod condvar;
pub mod mutex;
pub mod net2;
pub mod net;
pub mod poison;
pub mod remutex;
pub mod rwlock;
Expand Down
File renamed without changes.
18 changes: 11 additions & 7 deletions src/libstd/sys/common/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use sys::mutex as sys;

/// A re-entrant mutual exclusion
///
/// This mutex will block *other* threads waiting for the lock to become available. The thread
/// which has already locked the mutex can lock it multiple times without blocking, preventing a
/// common source of deadlocks.
/// This mutex will block *other* threads waiting for the lock to become
/// available. The thread which has already locked the mutex can lock it
/// multiple times without blocking, preventing a common source of deadlocks.
pub struct ReentrantMutex<T> {
inner: Box<sys::ReentrantMutex>,
poison: poison::Flag,
Expand Down Expand Up @@ -51,10 +51,14 @@ impl<'a, T> !marker::Send for ReentrantMutexGuard<'a, T> {}
impl<T> ReentrantMutex<T> {
/// Creates a new reentrant mutex in an unlocked state.
pub fn new(t: T) -> ReentrantMutex<T> {
ReentrantMutex {
inner: box unsafe { sys::ReentrantMutex::new() },
poison: poison::FLAG_INIT,
data: t,
unsafe {
let mut mutex = ReentrantMutex {
inner: box sys::ReentrantMutex::uninitialized(),
poison: poison::FLAG_INIT,
data: t,
};
mutex.inner.init();
return mutex
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/unix/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl OpenOptionsExt for OpenOptions {
}

#[unstable(feature = "metadata_ext", reason = "recently added API")]
pub struct Metadata(sys::fs2::FileAttr);
pub struct Metadata(sys::fs::FileAttr);

#[unstable(feature = "metadata_ext", reason = "recently added API")]
pub trait MetadataExt {
Expand All @@ -111,7 +111,7 @@ pub trait MetadataExt {

impl MetadataExt for fs::Metadata {
fn as_raw(&self) -> &Metadata {
let inner: &sys::fs2::FileAttr = self.as_inner();
let inner: &sys::fs::FileAttr = self.as_inner();
unsafe { mem::transmute(inner) }
}
}
Expand Down Expand Up @@ -187,7 +187,7 @@ impl DirEntryExt for fs::DirEntry {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
{
sys::fs2::symlink(src.as_ref(), dst.as_ref())
sys::fs::symlink(src.as_ref(), dst.as_ref())
}

#[unstable(feature = "dir_builder", reason = "recently added API")]
Expand Down
Loading