about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-08-11 17:27:05 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-08-12 14:55:17 -0700
commit8d90d3f36871a00023cc1f313f91e351c287ca15 (patch)
tree2d9b616a2468117aa3afe1f6b1f910ff3116776b /src/libstd/sys
parentd07d465cf60033e35eba16b9e431471d54c712f4 (diff)
downloadrust-8d90d3f36871a00023cc1f313f91e351c287ca15.tar.gz
rust-8d90d3f36871a00023cc1f313f91e351c287ca15.zip
Remove all unstable deprecated functionality
This commit removes all unstable and deprecated functions in the standard
library. A release was recently cut (1.3) which makes this a good time for some
spring cleaning of the deprecated functions.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/common/net.rs95
-rw-r--r--src/libstd/sys/common/remutex.rs22
-rw-r--r--src/libstd/sys/unix/fs.rs7
-rw-r--r--src/libstd/sys/unix/mod.rs8
-rw-r--r--src/libstd/sys/windows/fs.rs13
-rw-r--r--src/libstd/sys/windows/mod.rs10
-rw-r--r--src/libstd/sys/windows/net.rs1
-rw-r--r--src/libstd/sys/windows/os.rs9
8 files changed, 11 insertions, 154 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 6dd222b8f6e..68d5f49dffa 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -186,42 +186,6 @@ impl TcpStream {
 
     pub fn into_socket(self) -> Socket { self.inner }
 
-    pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_NODELAY,
-                   nodelay as c_int)
-    }
-
-    pub fn set_keepalive(&self, seconds: Option<u32>) -> io::Result<()> {
-        let ret = setsockopt(&self.inner, libc::SOL_SOCKET, libc::SO_KEEPALIVE,
-                             seconds.is_some() as c_int);
-        match seconds {
-            Some(n) => ret.and_then(|()| self.set_tcp_keepalive(n)),
-            None => ret,
-        }
-    }
-
-    #[cfg(any(target_os = "macos", target_os = "ios"))]
-    fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
-                   seconds as c_int)
-    }
-    #[cfg(any(target_os = "freebsd",
-              target_os = "dragonfly",
-              target_os = "linux"))]
-    fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
-                   seconds as c_int)
-    }
-
-    #[cfg(not(any(target_os = "macos",
-                  target_os = "ios",
-                  target_os = "freebsd",
-                  target_os = "dragonfly",
-                  target_os = "linux")))]
-    fn set_tcp_keepalive(&self, _seconds: u32) -> io::Result<()> {
-        Ok(())
-    }
-
     pub fn set_read_timeout(&self, dur: Option<Duration>) -> io::Result<()> {
         self.inner.set_timeout(dur, libc::SO_RCVTIMEO)
     }
@@ -431,65 +395,6 @@ impl UdpSocket {
         Ok(ret as usize)
     }
 
-    pub fn set_broadcast(&self, on: bool) -> io::Result<()> {
-        setsockopt(&self.inner, libc::SOL_SOCKET, libc::SO_BROADCAST,
-                   on as c_int)
-    }
-
-    pub fn set_multicast_loop(&self, on: bool) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_IP,
-                   libc::IP_MULTICAST_LOOP, on as c_int)
-    }
-
-    pub fn join_multicast(&self, multi: &IpAddr) -> io::Result<()> {
-        match *multi {
-            IpAddr::V4(..) => {
-                self.set_membership(multi, libc::IP_ADD_MEMBERSHIP)
-            }
-            IpAddr::V6(..) => {
-                self.set_membership(multi, libc::IPV6_ADD_MEMBERSHIP)
-            }
-        }
-    }
-    pub fn leave_multicast(&self, multi: &IpAddr) -> io::Result<()> {
-        match *multi {
-            IpAddr::V4(..) => {
-                self.set_membership(multi, libc::IP_DROP_MEMBERSHIP)
-            }
-            IpAddr::V6(..) => {
-                self.set_membership(multi, libc::IPV6_DROP_MEMBERSHIP)
-            }
-        }
-    }
-    fn set_membership(&self, addr: &IpAddr, opt: c_int) -> io::Result<()> {
-        match *addr {
-            IpAddr::V4(ref addr) => {
-                let mreq = libc::ip_mreq {
-                    imr_multiaddr: *addr.as_inner(),
-                    // interface == INADDR_ANY
-                    imr_interface: libc::in_addr { s_addr: 0x0 },
-                };
-                setsockopt(&self.inner, libc::IPPROTO_IP, opt, mreq)
-            }
-            IpAddr::V6(ref addr) => {
-                let mreq = libc::ip6_mreq {
-                    ipv6mr_multiaddr: *addr.as_inner(),
-                    ipv6mr_interface: 0,
-                };
-                setsockopt(&self.inner, libc::IPPROTO_IPV6, opt, mreq)
-            }
-        }
-    }
-
-    pub fn multicast_time_to_live(&self, ttl: i32) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_IP, libc::IP_MULTICAST_TTL,
-                   ttl as c_int)
-    }
-
-    pub fn time_to_live(&self, ttl: i32) -> io::Result<()> {
-        setsockopt(&self.inner, libc::IPPROTO_IP, libc::IP_TTL, ttl as c_int)
-    }
-
     pub fn duplicate(&self) -> io::Result<UdpSocket> {
         self.inner.duplicate().map(|s| UdpSocket { inner: s })
     }
diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs
index 8f416464173..20475c5463b 100644
--- a/src/libstd/sys/common/remutex.rs
+++ b/src/libstd/sys/common/remutex.rs
@@ -180,10 +180,11 @@ mod tests {
 
     #[test]
     fn is_mutex() {
-        let m = ReentrantMutex::new(RefCell::new(0));
+        let m = Arc::new(ReentrantMutex::new(RefCell::new(0)));
+        let m2 = m.clone();
         let lock = m.lock().unwrap();
-        let handle = thread::scoped(|| {
-            let lock = m.lock().unwrap();
+        let child = thread::spawn(move || {
+            let lock = m2.lock().unwrap();
             assert_eq!(*lock.borrow(), 4950);
         });
         for i in 0..100 {
@@ -191,20 +192,19 @@ mod tests {
             *lock.borrow_mut() += i;
         }
         drop(lock);
-        drop(handle);
+        child.join().unwrap();
     }
 
     #[test]
     fn trylock_works() {
-        let m = ReentrantMutex::new(());
+        let m = Arc::new(ReentrantMutex::new(()));
+        let m2 = m.clone();
         let lock = m.try_lock().unwrap();
         let lock2 = m.try_lock().unwrap();
-        {
-            thread::scoped(|| {
-                let lock = m.try_lock();
-                assert!(lock.is_err());
-            });
-        }
+        thread::spawn(move || {
+            let lock = m2.try_lock();
+            assert!(lock.is_err());
+        }).join().unwrap();
         let lock3 = m.try_lock().unwrap();
     }
 
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 922a213f9c2..751b8e48263 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -509,13 +509,6 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
     Ok(FileAttr { stat: stat })
 }
 
-pub fn utimes(p: &Path, atime: u64, mtime: u64) -> io::Result<()> {
-    let p = try!(cstr(p));
-    let buf = [super::ms_to_timeval(atime), super::ms_to_timeval(mtime)];
-    try!(cvt(unsafe { c::utimes(p.as_ptr(), buf.as_ptr()) }));
-    Ok(())
-}
-
 pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
     let path = try!(CString::new(p.as_os_str().as_bytes()));
     let mut buf = vec![0u8; 16 * 1024];
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs
index 2efca0257f3..bbed42cc31d 100644
--- a/src/libstd/sys/unix/mod.rs
+++ b/src/libstd/sys/unix/mod.rs
@@ -82,7 +82,6 @@ pub fn cvt<T: One + PartialEq + Neg<Output=T>>(t: T) -> io::Result<T> {
     }
 }
 
-#[allow(deprecated)]
 pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
     where T: One + PartialEq + Neg<Output=T>, F: FnMut() -> T
 {
@@ -93,10 +92,3 @@ pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
         }
     }
 }
-
-pub fn ms_to_timeval(ms: u64) -> libc::timeval {
-    libc::timeval {
-        tv_sec: (ms / 1000) as libc::time_t,
-        tv_usec: ((ms % 1000) * 1000) as libc::suseconds_t,
-    }
-}
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index b8c3f1e7b35..d413d536cc8 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -571,19 +571,6 @@ pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
     }
 }
 
-pub fn utimes(p: &Path, atime: u64, mtime: u64) -> io::Result<()> {
-    let atime = super::ms_to_filetime(atime);
-    let mtime = super::ms_to_filetime(mtime);
-
-    let mut o = OpenOptions::new();
-    o.write(true);
-    let f = try!(File::open(p, &o));
-    try!(cvt(unsafe {
-        c::SetFileTime(f.handle.raw(), 0 as *const _, &atime, &mtime)
-    }));
-    Ok(())
-}
-
 fn get_path(f: &File) -> io::Result<PathBuf> {
     super::fill_utf16_buf(|buf, sz| unsafe {
         c::GetFinalPathNameByHandleW(f.handle.raw(), buf, sz,
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index b38945d8916..732e2e65864 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -174,13 +174,3 @@ fn dur2timeout(dur: Duration) -> libc::DWORD {
         }
     }).unwrap_or(libc::INFINITE)
 }
-
-fn ms_to_filetime(ms: u64) -> libc::FILETIME {
-    // A FILETIME is a count of 100 nanosecond intervals, so we multiply by
-    // 10000 b/c there are 10000 intervals in 1 ms
-    let ms = ms * 10000;
-    libc::FILETIME {
-        dwLowDateTime: ms as u32,
-        dwHighDateTime: (ms >> 32) as u32,
-    }
-}
diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs
index 02c5bc1f0ab..57e84b0c46c 100644
--- a/src/libstd/sys/windows/net.rs
+++ b/src/libstd/sys/windows/net.rs
@@ -67,7 +67,6 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
 }
 
 /// Provides the functionality of `cvt` for a closure.
-#[allow(deprecated)]
 pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
     where F: FnMut() -> T, T: One + Neg<Output=T> + PartialEq
 {
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 694d873d0d2..3e640ceaddd 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -21,7 +21,6 @@ use fmt;
 use io;
 use libc::types::os::arch::extra::LPWCH;
 use libc::{self, c_int, c_void};
-use mem;
 use ops::Range;
 use os::windows::ffi::EncodeWide;
 use path::{self, PathBuf};
@@ -334,14 +333,6 @@ pub fn args() -> Args {
     }
 }
 
-pub fn page_size() -> usize {
-    unsafe {
-        let mut info = mem::zeroed();
-        libc::GetSystemInfo(&mut info);
-        return info.dwPageSize as usize;
-    }
-}
-
 pub fn temp_dir() -> PathBuf {
     super::fill_utf16_buf(|buf, sz| unsafe {
         c::GetTempPathW(sz, buf)