about summary refs log tree commit diff
path: root/src/libstd/sys/common
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-04-15 01:05:03 +0000
committerbors <bors@rust-lang.org>2015-04-15 01:05:03 +0000
commit16e1fcead14628701e1b10b9d00c898d748db2ed (patch)
tree37d18d85fa9631880c287c3795d5b4b3d8994f20 /src/libstd/sys/common
parent8415fa27877a4309a79b08c75a52eb4c3546b7a5 (diff)
parente053571df21fda7bb909c1b79de9b0cbe1a2931d (diff)
downloadrust-16e1fcead14628701e1b10b9d00c898d748db2ed.tar.gz
rust-16e1fcead14628701e1b10b9d00c898d748db2ed.zip
Auto merge of #24433 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/libstd/sys/common')
-rw-r--r--src/libstd/sys/common/condvar.rs10
-rw-r--r--src/libstd/sys/common/mod.rs91
-rw-r--r--src/libstd/sys/common/mutex.rs8
-rw-r--r--src/libstd/sys/common/poison.rs2
-rw-r--r--src/libstd/sys/common/rwlock.rs14
-rw-r--r--src/libstd/sys/common/thread_local.rs2
-rw-r--r--src/libstd/sys/common/wtf8.rs54
7 files changed, 45 insertions, 136 deletions
diff --git a/src/libstd/sys/common/condvar.rs b/src/libstd/sys/common/condvar.rs
index 32fa6ec5903..9f46b0c3824 100644
--- a/src/libstd/sys/common/condvar.rs
+++ b/src/libstd/sys/common/condvar.rs
@@ -31,15 +31,15 @@ impl Condvar {
     #[inline]
     pub unsafe fn new() -> Condvar { Condvar(imp::Condvar::new()) }
 
-    /// Signal one waiter on this condition variable to wake up.
+    /// Signals one waiter on this condition variable to wake up.
     #[inline]
     pub unsafe fn notify_one(&self) { self.0.notify_one() }
 
-    /// Awaken all current waiters on this condition variable.
+    /// Awakens all current waiters on this condition variable.
     #[inline]
     pub unsafe fn notify_all(&self) { self.0.notify_all() }
 
-    /// Wait for a signal on the specified mutex.
+    /// Waits for a signal on the specified mutex.
     ///
     /// Behavior is undefined if the mutex is not locked by the current thread.
     /// Behavior is also undefined if more than one mutex is used concurrently
@@ -47,7 +47,7 @@ impl Condvar {
     #[inline]
     pub unsafe fn wait(&self, mutex: &Mutex) { self.0.wait(mutex::raw(mutex)) }
 
-    /// Wait for a signal on the specified mutex with a timeout duration
+    /// Waits for a signal on the specified mutex with a timeout duration
     /// specified by `dur` (a relative time into the future).
     ///
     /// Behavior is undefined if the mutex is not locked by the current thread.
@@ -58,7 +58,7 @@ impl Condvar {
         self.0.wait_timeout(mutex::raw(mutex), dur)
     }
 
-    /// Deallocate all resources associated with this condition variable.
+    /// Deallocates all resources associated with this condition variable.
     ///
     /// Behavior is undefined if there are current or will be future users of
     /// this condition variable.
diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs
index 8a01eace889..95294b813ea 100644
--- a/src/libstd/sys/common/mod.rs
+++ b/src/libstd/sys/common/mod.rs
@@ -10,24 +10,11 @@
 
 #![allow(missing_docs)]
 
-use old_io::{self, IoError, IoResult};
 use prelude::v1::*;
-use sys::{last_error, retry};
-use ffi::CString;
-#[allow(deprecated)] // Int
-use num::Int;
-
-#[allow(deprecated)]
-use old_path::BytesContainer;
-
-use collections;
-
-#[macro_use] pub mod helper_thread;
 
 pub mod backtrace;
 pub mod condvar;
 pub mod mutex;
-pub mod net;
 pub mod net2;
 pub mod poison;
 pub mod remutex;
@@ -40,72 +27,6 @@ pub mod wtf8;
 
 // common error constructors
 
-#[allow(deprecated)]
-pub fn eof() -> IoError {
-    IoError {
-        kind: old_io::EndOfFile,
-        desc: "end of file",
-        detail: None,
-    }
-}
-
-#[allow(deprecated)]
-pub fn timeout(desc: &'static str) -> IoError {
-    IoError {
-        kind: old_io::TimedOut,
-        desc: desc,
-        detail: None,
-    }
-}
-
-#[allow(deprecated)]
-pub fn short_write(n: usize, desc: &'static str) -> IoError {
-    IoError {
-        kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) },
-        desc: desc,
-        detail: None,
-    }
-}
-
-#[allow(deprecated)]
-pub fn unimpl() -> IoError {
-    IoError {
-        kind: old_io::IoUnavailable,
-        desc: "operations not yet supported",
-        detail: None,
-    }
-}
-
-// unix has nonzero values as errors
-#[allow(deprecated)]
-pub fn mkerr_libc<T: Int>(ret: T) -> IoResult<()> {
-    if ret != Int::zero() {
-        Err(last_error())
-    } else {
-        Ok(())
-    }
-}
-
-pub fn keep_going<F>(data: &[u8], mut f: F) -> i64 where
-    F: FnMut(*const u8, usize) -> i64,
-{
-    let origamt = data.len();
-    let mut data = data.as_ptr();
-    let mut amt = origamt;
-    while amt > 0 {
-        let ret = retry(|| f(data, amt));
-        if ret == 0 {
-            break
-        } else if ret != -1 {
-            amt -= ret as usize;
-            data = unsafe { data.offset(ret as isize) };
-        } else {
-            return ret;
-        }
-    }
-    return (origamt - amt) as i64;
-}
-
 /// A trait for viewing representations from std types
 #[doc(hidden)]
 pub trait AsInner<Inner: ?Sized> {
@@ -129,15 +50,3 @@ pub trait IntoInner<Inner> {
 pub trait FromInner<Inner> {
     fn from_inner(inner: Inner) -> Self;
 }
-
-#[doc(hidden)]
-#[allow(deprecated)]
-pub trait ProcessConfig<K: BytesContainer, V: BytesContainer> {
-    fn program(&self) -> &CString;
-    fn args(&self) -> &[CString];
-    fn env(&self) -> Option<&collections::HashMap<K, V>>;
-    fn cwd(&self) -> Option<&CString>;
-    fn uid(&self) -> Option<usize>;
-    fn gid(&self) -> Option<usize>;
-    fn detach(&self) -> bool;
-}
diff --git a/src/libstd/sys/common/mutex.rs b/src/libstd/sys/common/mutex.rs
index 0ca22826700..1f9dd54192c 100644
--- a/src/libstd/sys/common/mutex.rs
+++ b/src/libstd/sys/common/mutex.rs
@@ -24,14 +24,14 @@ unsafe impl Sync for Mutex {}
 pub const MUTEX_INIT: Mutex = Mutex(imp::MUTEX_INIT);
 
 impl Mutex {
-    /// Lock the mutex blocking the current thread until it is available.
+    /// Locks the mutex blocking the current thread until it is available.
     ///
     /// Behavior is undefined if the mutex has been moved between this and any
     /// previous function call.
     #[inline]
     pub unsafe fn lock(&self) { self.0.lock() }
 
-    /// Attempt to lock the mutex without blocking, returning whether it was
+    /// Attempts to lock the mutex without blocking, returning whether it was
     /// successfully acquired or not.
     ///
     /// Behavior is undefined if the mutex has been moved between this and any
@@ -39,14 +39,14 @@ impl Mutex {
     #[inline]
     pub unsafe fn try_lock(&self) -> bool { self.0.try_lock() }
 
-    /// Unlock the mutex.
+    /// Unlocks the mutex.
     ///
     /// Behavior is undefined if the current thread does not actually hold the
     /// mutex.
     #[inline]
     pub unsafe fn unlock(&self) { self.0.unlock() }
 
-    /// Deallocate all resources associated with this mutex.
+    /// Deallocates all resources associated with this mutex.
     ///
     /// Behavior is undefined if there are current or will be future users of
     /// this mutex.
diff --git a/src/libstd/sys/common/poison.rs b/src/libstd/sys/common/poison.rs
index 347cd0b464e..6deb4a48007 100644
--- a/src/libstd/sys/common/poison.rs
+++ b/src/libstd/sys/common/poison.rs
@@ -116,7 +116,7 @@ impl<T: Send> Error for PoisonError<T> {
 }
 
 impl<T> PoisonError<T> {
-    /// Create a `PoisonError`.
+    /// Creates a `PoisonError`.
     #[unstable(feature = "std_misc")]
     pub fn new(guard: T) -> PoisonError<T> {
         PoisonError { guard: guard }
diff --git a/src/libstd/sys/common/rwlock.rs b/src/libstd/sys/common/rwlock.rs
index f7d7a5715bc..725a09bcc86 100644
--- a/src/libstd/sys/common/rwlock.rs
+++ b/src/libstd/sys/common/rwlock.rs
@@ -21,7 +21,7 @@ pub struct RWLock(imp::RWLock);
 pub const RWLOCK_INIT: RWLock = RWLock(imp::RWLOCK_INIT);
 
 impl RWLock {
-    /// Acquire shared access to the underlying lock, blocking the current
+    /// Acquires shared access to the underlying lock, blocking the current
     /// thread to do so.
     ///
     /// Behavior is undefined if the rwlock has been moved between this and any
@@ -29,7 +29,7 @@ impl RWLock {
     #[inline]
     pub unsafe fn read(&self) { self.0.read() }
 
-    /// Attempt to acquire shared access to this lock, returning whether it
+    /// Attempts to acquire shared access to this lock, returning whether it
     /// succeeded or not.
     ///
     /// This function does not block the current thread.
@@ -39,7 +39,7 @@ impl RWLock {
     #[inline]
     pub unsafe fn try_read(&self) -> bool { self.0.try_read() }
 
-    /// Acquire write access to the underlying lock, blocking the current thread
+    /// Acquires write access to the underlying lock, blocking the current thread
     /// to do so.
     ///
     /// Behavior is undefined if the rwlock has been moved between this and any
@@ -47,7 +47,7 @@ impl RWLock {
     #[inline]
     pub unsafe fn write(&self) { self.0.write() }
 
-    /// Attempt to acquire exclusive access to this lock, returning whether it
+    /// Attempts to acquire exclusive access to this lock, returning whether it
     /// succeeded or not.
     ///
     /// This function does not block the current thread.
@@ -57,20 +57,20 @@ impl RWLock {
     #[inline]
     pub unsafe fn try_write(&self) -> bool { self.0.try_write() }
 
-    /// Unlock previously acquired shared access to this lock.
+    /// Unlocks previously acquired shared access to this lock.
     ///
     /// Behavior is undefined if the current thread does not have shared access.
     #[inline]
     pub unsafe fn read_unlock(&self) { self.0.read_unlock() }
 
-    /// Unlock previously acquired exclusive access to this lock.
+    /// Unlocks previously acquired exclusive access to this lock.
     ///
     /// Behavior is undefined if the current thread does not currently have
     /// exclusive access.
     #[inline]
     pub unsafe fn write_unlock(&self) { self.0.write_unlock() }
 
-    /// Destroy OS-related resources with this RWLock.
+    /// Destroys OS-related resources with this RWLock.
     ///
     /// Behavior is undefined if there are any currently active users of this
     /// lock.
diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs
index 5995d7ac10f..618a389110a 100644
--- a/src/libstd/sys/common/thread_local.rs
+++ b/src/libstd/sys/common/thread_local.rs
@@ -207,7 +207,7 @@ impl StaticKey {
 }
 
 impl Key {
-    /// Create a new managed OS TLS key.
+    /// Creates a new managed OS TLS key.
     ///
     /// This key will be deallocated when the key falls out of scope.
     ///
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs
index 987a12293da..34a4a773f8e 100644
--- a/src/libstd/sys/common/wtf8.rs
+++ b/src/libstd/sys/common/wtf8.rs
@@ -69,7 +69,7 @@ impl fmt::Debug for CodePoint {
 }
 
 impl CodePoint {
-    /// Unsafely create a new `CodePoint` without checking the value.
+    /// Unsafely creates a new `CodePoint` without checking the value.
     ///
     /// Only use when `value` is known to be less than or equal to 0x10FFFF.
     #[inline]
@@ -77,9 +77,9 @@ impl CodePoint {
         CodePoint { value: value }
     }
 
-    /// Create a new `CodePoint` if the value is a valid code point.
+    /// Creates a new `CodePoint` if the value is a valid code point.
     ///
-    /// Return `None` if `value` is above 0x10FFFF.
+    /// Returns `None` if `value` is above 0x10FFFF.
     #[inline]
     pub fn from_u32(value: u32) -> Option<CodePoint> {
         match value {
@@ -88,7 +88,7 @@ impl CodePoint {
         }
     }
 
-    /// Create a new `CodePoint` from a `char`.
+    /// Creates a new `CodePoint` from a `char`.
     ///
     /// Since all Unicode scalar values are code points, this always succeeds.
     #[inline]
@@ -96,15 +96,15 @@ impl CodePoint {
         CodePoint { value: value as u32 }
     }
 
-    /// Return the numeric value of the code point.
+    /// Returns the numeric value of the code point.
     #[inline]
     pub fn to_u32(&self) -> u32 {
         self.value
     }
 
-    /// Optionally return a Unicode scalar value for the code point.
+    /// Optionally returns a Unicode scalar value for the code point.
     ///
-    /// Return `None` if the code point is a surrogate (from U+D800 to U+DFFF).
+    /// Returns `None` if the code point is a surrogate (from U+D800 to U+DFFF).
     #[inline]
     pub fn to_char(&self) -> Option<char> {
         match self.value {
@@ -113,9 +113,9 @@ impl CodePoint {
         }
     }
 
-    /// Return a Unicode scalar value for the code point.
+    /// Returns a Unicode scalar value for the code point.
     ///
-    /// Return `'\u{FFFD}'` (the replacement character “�”)
+    /// Returns `'\u{FFFD}'` (the replacement character “�”)
     /// if the code point is a surrogate (from U+D800 to U+DFFF).
     #[inline]
     pub fn to_char_lossy(&self) -> char {
@@ -151,19 +151,19 @@ impl fmt::Debug for Wtf8Buf {
 }
 
 impl Wtf8Buf {
-    /// Create an new, empty WTF-8 string.
+    /// Creates an new, empty WTF-8 string.
     #[inline]
     pub fn new() -> Wtf8Buf {
         Wtf8Buf { bytes: Vec::new() }
     }
 
-    /// Create an new, empty WTF-8 string with pre-allocated capacity for `n` bytes.
+    /// Creates an new, empty WTF-8 string with pre-allocated capacity for `n` bytes.
     #[inline]
     pub fn with_capacity(n: usize) -> Wtf8Buf {
         Wtf8Buf { bytes: Vec::with_capacity(n) }
     }
 
-    /// Create a WTF-8 string from an UTF-8 `String`.
+    /// Creates a WTF-8 string from an UTF-8 `String`.
     ///
     /// This takes ownership of the `String` and does not copy.
     ///
@@ -173,7 +173,7 @@ impl Wtf8Buf {
         Wtf8Buf { bytes: string.into_bytes() }
     }
 
-    /// Create a WTF-8 string from an UTF-8 `&str` slice.
+    /// Creates a WTF-8 string from an UTF-8 `&str` slice.
     ///
     /// This copies the content of the slice.
     ///
@@ -183,7 +183,7 @@ impl Wtf8Buf {
         Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()) }
     }
 
-    /// Create a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
+    /// Creates a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
     ///
     /// This is lossless: calling `.encode_wide()` on the resulting string
     /// will always return the original code units.
@@ -319,7 +319,7 @@ impl Wtf8Buf {
         self.bytes.truncate(new_len)
     }
 
-    /// Consume the WTF-8 string and try to convert it to UTF-8.
+    /// Consumes the WTF-8 string and tries to convert it to UTF-8.
     ///
     /// This does not copy the data.
     ///
@@ -333,7 +333,7 @@ impl Wtf8Buf {
         }
     }
 
-    /// Consume the WTF-8 string and convert it lossily to UTF-8.
+    /// Consumes the WTF-8 string and converts it lossily to UTF-8.
     ///
     /// This does not copy the data (but may overwrite parts of it in place).
     ///
@@ -454,7 +454,7 @@ impl fmt::Debug for Wtf8 {
 }
 
 impl Wtf8 {
-    /// Create a WTF-8 slice from a UTF-8 `&str` slice.
+    /// Creates a WTF-8 slice from a UTF-8 `&str` slice.
     ///
     /// Since WTF-8 is a superset of UTF-8, this always succeeds.
     #[inline]
@@ -462,13 +462,13 @@ impl Wtf8 {
         unsafe { mem::transmute(value.as_bytes()) }
     }
 
-    /// Return the length, in WTF-8 bytes.
+    /// Returns the length, in WTF-8 bytes.
     #[inline]
     pub fn len(&self) -> usize {
         self.bytes.len()
     }
 
-    /// Return the code point at `position` if it is in the ASCII range,
+    /// Returns the code point at `position` if it is in the ASCII range,
     /// or `b'\xFF' otherwise.
     ///
     /// # Panics
@@ -482,7 +482,7 @@ impl Wtf8 {
         }
     }
 
-    /// Return the code point at `position`.
+    /// Returns the code point at `position`.
     ///
     /// # Panics
     ///
@@ -494,7 +494,7 @@ impl Wtf8 {
         code_point
     }
 
-    /// Return the code point at `position`
+    /// Returns the code point at `position`
     /// and the position of the next code point.
     ///
     /// # Panics
@@ -507,15 +507,15 @@ impl Wtf8 {
         (CodePoint { value: c }, n)
     }
 
-    /// Return an iterator for the string’s code points.
+    /// Returns an iterator for the string’s code points.
     #[inline]
     pub fn code_points(&self) -> Wtf8CodePoints {
         Wtf8CodePoints { bytes: self.bytes.iter() }
     }
 
-    /// Try to convert the string to UTF-8 and return a `&str` slice.
+    /// Tries to convert the string to UTF-8 and return a `&str` slice.
     ///
-    /// Return `None` if the string contains surrogates.
+    /// Returns `None` if the string contains surrogates.
     ///
     /// This does not copy the data.
     #[inline]
@@ -528,8 +528,8 @@ impl Wtf8 {
         }
     }
 
-    /// Lossily convert the string to UTF-8.
-    /// Return an UTF-8 `&str` slice if the contents are well-formed in UTF-8.
+    /// Lossily converts the string to UTF-8.
+    /// Returns an UTF-8 `&str` slice if the contents are well-formed in UTF-8.
     ///
     /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”).
     ///
@@ -559,7 +559,7 @@ impl Wtf8 {
         }
     }
 
-    /// Convert the WTF-8 string to potentially ill-formed UTF-16
+    /// Converts the WTF-8 string to potentially ill-formed UTF-16
     /// and return an iterator of 16-bit code units.
     ///
     /// This is lossless: