about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-21 15:28:53 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-21 15:28:53 -0700
commita1dd5ac78745a9f266573d539ba34bbd75b50277 (patch)
tree584e29815ca61d4045fa6bfa048d3804c7ce529a /src/libstd/sys
parent98e9765d973d46faa5c80fb37a48040ca9e87b28 (diff)
parenta568a7f9f2eb3fa3f3e049df288ef0ad32cc7881 (diff)
downloadrust-a1dd5ac78745a9f266573d539ba34bbd75b50277.tar.gz
rust-a1dd5ac78745a9f266573d539ba34bbd75b50277.zip
rollup merge of #24636: alexcrichton/remove-deprecated
Conflicts:
	src/libcore/result.rs
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/common/wtf8.rs2
-rw-r--r--src/libstd/sys/unix/condvar.rs7
-rw-r--r--src/libstd/sys/unix/mod.rs24
-rw-r--r--src/libstd/sys/unix/process2.rs16
-rw-r--r--src/libstd/sys/windows/fs2.rs2
-rw-r--r--src/libstd/sys/windows/mod.rs8
-rw-r--r--src/libstd/sys/windows/net.rs15
-rw-r--r--src/libstd/sys/windows/process2.rs4
8 files changed, 29 insertions, 49 deletions
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs
index c44bf08cae7..56a952e6a7e 100644
--- a/src/libstd/sys/common/wtf8.rs
+++ b/src/libstd/sys/common/wtf8.rs
@@ -37,8 +37,6 @@ use fmt;
 use hash::{Hash, Hasher};
 use iter::FromIterator;
 use mem;
-#[allow(deprecated)] // Int
-use num::Int;
 use ops;
 use slice;
 use str;
diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs
index 90dfebc4c45..ed6382e000a 100644
--- a/src/libstd/sys/unix/condvar.rs
+++ b/src/libstd/sys/unix/condvar.rs
@@ -17,7 +17,6 @@ use sys::mutex::{self, Mutex};
 use sys::time;
 use sys::sync as ffi;
 use time::Duration;
-use num::{Int, NumCast};
 
 pub struct Condvar { inner: UnsafeCell<ffi::pthread_cond_t> }
 
