Skip to content

Commit

Permalink
Fix libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Sep 30, 2014
1 parent 1e0c7b6 commit d5647a8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 56 deletions.
22 changes: 11 additions & 11 deletions src/libstd/dynamic_lib.rs
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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.
Expand All @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/net/addrinfo.rs
Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions src/libstd/io/process.rs
Expand Up @@ -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());
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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;

Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/signal.rs
Expand Up @@ -160,7 +160,7 @@ impl Listener {
}
}

#[cfg(test, unix)]
#[cfg(all(test, unix))]
mod test_unix {
use prelude::*;
use libc;
Expand Down Expand Up @@ -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};
Expand Down
36 changes: 16 additions & 20 deletions src/libstd/os.rs
Expand Up @@ -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::*;
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rand/os.rs
Expand Up @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions src/libstd/rt/backtrace.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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)]
Expand All @@ -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;
Expand Down Expand Up @@ -571,25 +570,26 @@ 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;
}

// 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 {
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit d5647a8

Please sign in to comment.