diff options
| author | Marc-Antoine Perennou <Marc-Antoine@Perennou.com> | 2017-02-09 10:11:36 +0100 |
|---|---|---|
| committer | Marc-Antoine Perennou <Marc-Antoine@Perennou.com> | 2017-02-09 10:11:36 +0100 |
| commit | ec73ef9dc85b7b1cb986eb7c85fc8093cc668f60 (patch) | |
| tree | 6485eee90adc1849cce9634efd79ea62f1a34789 /src/libstd | |
| parent | 4268872807cf8bc5c8c435794d1c82d21899d67b (diff) | |
| parent | fd2f8a4536cb9b45abd72b8ff977ad48618602b3 (diff) | |
| download | rust-ec73ef9dc85b7b1cb986eb7c85fc8093cc668f60.tar.gz rust-ec73ef9dc85b7b1cb986eb7c85fc8093cc668f60.zip | |
Merge branch 'master' of git://github.com/rust-lang/rust
* 'master' of git://github.com/rust-lang/rust: (70 commits) sanitizer-dylib: only run where std for x86_64-linux is available travis: Fix build order of dist-x86-linux fix the sanitizer-dylib test on non x86_64 linux hosts dist-x86-linux: install newer kernel headers enable sanitizers on build job that tests x86_64 linux enable sanitizers on x86_64-linux releases use helper function in the rebuild logic of the rustc_*san crates build/test the sanitizers only when --enable-sanitizers is used sanitizer support Add missing urls on join_paths Add test for #27433 Add more examples, get everything passing at last. Remove some leftover makefiles. Add more test for rustdoc --test Rename manifest_version to manifest-version reference: clarify #[cfg] section Bump stable release date rustbuild: Clean build/dist on `make clean` Add missing urls for current_dir review nits ...
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/Cargo.toml | 10 | ||||
| -rw-r--r-- | src/libstd/build.rs | 1 | ||||
| -rw-r--r-- | src/libstd/env.rs | 19 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 6 | ||||
| -rw-r--r-- | src/libstd/net/addr.rs | 7 | ||||
| -rw-r--r-- | src/libstd/net/ip.rs | 62 | ||||
| -rw-r--r-- | src/libstd/panicking.rs | 6 | ||||
| -rw-r--r-- | src/libstd/path.rs | 7 | ||||
| -rw-r--r-- | src/libstd/process.rs | 15 | ||||
| -rw-r--r-- | src/libstd/rtdeps.rs | 68 | ||||
| -rw-r--r-- | src/libstd/sys/redox/process.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sys/unix/args.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/unix/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process/process_common.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process/process_fuchsia.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process/process_unix.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sys/unix/rand.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/windows/c.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys_common/gnu/libbacktrace.rs | 3 | ||||
| -rw-r--r-- | src/libstd/sys_common/mod.rs | 4 |
21 files changed, 129 insertions, 131 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 8146e7fb1ed..2ba7517d3d2 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -23,13 +23,23 @@ compiler_builtins = { path = "../libcompiler_builtins" } std_unicode = { path = "../libstd_unicode" } unwind = { path = "../libunwind" } +[target.x86_64-unknown-linux-gnu.dependencies] +rustc_asan = { path = "../librustc_asan", optional = true } +rustc_lsan = { path = "../librustc_lsan", optional = true } +rustc_msan = { path = "../librustc_msan", optional = true } +rustc_tsan = { path = "../librustc_tsan", optional = true } + [build-dependencies] build_helper = { path = "../build_helper" } gcc = "0.3.27" [features] +asan = ["rustc_asan"] backtrace = [] debug-jemalloc = ["alloc_jemalloc/debug"] jemalloc = ["alloc_jemalloc"] force_alloc_system = [] +lsan = ["rustc_lsan"] +msan = ["rustc_msan"] panic-unwind = ["panic_unwind"] +tsan = ["rustc_tsan"] diff --git a/src/libstd/build.rs b/src/libstd/build.rs index a0844821709..0fca374f6e6 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -21,7 +21,6 @@ use std::process::Command; use build_helper::{run, rerun_if_changed_anything_in_dir, up_to_date}; fn main() { - println!("cargo:rustc-cfg=cargobuild"); println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").expect("TARGET was not set"); diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 29f2ac6ab44..1ef2cb4ed15 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -24,16 +24,19 @@ use path::{Path, PathBuf}; use sys; use sys::os as os_imp; -/// Returns the current working directory as a `PathBuf`. +/// Returns the current working directory as a [`PathBuf`]. /// /// # Errors /// -/// Returns an `Err` if the current working directory value is invalid. +/// Returns an [`Err`] if the current working directory value is invalid. /// Possible cases: /// /// * Current directory does not exist. /// * There are insufficient permissions to access the current directory. /// +/// [`PathBuf`]: ../../std/path/struct.PathBuf.html +/// [`Err`]: ../../std/result/enum.Result.html#method.err +/// /// # Examples /// /// ``` @@ -397,15 +400,19 @@ pub struct JoinPathsError { inner: os_imp::JoinPathsError } -/// Joins a collection of `Path`s appropriately for the `PATH` +/// Joins a collection of [`Path`]s appropriately for the `PATH` /// environment variable. /// -/// Returns an `OsString` on success. +/// Returns an [`OsString`] on success. /// -/// Returns an `Err` (containing an error message) if one of the input -/// `Path`s contains an invalid character for constructing the `PATH` +/// Returns an [`Err`][err] (containing an error message) if one of the input +/// [`Path`]s contains an invalid character for constructing the `PATH` /// variable (a double quote on Windows or a colon on Unix). /// +/// [`Path`]: ../../std/path/struct.Path.html +/// [`OsString`]: ../../std/ffi/struct.OsString.html +/// [err]: ../../std/result/enum.Result.html#variant.Err +/// /// # Examples /// /// ``` diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9bcecebf693..3a552c060a9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -261,6 +261,8 @@ #![feature(generic_param_attrs)] #![feature(hashmap_hasher)] #![feature(heap_api)] +#![feature(i128)] +#![feature(i128_type)] #![feature(inclusive_range)] #![feature(int_error_internals)] #![feature(integer_atomics)] @@ -304,7 +306,6 @@ #![feature(unwind_attributes)] #![feature(vec_push_all)] #![feature(zero_one)] -#![feature(i128)] #![cfg_attr(test, feature(update_panic_count))] // Explicitly import the prelude. The compiler uses this same unstable attribute @@ -463,9 +464,6 @@ mod panicking; mod rand; mod memchr; -// This module just defines per-platform native library dependencies -mod rtdeps; - // The runtime entry point and a few unstable public functions used by the // compiler pub mod rt; diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 751878c687c..84c4acb8d92 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -456,6 +456,13 @@ impl From<SocketAddrV6> for SocketAddr { } } +#[stable(feature = "addr_from_into_ip", since = "1.17.0")] +impl<I: Into<IpAddr>> From<(I, u16)> for SocketAddr { + fn from(pieces: (I, u16)) -> SocketAddr { + SocketAddr::new(pieces.0.into(), pieces.1) + } +} + impl<'a> IntoInner<(*const c::sockaddr, c::socklen_t)> for &'a SocketAddr { fn into_inner(self) -> (*const c::sockaddr, c::socklen_t) { match *self { diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 7803cf728f2..5d6e8d319d7 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -656,6 +656,13 @@ impl From<[u8; 4]> for Ipv4Addr { } } +#[stable(feature = "ip_from_slice", since = "1.17.0")] +impl From<[u8; 4]> for IpAddr { + fn from(octets: [u8; 4]) -> IpAddr { + IpAddr::V4(Ipv4Addr::from(octets)) + } +} + impl Ipv6Addr { /// Creates a new IPv6 address from eight 16-bit segments. /// @@ -1149,6 +1156,26 @@ impl FromInner<c::in6_addr> for Ipv6Addr { } } +#[unstable(feature = "i128", issue = "35118")] +impl From<Ipv6Addr> for u128 { + fn from(ip: Ipv6Addr) -> u128 { + let ip = ip.segments(); + ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + + ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + + ((ip[6] as u128) << 16) + (ip[7] as u128) + } +} +#[unstable(feature = "i128", issue = "35118")] +impl From<u128> for Ipv6Addr { + fn from(ip: u128) -> Ipv6Addr { + Ipv6Addr::new( + (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, + (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, + (ip >> 16) as u16, ip as u16, + ) + } +} + #[stable(feature = "ipv6_from_octets", since = "1.9.0")] impl From<[u8; 16]> for Ipv6Addr { fn from(octets: [u8; 16]) -> Ipv6Addr { @@ -1166,6 +1193,21 @@ impl From<[u16; 8]> for Ipv6Addr { } } + +#[stable(feature = "ip_from_slice", since = "1.17.0")] +impl From<[u8; 16]> for IpAddr { + fn from(octets: [u8; 16]) -> IpAddr { + IpAddr::V6(Ipv6Addr::from(octets)) + } +} + +#[stable(feature = "ip_from_slice", since = "1.17.0")] +impl From<[u16; 8]> for IpAddr { + fn from(segments: [u16; 8]) -> IpAddr { + IpAddr::V6(Ipv6Addr::from(segments)) + } +} + // Tests for this module #[cfg(all(test, not(target_os = "emscripten")))] mod tests { @@ -1500,14 +1542,26 @@ mod tests { #[test] fn test_ipv4_to_int() { - let a = Ipv4Addr::new(127, 0, 0, 1); - assert_eq!(u32::from(a), 2130706433); + let a = Ipv4Addr::new(0x11, 0x22, 0x33, 0x44); + assert_eq!(u32::from(a), 0x11223344); } #[test] fn test_int_to_ipv4() { - let a = Ipv4Addr::new(127, 0, 0, 1); - assert_eq!(Ipv4Addr::from(2130706433), a); + let a = Ipv4Addr::new(0x11, 0x22, 0x33, 0x44); + assert_eq!(Ipv4Addr::from(0x11223344), a); + } + + #[test] + fn test_ipv6_to_int() { + let a = Ipv6Addr::new(0x1122, 0x3344, 0x5566, 0x7788, 0x99aa, 0xbbcc, 0xddee, 0xff11); + assert_eq!(u128::from(a), 0x112233445566778899aabbccddeeff11u128); + } + + #[test] + fn test_int_to_ipv6() { + let a = Ipv6Addr::new(0x1122, 0x3344, 0x5566, 0x7788, 0x99aa, 0xbbcc, 0xddee, 0xff11); + assert_eq!(Ipv6Addr::from(0x112233445566778899aabbccddeeff11u128), a); } #[test] diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index e5edea241e1..d76e8816ca4 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -311,12 +311,12 @@ impl<'a> Location<'a> { } fn default_hook(info: &PanicInfo) { - #[cfg(any(not(cargobuild), feature = "backtrace"))] + #[cfg(feature = "backtrace")] use sys_common::backtrace; // If this is a double panic, make sure that we print a backtrace // for this panic. Otherwise only print it if logging is enabled. - #[cfg(any(not(cargobuild), feature = "backtrace"))] + #[cfg(feature = "backtrace")] let log_backtrace = { let panics = update_panic_count(0); @@ -341,7 +341,7 @@ fn default_hook(info: &PanicInfo) { let _ = writeln!(err, "thread '{}' panicked at '{}', {}:{}", name, msg, file, line); - #[cfg(any(not(cargobuild), feature = "backtrace"))] + #[cfg(feature = "backtrace")] { use sync::atomic::{AtomicBool, Ordering}; diff --git a/src/libstd/path.rs b/src/libstd/path.rs index eb0a6cd74d7..07b43cd89ac 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1265,6 +1265,13 @@ impl Borrow<Path> for PathBuf { } } +#[stable(feature = "default_for_pathbuf", since = "1.16.0")] +impl Default for PathBuf { + fn default() -> Self { + PathBuf::new() + } +} + #[stable(feature = "cow_from_path", since = "1.6.0")] impl<'a> From<&'a Path> for Cow<'a, Path> { #[inline] diff --git a/src/libstd/process.rs b/src/libstd/process.rs index c16b97ebda5..4ff35738b50 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -844,9 +844,9 @@ impl Child { /// guaranteed to repeatedly return a successful exit status so long as the /// child has already exited. /// - /// If the child has exited, then `Ok(status)` is returned. If the exit - /// status is not available at this time then an error is returned with the - /// error kind `WouldBlock`. If an error occurs, then that error is returned. + /// If the child has exited, then `Ok(Some(status))` is returned. If the + /// exit status is not available at this time then `Ok(None)` is returned. + /// If an error occurs, then that error is returned. /// /// Note that unlike `wait`, this function will not attempt to drop stdin. /// @@ -857,14 +857,13 @@ impl Child { /// ```no_run /// #![feature(process_try_wait)] /// - /// use std::io; /// use std::process::Command; /// /// let mut child = Command::new("ls").spawn().unwrap(); /// /// match child.try_wait() { - /// Ok(status) => println!("exited with: {}", status), - /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + /// Ok(Some(status)) => println!("exited with: {}", status), + /// Ok(None) => { /// println!("status not ready yet, let's really wait"); /// let res = child.wait(); /// println!("result: {:?}", res); @@ -873,8 +872,8 @@ impl Child { /// } /// ``` #[unstable(feature = "process_try_wait", issue = "38903")] - pub fn try_wait(&mut self) -> io::Result<ExitStatus> { - self.handle.try_wait().map(ExitStatus) + pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { + Ok(self.handle.try_wait()?.map(ExitStatus)) } /// Simultaneously waits for the child to exit and collect all remaining diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs deleted file mode 100644 index 5dc6ee2bc8c..00000000000 --- a/src/libstd/rtdeps.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! This module contains the linkage attributes to all runtime dependencies of -//! the standard library This varies per-platform, but these libraries are -//! necessary for running libstd. - -#![cfg(not(cargobuild))] - -// LLVM implements the `frem` instruction as a call to `fmod`, which lives in -// libm. Hence, we must explicitly link to it. -// -// On Linux, librt and libdl are indirect dependencies via std, -// and binutils 2.22+ won't add them automatically -#[cfg(all(target_os = "linux", not(target_env = "musl")))] -#[link(name = "dl")] -#[link(name = "pthread")] -extern {} - -#[cfg(target_os = "android")] -#[link(name = "dl")] -#[link(name = "log")] -extern {} - -#[cfg(target_os = "freebsd")] -#[link(name = "execinfo")] -#[link(name = "pthread")] -extern {} - -#[cfg(any(target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] -#[link(name = "pthread")] -extern {} - -#[cfg(target_os = "solaris")] -#[link(name = "socket")] -#[link(name = "posix4")] -#[link(name = "pthread")] -extern {} - -// For PNaCl targets, nacl_io is a Pepper wrapper for some IO functions -// missing (ie always error) in Newlib. -#[cfg(all(target_os = "nacl", not(test)))] -#[link(name = "nacl_io", kind = "static")] -#[link(name = "c++", kind = "static")] // for `nacl_io` and EH. -#[link(name = "pthread", kind = "static")] -extern {} - -#[cfg(target_os = "macos")] -#[link(name = "System")] -extern {} - -#[cfg(target_os = "ios")] -#[link(name = "System")] -extern {} - -#[cfg(target_os = "haiku")] -#[link(name = "network")] -extern {} diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 50dcd44b42e..60dc03fcf47 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -502,17 +502,17 @@ impl Process { Ok(ExitStatus(status as i32)) } - pub fn try_wait(&mut self) -> io::Result<ExitStatus> { + pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { if let Some(status) = self.status { - return Ok(status) + return Ok(Some(status)) } let mut status = 0; let pid = cvt(syscall::waitpid(self.pid, &mut status, syscall::WNOHANG))?; if pid == 0 { - Err(io::Error::from_raw_os_error(syscall::EWOULDBLOCK)) + Ok(None) } else { self.status = Some(ExitStatus(status as i32)); - Ok(ExitStatus(status as i32)) + Ok(Some(ExitStatus(status as i32))) } } } diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index 0f447ff4ec4..6e35a472792 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -189,11 +189,6 @@ mod imp { fn objc_msgSend_ul(obj: NsId, sel: Sel, ...) -> NsId; } - #[link(name = "Foundation", kind = "framework")] - #[link(name = "objc")] - #[cfg(not(cargobuild))] - extern {} - type Sel = *const libc::c_void; type NsId = *const libc::c_void; diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index fd7dc17cccd..c57751a01d7 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -33,7 +33,7 @@ pub mod weak; pub mod args; pub mod android; -#[cfg(any(not(cargobuild), feature = "backtrace"))] +#[cfg(feature = "backtrace")] pub mod backtrace; pub mod condvar; pub mod env; diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 3497b266340..a4536520376 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -439,6 +439,10 @@ mod tests { #[test] #[cfg_attr(target_os = "macos", ignore)] #[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl. + // When run under our current QEMU emulation test suite this test fails, + // although the reason isn't very clear as to why. For now this test is + // ignored there. + #[cfg_attr(target_arch = "arm", ignore)] fn test_process_mask() { unsafe { // Test to make sure that a signal mask does not get inherited. @@ -471,7 +475,7 @@ mod tests { // Either EOF or failure (EPIPE) is okay. let mut buf = [0; 5]; if let Ok(ret) = stdout_read.read(&mut buf) { - assert!(ret == 0); + assert_eq!(ret, 0); } t!(cat.wait()); diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 87acb0ed9b9..0bb2e0c1a83 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -165,7 +165,7 @@ impl Process { Ok(ExitStatus::new(proc_info.rec.return_code)) } - pub fn try_wait(&mut self) -> io::Result<ExitStatus> { + pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { use default::Default; use sys::process::magenta::*; @@ -179,7 +179,7 @@ impl Process { match status { 0 => { }, // Success x if x == ERR_TIMED_OUT => { - return Err(io::Error::from(io::ErrorKind::WouldBlock)); + return Ok(None); }, _ => { panic!("Failed to wait on process handle: {}", status); }, } @@ -192,7 +192,7 @@ impl Process { return Err(io::Error::new(io::ErrorKind::InvalidData, "Failed to get exit status of process")); } - Ok(ExitStatus::new(proc_info.rec.return_code)) + Ok(Some(ExitStatus::new(proc_info.rec.return_code))) } } diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 0dc1739c1a1..bbc987209e3 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -249,19 +249,19 @@ impl Process { Ok(ExitStatus::new(status)) } - pub fn try_wait(&mut self) -> io::Result<ExitStatus> { + pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { if let Some(status) = self.status { - return Ok(status) + return Ok(Some(status)) } let mut status = 0 as c_int; let pid = cvt(unsafe { libc::waitpid(self.pid, &mut status, libc::WNOHANG) })?; if pid == 0 { - Err(io::Error::from_raw_os_error(libc::EWOULDBLOCK)) + Ok(None) } else { self.status = Some(ExitStatus::new(status)); - Ok(ExitStatus::new(status)) + Ok(Some(ExitStatus::new(status))) } } } diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs index 9b1cf6ffd0e..77ebad4e344 100644 --- a/src/libstd/sys/unix/rand.rs +++ b/src/libstd/sys/unix/rand.rs @@ -257,10 +257,6 @@ mod imp { #[allow(non_upper_case_globals)] const kSecRandomDefault: *const SecRandom = ptr::null(); - #[link(name = "Security", kind = "framework")] - #[cfg(not(cargobuild))] - extern {} - extern { fn SecRandomCopyBytes(rnd: *const SecRandom, count: size_t, bytes: *mut u8) -> c_int; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 850d6f49612..e5010ca3564 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -833,13 +833,6 @@ pub struct CONSOLE_READCONSOLE_CONTROL { } pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL; -#[link(name = "ws2_32")] -#[link(name = "userenv")] -#[link(name = "shell32")] -#[link(name = "advapi32")] -#[cfg(not(cargobuild))] -extern {} - extern "system" { pub fn WSAStartup(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int; diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index d2ad81023e7..1afb3728c9d 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -340,18 +340,18 @@ impl Process { } } - pub fn try_wait(&mut self) -> io::Result<ExitStatus> { + pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { unsafe { match c::WaitForSingleObject(self.handle.raw(), 0) { c::WAIT_OBJECT_0 => {} c::WAIT_TIMEOUT => { - return Err(io::Error::from_raw_os_error(c::WSAEWOULDBLOCK)) + return Ok(None); } _ => return Err(io::Error::last_os_error()), } let mut status = 0; cvt(c::GetExitCodeProcess(self.handle.raw(), &mut status))?; - Ok(ExitStatus(status)) + Ok(Some(ExitStatus(status))) } } diff --git a/src/libstd/sys_common/gnu/libbacktrace.rs b/src/libstd/sys_common/gnu/libbacktrace.rs index d464a13ad1d..0bdbeddb112 100644 --- a/src/libstd/sys_common/gnu/libbacktrace.rs +++ b/src/libstd/sys_common/gnu/libbacktrace.rs @@ -39,9 +39,6 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, msg: *const libc::c_char, errnum: libc::c_int); enum backtrace_state {} - #[link(name = "backtrace", kind = "static")] - #[cfg(all(not(test), not(cargobuild)))] - extern {} extern { fn backtrace_create_state(filename: *const libc::c_char, diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index 634d6258885..d4d3365dc01 100644 --- a/src/libstd/sys_common/mod.rs +++ b/src/libstd/sys_common/mod.rs @@ -29,7 +29,7 @@ use sync::Once; use sys; pub mod at_exit_imp; -#[cfg(any(not(cargobuild), feature = "backtrace"))] +#[cfg(feature = "backtrace")] pub mod backtrace; pub mod condvar; pub mod io; @@ -50,7 +50,7 @@ pub use sys::net; #[cfg(not(target_os = "redox"))] pub mod net; -#[cfg(any(not(cargobuild), feature = "backtrace"))] +#[cfg(feature = "backtrace")] #[cfg(any(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "emscripten"))), all(windows, target_env = "gnu")))] pub mod gnu; |