@@ -70,8 +69,8 @@ impl Condvar {
         let r = ffi::gettimeofday(&mut sys_now, ptr::null_mut());
         debug_assert_eq!(r, 0);
 
-        let seconds = NumCast::from(dur.num_seconds());
-        let timeout = match seconds.and_then(|s| sys_now.tv_sec.checked_add(s)) {
+        let seconds = dur.num_seconds() as libc::time_t;
+        let timeout = match sys_now.tv_sec.checked_add(seconds) {
             Some(sec) => {
                 libc::timespec {
                     tv_sec: sec,
@@ -81,7 +80,7 @@ impl Condvar {
             }
             None => {
                 libc::timespec {
-                    tv_sec: Int::max_value(),
+                    tv_sec: <libc::time_t>::max_value(),
                     tv_nsec: 1_000_000_000 - 1,
                 }
             }
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs
index a8a6219f398..d99753a6a4c 100644
--- a/src/libstd/sys/unix/mod.rs
+++ b/src/libstd/sys/unix/mod.rs
@@ -15,7 +15,8 @@ use prelude::v1::*;
 
 use io::{self, ErrorKind};
 use libc;
-use num::{Int, SignedInt};
+use num::One;
+use ops::Neg;
 
 pub mod backtrace;
 pub mod c;
@@ -63,23 +64,8 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
     }
 }
 
-#[inline]
-#[allow(deprecated)]
-pub fn retry<T, F> (mut f: F) -> T where
-    T: SignedInt,
-    F: FnMut() -> T,
-{
-    let one: T = Int::one();
-    loop {
-        let n = f();
-        if n == -one && os::errno() == libc::EINTR as i32 { }
-        else { return n }
-    }
-}
-
-#[allow(deprecated)]
-pub fn cvt<T: SignedInt>(t: T) -> io::Result<T> {
-    let one: T = Int::one();
+pub fn cvt<T: One + PartialEq + Neg<Output=T>>(t: T) -> io::Result<T> {
+    let one: T = T::one();
     if t == -one {
         Err(io::Error::last_os_error())
     } else {
@@ -89,7 +75,7 @@ pub fn cvt<T: SignedInt>(t: T) -> io::Result<T> {
 
 #[allow(deprecated)]
 pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
-    where T: SignedInt, F: FnMut() -> T
+    where T: One + PartialEq + Neg<Output=T>, F: FnMut() -> T
 {
     loop {
         match cvt(f()) {
diff --git a/src/libstd/sys/unix/process2.rs b/src/libstd/sys/unix/process2.rs
index caa7b4eb29c..4e7c4d241f5 100644
--- a/src/libstd/sys/unix/process2.rs
+++ b/src/libstd/sys/unix/process2.rs
@@ -19,7 +19,7 @@ use io::{self, Error, ErrorKind};
 use libc::{self, pid_t, c_void, c_int, gid_t, uid_t};
 use ptr;
 use sys::pipe2::AnonPipe;
-use sys::{self, retry, c, cvt};
+use sys::{self, c, cvt, cvt_r};
 use sys::fs2::{File, OpenOptions};
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -273,7 +273,7 @@ impl Process {
                     }
                 }
             };
-            retry(|| libc::dup2(fd.raw(), dst)) != -1
+            cvt_r(|| libc::dup2(fd.raw(), dst)).is_ok()
         };
 
         if !setup(in_fd, libc::STDIN_FILENO) { fail(&mut output) }
@@ -317,19 +317,19 @@ impl Process {
 
     pub fn wait(&self) -> io::Result<ExitStatus> {
         let mut status = 0 as c_int;
-        try!(cvt(retry(|| unsafe { c::waitpid(self.pid, &mut status, 0) })));
+        try!(cvt_r(|| unsafe { c::waitpid(self.pid, &mut status, 0) }));
         Ok(translate_status(status))
     }
 
     pub fn try_wait(&self) -> Option<ExitStatus> {
         let mut status = 0 as c_int;
-        match retry(|| unsafe {
+        match cvt_r(|| unsafe {
             c::waitpid(self.pid, &mut status, c::WNOHANG)
         }) {
-            n if n == self.pid => Some(translate_status(status)),
-            0 => None,
-            n => panic!("unknown waitpid error `{}`: {}", n,
-                       io::Error::last_os_error()),
+            Ok(0) => None,
+            Ok(n) if n == self.pid => Some(translate_status(status)),
+            Ok(n) => panic!("unkown pid: {}", n),
+            Err(e) => panic!("unknown waitpid error: {}", e),
         }
     }
 }
diff --git a/src/libstd/sys/windows/fs2.rs b/src/libstd/sys/windows/fs2.rs
index 07612d125e1..af61eec319c 100644
--- a/src/libstd/sys/windows/fs2.rs
+++ b/src/libstd/sys/windows/fs2.rs
@@ -13,7 +13,7 @@ use io::prelude::*;
 use os::windows::prelude::*;
 
 use default::Default;
-use ffi::{OsString, AsOsStr};
+use ffi::OsString;
 use fmt;
 use io::{self, Error, SeekFrom};
 use libc::{self, HANDLE};
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 1171c6c068b..5ae5f6f201b 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -17,8 +17,7 @@ use prelude::v1::*;
 use ffi::{OsStr, OsString};
 use io::{self, ErrorKind};
 use libc;
-#[allow(deprecated)]
-use num::Int;
+use num::Zero;
 use os::windows::ffi::{OsStrExt, OsStringExt};
 use path::PathBuf;
 
@@ -144,9 +143,8 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
     }
 }
 
-#[allow(deprecated)]
-fn cvt<I: Int>(i: I) -> io::Result<I> {
-    if i == Int::zero() {
+fn cvt<I: PartialEq + Zero>(i: I) -> io::Result<I> {
+    if i == I::zero() {
         Err(io::Error::last_os_error())
     } else {
         Ok(i)
diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs
index cbc3876dbb1..6bbcd968157 100644
--- a/src/libstd/sys/windows/net.rs
+++ b/src/libstd/sys/windows/net.rs
@@ -15,8 +15,8 @@ use libc::consts::os::extra::INVALID_SOCKET;
 use libc::{self, c_int, c_void};
 use mem;
 use net::SocketAddr;
-#[allow(deprecated)]
-use num::{SignedInt, Int};
+use num::One;
+use ops::Neg;
 use rt;
 use sync::{Once, ONCE_INIT};
 use sys::c;
@@ -49,11 +49,8 @@ fn last_error() -> io::Error {
 /// Checks if the signed integer is the Windows constant `SOCKET_ERROR` (-1)
 /// and if so, returns the last error from the Windows socket interface. . This
 /// function must be called before another call to the socket API is made.
-///
-/// FIXME: generics needed?
-#[allow(deprecated)]
-pub fn cvt<T: SignedInt>(t: T) -> io::Result<T> {
-    let one: T = Int::one();
+pub fn cvt<T: One + Neg<Output=T> + PartialEq>(t: T) -> io::Result<T> {
+    let one: T = T::one();
     if t == -one {
         Err(last_error())
     } else {
@@ -70,7 +67,9 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
 
 /// Provides the functionality of `cvt` for a closure.
 #[allow(deprecated)]
-pub fn cvt_r<T: SignedInt, F>(mut f: F) -> io::Result<T> where F: FnMut() -> T {
+pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
+    where F: FnMut() -> T, T: One + Neg<Output=T> + PartialEq
+{
     cvt(f())
 }
 
diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs
index 16c2a9125ea..5ddcf3d1ea2 100644
--- a/src/libstd/sys/windows/process2.rs
+++ b/src/libstd/sys/windows/process2.rs
@@ -140,7 +140,7 @@ impl Process {
         // read the *child's* PATH if one is provided. See #15149 for more details.
         let program = cfg.env.as_ref().and_then(|env| {
             for (key, v) in env {
-                if OsStr::from_str("PATH") != &**key { continue }
+                if OsStr::new("PATH") != &**key { continue }
 
                 // Split the value and test each path to see if the
                 // program exists.
@@ -463,7 +463,7 @@ mod tests {
     fn test_make_command_line() {
         fn test_wrapper(prog: &str, args: &[&str]) -> String {
             String::from_utf16(
-                &make_command_line(OsStr::from_str(prog),
+                &make_command_line(OsStr::new(prog),
                                    &args.iter()
                                         .map(|a| OsString::from(a))
                                         .collect::<Vec<OsString>>())).unwrap()