}
}
-#[cfg(test, not(target_os = "ios"))]
+#[cfg(all(test, not(target_os = "ios")))]
mod test {
use super::*;
use prelude::*;
}
#[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.
}
}
-#[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};
// 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();
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());
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")
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")
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")
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;
}
})
- #[cfg(unix,not(target_os="android"))]
+ #[cfg(all(unix, not(target_os="android")))]
pub fn pwd_cmd() -> Command {
Command::new("pwd")
}
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")
}
}
}
-#[cfg(test, unix)]
+#[cfg(all(test, unix))]
mod test_unix {
use prelude::*;
use libc;
}
}
-#[cfg(test, windows)]
+#[cfg(all(test, windows))]
mod test_windows {
use super::{User1, Listener};
use result::{Ok, Err};
/// ```
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::*;
}
}
- #[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;
}
}
- #[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;
#[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;
}
}
- #[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;
#[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 {
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;
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;
/// 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};
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<()> {
}
}
- #[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)]
}
}
- #[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;
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 {
// 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
{