Fix libstd
This commit is contained in:
parent
1e0c7b682f
commit
d5647a8ea3
@ -154,7 +154,7 @@ impl DynamicLibrary {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test, not(target_os = "ios"))]
|
||||
#[cfg(all(test, not(target_os = "ios")))]
|
||||
mod test {
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
@ -189,10 +189,10 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"))]
|
||||
fn test_errors_do_not_crash() {
|
||||
// Open /dev/null as a library to get an error, and make sure
|
||||
// that only causes an error, and not a crash.
|
||||
@ -204,12 +204,12 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"))]
|
||||
pub mod dl {
|
||||
|
||||
use c_str::{CString, ToCStr};
|
||||
|
@ -123,7 +123,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
|
||||
|
||||
// Ignored on android since we cannot give tcp/ip
|
||||
// permission without help of apk
|
||||
#[cfg(test, not(target_os = "android"))]
|
||||
#[cfg(all(test, not(target_os = "android")))]
|
||||
mod test {
|
||||
iotest!(fn dns_smoke_test() {
|
||||
let ipaddrs = get_host_addresses("localhost").unwrap();
|
||||
|
@ -693,7 +693,7 @@ mod tests {
|
||||
drop(p.wait().clone());
|
||||
})
|
||||
|
||||
#[cfg(unix, not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
iotest!(fn signal_reported_right() {
|
||||
let p = Command::new("/bin/sh").arg("-c").arg("kill -1 $$").spawn();
|
||||
assert!(p.is_ok());
|
||||
@ -725,7 +725,7 @@ mod tests {
|
||||
assert_eq!(run_output(cmd), "foobar\n".to_string());
|
||||
})
|
||||
|
||||
#[cfg(unix, not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
iotest!(fn set_cwd_works() {
|
||||
let mut cmd = Command::new("/bin/sh");
|
||||
cmd.arg("-c").arg("pwd")
|
||||
@ -734,7 +734,7 @@ mod tests {
|
||||
assert_eq!(run_output(cmd), "/\n".to_string());
|
||||
})
|
||||
|
||||
#[cfg(unix, not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
iotest!(fn stdin_works() {
|
||||
let mut p = Command::new("/bin/sh")
|
||||
.arg("-c").arg("read line; echo $line")
|
||||
@ -759,7 +759,7 @@ mod tests {
|
||||
assert!(Command::new("test").uid(10).spawn().is_err());
|
||||
})
|
||||
|
||||
#[cfg(unix, not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
iotest!(fn uid_works() {
|
||||
use libc;
|
||||
let mut p = Command::new("/bin/sh")
|
||||
@ -770,7 +770,7 @@ mod tests {
|
||||
assert!(p.wait().unwrap().success());
|
||||
})
|
||||
|
||||
#[cfg(unix, not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
iotest!(fn uid_to_root_fails() {
|
||||
use libc;
|
||||
|
||||
@ -847,7 +847,7 @@ mod tests {
|
||||
}
|
||||
})
|
||||
|
||||
#[cfg(unix,not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
pub fn pwd_cmd() -> Command {
|
||||
Command::new("pwd")
|
||||
}
|
||||
@ -897,7 +897,7 @@ mod tests {
|
||||
assert_eq!(parent_stat.unstable.inode, child_stat.unstable.inode);
|
||||
})
|
||||
|
||||
#[cfg(unix,not(target_os="android"))]
|
||||
#[cfg(all(unix, not(target_os="android")))]
|
||||
pub fn env_cmd() -> Command {
|
||||
Command::new("env")
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl Listener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test, unix)]
|
||||
#[cfg(all(test, unix))]
|
||||
mod test_unix {
|
||||
use prelude::*;
|
||||
use libc;
|
||||
@ -218,7 +218,7 @@ mod test_unix {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test, windows)]
|
||||
#[cfg(all(test, windows))]
|
||||
mod test_windows {
|
||||
use super::{User1, Listener};
|
||||
use result::{Ok, Err};
|
||||
|
@ -653,8 +653,7 @@ pub fn dll_filename(base: &str) -> String {
|
||||
/// ```
|
||||
pub fn self_exe_name() -> Option<Path> {
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
|
||||
fn load_self() -> Option<Vec<u8>> {
|
||||
unsafe {
|
||||
use libc::funcs::bsd44::*;
|
||||
@ -680,8 +679,7 @@ pub fn self_exe_name() -> Option<Path> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn load_self() -> Option<Vec<u8>> {
|
||||
use std::io;
|
||||
|
||||
@ -691,8 +689,7 @@ pub fn self_exe_name() -> Option<Path> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
fn load_self() -> Option<Vec<u8>> {
|
||||
unsafe {
|
||||
use libc::funcs::extra::_NSGetExecutablePath;
|
||||
@ -909,9 +906,9 @@ pub fn change_dir(p: &Path) -> bool {
|
||||
#[cfg(unix)]
|
||||
/// Returns the platform-specific value of errno
|
||||
pub fn errno() -> int {
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(any(target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "freebsd"))]
|
||||
fn errno_location() -> *const c_int {
|
||||
extern {
|
||||
fn __error() -> *const c_int;
|
||||
@ -931,8 +928,7 @@ pub fn errno() -> int {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn errno_location() -> *const c_int {
|
||||
extern {
|
||||
fn __errno_location() -> *const c_int;
|
||||
@ -975,11 +971,11 @@ pub fn error_string(errnum: uint) -> String {
|
||||
|
||||
#[cfg(unix)]
|
||||
fn strerror(errnum: uint) -> String {
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"))]
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t)
|
||||
-> c_int {
|
||||
extern {
|
||||
@ -1180,10 +1176,10 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
|
||||
res
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"))]
|
||||
fn real_args_as_bytes() -> Vec<Vec<u8>> {
|
||||
use rt;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
pub use self::imp::OsRng;
|
||||
|
||||
#[cfg(unix, not(target_os = "ios"))]
|
||||
#[cfg(all(unix, not(target_os = "ios")))]
|
||||
mod imp {
|
||||
use io::{IoResult, File};
|
||||
use path::Path;
|
||||
|
@ -253,7 +253,7 @@ mod imp {
|
||||
/// play well with green threads, so while it is extremely nice
|
||||
/// and simple to use it should be used only on iOS devices as the
|
||||
/// only viable option.
|
||||
#[cfg(target_os = "ios", target_arch = "arm")]
|
||||
#[cfg(all(target_os = "ios", target_arch = "arm"))]
|
||||
#[inline(never)]
|
||||
pub fn write(w: &mut Writer) -> IoResult<()> {
|
||||
use iter::{Iterator, range};
|
||||
@ -284,7 +284,7 @@ mod imp {
|
||||
result::fold(iter, (), |_, _| ())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "ios", target_arch = "arm"))]
|
||||
#[cfg(not(all(target_os = "ios", target_arch = "arm")))]
|
||||
#[inline(never)] // if we know this is a function call, we can skip it when
|
||||
// tracing
|
||||
pub fn write(w: &mut Writer) -> IoResult<()> {
|
||||
@ -365,8 +365,7 @@ mod imp {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
|
||||
use intrinsics;
|
||||
#[repr(C)]
|
||||
@ -391,7 +390,7 @@ mod imp {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"), not(target_os = "ios"))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
|
||||
use collections::Collection;
|
||||
use iter::Iterator;
|
||||
@ -571,16 +570,17 @@ mod imp {
|
||||
|
||||
extern {
|
||||
// No native _Unwind_Backtrace on iOS
|
||||
#[cfg(not(target_os = "ios", target_arch = "arm"))]
|
||||
#[cfg(not(all(target_os = "ios", target_arch = "arm")))]
|
||||
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
|
||||
trace_argument: *mut libc::c_void)
|
||||
-> _Unwind_Reason_Code;
|
||||
|
||||
#[cfg(not(target_os = "android"),
|
||||
not(target_os = "linux", target_arch = "arm"))]
|
||||
#[cfg(all(not(target_os = "android"),
|
||||
not(all(target_os = "linux", target_arch = "arm"))))]
|
||||
pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t;
|
||||
#[cfg(not(target_os = "android"),
|
||||
not(target_os = "linux", target_arch = "arm"))]
|
||||
|
||||
#[cfg(all(not(target_os = "android"),
|
||||
not(all(target_os = "linux", target_arch = "arm"))))]
|
||||
pub fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void)
|
||||
-> *mut libc::c_void;
|
||||
}
|
||||
@ -588,8 +588,8 @@ mod imp {
|
||||
// On android, the function _Unwind_GetIP is a macro, and this is the
|
||||
// expansion of the macro. This is all copy/pasted directly from the
|
||||
// header file with the definition of _Unwind_GetIP.
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "linux", target_arch = "arm")]
|
||||
#[cfg(any(target_os = "android",
|
||||
all(target_os = "linux", target_arch = "arm")))]
|
||||
pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t {
|
||||
#[repr(C)]
|
||||
enum _Unwind_VRS_Result {
|
||||
@ -634,8 +634,8 @@ mod imp {
|
||||
|
||||
// This function also doesn't exist on Android or ARM/Linux, so make it
|
||||
// a no-op
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "linux", target_arch = "arm")]
|
||||
#[cfg(any(target_os = "android",
|
||||
all(target_os = "linux", target_arch = "arm")))]
|
||||
pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void)
|
||||
-> *mut libc::c_void
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user