diff options
| author | bors <bors@rust-lang.org> | 2015-02-04 06:40:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-04 06:40:12 +0000 |
| commit | d6c15d9b2daecdbe32eca894bda40c424798f5a0 (patch) | |
| tree | a9e08bd10dc4cb6cb0d489e120001c3445e89b00 /src/libstd/sys | |
| parent | 3b2ed14906fd9f9daa27cc7d1dad263d2f5ff450 (diff) | |
| parent | 70ecd8ed38d5bedbeb281d78c3da44477764236a (diff) | |
| download | rust-d6c15d9b2daecdbe32eca894bda40c424798f5a0.tar.gz rust-d6c15d9b2daecdbe32eca894bda40c424798f5a0.zip | |
Auto merge of #21919 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/c.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/unix/mod.rs | 32 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 30 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/mod.rs | 29 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 2 |
10 files changed, 83 insertions, 21 deletions
diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index ae01586c703..6f6b4c58717 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use sys::{last_error, retry}; use ffi::CString; use num::Int; -use path::BytesContainer; +use old_path::BytesContainer; use collections; pub mod backtrace; diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 89bd9a23406..50a8e6b73e3 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -143,6 +143,7 @@ extern { pub fn sigdelset(set: *mut sigset_t, signum: libc::c_int) -> libc::c_int; pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int; + #[cfg(not(target_os = "ios"))] pub fn getpwuid_r(uid: libc::uid_t, pwd: *mut passwd, buf: *mut libc::c_char, diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index b03b9046966..427cf21ac70 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -18,10 +18,11 @@ use prelude::v1::*; use ffi; -use old_io::{self, IoResult, IoError}; +use io::ErrorKind; use libc; use num::{Int, SignedInt}; use num; +use old_io::{self, IoResult, IoError}; use str; use sys_common::mkerr_libc; @@ -133,6 +134,35 @@ pub fn decode_error_detailed(errno: i32) -> IoError { err } +pub fn decode_error_kind(errno: i32) -> ErrorKind { + match errno as libc::c_int { + libc::ECONNREFUSED => ErrorKind::ConnectionRefused, + libc::ECONNRESET => ErrorKind::ConnectionReset, + libc::EPERM | libc::EACCES => ErrorKind::PermissionDenied, + libc::EPIPE => ErrorKind::BrokenPipe, + libc::ENOTCONN => ErrorKind::NotConnected, + libc::ECONNABORTED => ErrorKind::ConnectionAborted, + libc::EADDRNOTAVAIL => ErrorKind::ConnectionRefused, + libc::EADDRINUSE => ErrorKind::ConnectionRefused, + libc::ENOENT => ErrorKind::FileNotFound, + libc::EISDIR => ErrorKind::InvalidInput, + libc::EINTR => ErrorKind::Interrupted, + libc::EINVAL => ErrorKind::InvalidInput, + libc::ENOTTY => ErrorKind::MismatchedFileTypeForOperation, + libc::ETIMEDOUT => ErrorKind::TimedOut, + libc::ECANCELED => ErrorKind::TimedOut, + libc::consts::os::posix88::EEXIST => ErrorKind::PathAlreadyExists, + + // These two constants can have the same value on some systems, + // but different values on others, so we can't use a match + // clause + x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => + ErrorKind::ResourceUnavailable, + + _ => ErrorKind::Other, + } +} + #[inline] pub fn retry<T, F> (mut f: F) -> T where T: SignedInt, diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index b3f37962945..5004ff713c4 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -307,23 +307,23 @@ pub fn args() -> Args { let mut res = Vec::new(); unsafe { - let processInfoSel = sel_registerName("processInfo\0".as_ptr()); - let argumentsSel = sel_registerName("arguments\0".as_ptr()); - let utf8Sel = sel_registerName("UTF8String\0".as_ptr()); - let countSel = sel_registerName("count\0".as_ptr()); - let objectAtSel = sel_registerName("objectAtIndex:\0".as_ptr()); + let process_info_sel = sel_registerName("processInfo\0".as_ptr()); + let arguments_sel = sel_registerName("arguments\0".as_ptr()); + let utf8_sel = sel_registerName("UTF8String\0".as_ptr()); + let count_sel = sel_registerName("count\0".as_ptr()); + let object_at_sel = sel_registerName("objectAtIndex:\0".as_ptr()); let klass = objc_getClass("NSProcessInfo\0".as_ptr()); - let info = objc_msgSend(klass, processInfoSel); - let args = objc_msgSend(info, argumentsSel); + let info = objc_msgSend(klass, process_info_sel); + let args = objc_msgSend(info, arguments_sel); - let cnt: int = mem::transmute(objc_msgSend(args, countSel)); + let cnt: int = mem::transmute(objc_msgSend(args, count_sel)); for i in range(0, cnt) { - let tmp = objc_msgSend(args, objectAtSel, i); + let tmp = objc_msgSend(args, object_at_sel, i); let utf_c_str: *const libc::c_char = - mem::transmute(objc_msgSend(tmp, utf8Sel)); - let bytes = ffi::c_str_to_bytes(&utf_c_str).to_vec(); - res.push(OsString::from_vec(bytes)) + mem::transmute(objc_msgSend(tmp, utf8_sel)); + let bytes = ffi::c_str_to_bytes(&utf_c_str); + res.push(OsString::from_str(str::from_utf8(bytes).unwrap())) } } @@ -455,9 +455,11 @@ pub fn home_dir() -> Option<Path> { Path::new(os.into_vec()) }); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", + target_os = "ios"))] unsafe fn fallback() -> Option<OsString> { None } - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", + target_os = "ios")))] unsafe fn fallback() -> Option<OsString> { let mut amt = match libc::sysconf(c::_SC_GETPW_R_SIZE_MAX) { n if n < 0 => 512 as usize, diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index 3dd89ad0759..a2c93dea6a4 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -20,7 +20,7 @@ use str; use string::{String, CowString}; use mem; -#[derive(Clone)] +#[derive(Clone, Hash)] pub struct Buf { pub inner: Vec<u8> } diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 7e117b10a34..20f86227e8e 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -20,7 +20,7 @@ use old_io::{self, IoResult, IoError, EndOfFile}; use libc::{self, pid_t, c_void, c_int}; use mem; use os; -use path::BytesContainer; +use old_path::BytesContainer; use ptr; use sync::mpsc::{channel, Sender, Receiver}; use sys::fs::FileDesc; diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index 66712b9e3a1..92e309da34b 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -32,7 +32,7 @@ use libc; use mem; use ops::Drop; use option::Option::{Some}; -use path::Path; +use old_path::Path; use ptr; use result::Result::{Ok, Err}; use slice::SliceExt; diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 8dd467eba9e..f1af70e2cf7 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -15,6 +15,7 @@ use prelude::v1::*; use ffi::OsStr; +use io::ErrorKind; use libc; use mem; use old_io::{self, IoResult, IoError}; @@ -143,6 +144,34 @@ pub fn decode_error_detailed(errno: i32) -> IoError { err } +pub fn decode_error_kind(errno: i32) -> ErrorKind { + match errno as libc::c_int { + libc::ERROR_ACCESS_DENIED => ErrorKind::PermissionDenied, + libc::ERROR_ALREADY_EXISTS => ErrorKind::PathAlreadyExists, + libc::ERROR_BROKEN_PIPE => ErrorKind::BrokenPipe, + libc::ERROR_FILE_NOT_FOUND => ErrorKind::FileNotFound, + libc::ERROR_INVALID_FUNCTION => ErrorKind::InvalidInput, + libc::ERROR_INVALID_HANDLE => ErrorKind::MismatchedFileTypeForOperation, + libc::ERROR_INVALID_NAME => ErrorKind::InvalidInput, + libc::ERROR_NOTHING_TO_TERMINATE => ErrorKind::InvalidInput, + libc::ERROR_NO_DATA => ErrorKind::BrokenPipe, + libc::ERROR_OPERATION_ABORTED => ErrorKind::TimedOut, + + libc::WSAEACCES => ErrorKind::PermissionDenied, + libc::WSAEADDRINUSE => ErrorKind::ConnectionRefused, + libc::WSAEADDRNOTAVAIL => ErrorKind::ConnectionRefused, + libc::WSAECONNABORTED => ErrorKind::ConnectionAborted, + libc::WSAECONNREFUSED => ErrorKind::ConnectionRefused, + libc::WSAECONNRESET => ErrorKind::ConnectionReset, + libc::WSAEINVAL => ErrorKind::InvalidInput, + libc::WSAENOTCONN => ErrorKind::NotConnected, + libc::WSAEWOULDBLOCK => ErrorKind::ResourceUnavailable, + + _ => ErrorKind::Other, + } +} + + #[inline] pub fn retry<I, F>(f: F) -> I where F: FnOnce() -> I { f() } // PR rust-lang/rust/#17020 diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index aab2406cef9..af94b56bf1f 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -18,7 +18,7 @@ use result::Result; use option::Option; use mem; -#[derive(Clone)] +#[derive(Clone, Hash)] pub struct Buf { pub inner: Wtf8Buf } diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 3ca735f7fdf..315c41e779a 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -23,7 +23,7 @@ use old_io::process::{ProcessExit, ExitStatus}; use old_io::{IoResult, IoError}; use old_io; use os; -use path::BytesContainer; +use old_path::BytesContainer; use ptr; use str; use sync::{StaticMutex, MUTEX_INIT}; |
