diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index f184e07891b96..0003de117a835 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -67,7 +67,7 @@ def run(args): "target_os = \"" + os + "\"", ] - f.write("#[cfg(" + ', '.join(cfg) + ")]\n") + f.write("#[cfg(all(" + ', '.join(cfg) + "))]\n") version = run([llconfig, '--version']).strip() diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 349ae15eb32a0..0d2872bcba06b 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -111,12 +111,12 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) { // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. In practice, the alignment is a // constant at the call site and the branch will be optimized out. -#[cfg(target_arch = "arm")] -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel"))] static MIN_ALIGN: uint = 8; -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", + target_arch = "x86_64"))] static MIN_ALIGN: uint = 16; #[cfg(jemalloc)] @@ -146,7 +146,7 @@ mod imp { } // -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough - #[cfg(not(windows), not(target_os = "android"))] + #[cfg(all(not(windows), not(target_os = "android")))] #[link(name = "pthread")] extern {} @@ -206,7 +206,7 @@ mod imp { } } -#[cfg(not(jemalloc), unix)] +#[cfg(all(not(jemalloc), unix))] mod imp { use core::cmp; use core::ptr; @@ -268,7 +268,7 @@ mod imp { pub fn stats_print() {} } -#[cfg(not(jemalloc), windows)] +#[cfg(all(not(jemalloc), windows))] mod imp { use libc::{c_void, size_t}; use libc; diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index 296615e15ffa0..a665d41aadf96 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -188,27 +188,27 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, // windows requires saving more registers (both general and XMM), so the windows // register context must be larger. -#[cfg(windows, target_arch = "x86_64")] +#[cfg(all(windows, target_arch = "x86_64"))] #[repr(C)] struct Registers { gpr:[libc::uintptr_t, ..14], _xmm:[simd::u32x4, ..10] } -#[cfg(not(windows), target_arch = "x86_64")] +#[cfg(all(not(windows), target_arch = "x86_64"))] #[repr(C)] struct Registers { gpr:[libc::uintptr_t, ..10], _xmm:[simd::u32x4, ..6] } -#[cfg(windows, target_arch = "x86_64")] +#[cfg(all(windows, target_arch = "x86_64"))] fn new_regs() -> Box { box() Registers { gpr:[0,..14], _xmm:[simd::u32x4(0,0,0,0),..10] } } -#[cfg(not(windows), target_arch = "x86_64")] +#[cfg(all(not(windows), target_arch = "x86_64"))] fn new_regs() -> Box { box() Registers { gpr:[0,..10], @@ -288,16 +288,13 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, regs[14] = rust_bootstrap_green_task as libc::uintptr_t; // #56 pc, r14 --> lr } -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "mips", target_arch = "mipsel"))] type Registers = [libc::uintptr_t, ..32]; -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "mips", target_arch = "mipsel"))] fn new_regs() -> Box { box {[0, .. 32]} } -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "mips", target_arch = "mipsel"))] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, procedure: raw::Procedure, sp: *mut uint) { let sp = align_down(sp); diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs index 4673e7b3ba209..23b41f6c6e75b 100644 --- a/src/libgreen/stack.rs +++ b/src/libgreen/stack.rs @@ -28,11 +28,10 @@ pub struct Stack { // // DragonFly BSD also seems to suffer from the same problem. When MAP_STACK is // used, it returns the same `ptr` multiple times. -#[cfg(not(windows), not(target_os = "freebsd"), not(target_os = "dragonfly"))] +#[cfg(not(any(windows, target_os = "freebsd", target_os = "dragonfly")))] static STACK_FLAGS: libc::c_int = libc::MAP_STACK | libc::MAP_PRIVATE | libc::MAP_ANON; -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] static STACK_FLAGS: libc::c_int = libc::MAP_PRIVATE | libc::MAP_ANON; #[cfg(windows)] static STACK_FLAGS: libc::c_int = 0; diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index eabc02e3e26eb..affa452eb49de 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -278,32 +278,31 @@ pub use funcs::bsd43::{shutdown}; #[cfg(windows)] pub use funcs::extra::msvcrt::{get_osfhandle, open_osfhandle}; #[cfg(windows)] pub use funcs::extra::winsock::{ioctlsocket}; -#[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"))] pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC}; -#[cfg(target_os = "linux")] #[cfg(target_os = "android")] +#[cfg(any(target_os = "linux", target_os = "android"))] pub use funcs::posix01::unistd::{fdatasync}; -#[cfg(target_os = "linux")] #[cfg(target_os = "android")] +#[cfg(any(target_os = "linux", target_os = "android"))] pub use types::os::arch::extra::{sockaddr_ll}; -#[cfg(target_os = "linux")] #[cfg(target_os = "android")] +#[cfg(any(target_os = "linux", target_os = "android"))] pub use consts::os::extra::{AF_PACKET}; -#[cfg(unix, not(target_os = "freebsd"))] +#[cfg(all(unix, not(target_os = "freebsd")))] pub use consts::os::extra::{MAP_STACK}; -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] pub use consts::os::bsd44::{TCP_KEEPIDLE}; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "macos", target_os = "ios"))] pub use consts::os::bsd44::{TCP_KEEPALIVE}; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "macos", target_os = "ios"))] pub use consts::os::extra::{F_FULLFSYNC}; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] + +#[cfg(any(target_os = "macos", target_os = "ios"))] pub use types::os::arch::extra::{mach_timebase_info}; @@ -372,8 +371,7 @@ pub mod types { // Standard types that are scalar but vary by OS and arch. - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub mod os { pub mod common { pub mod posix01 { @@ -506,10 +504,10 @@ pub mod types { } } - #[cfg(target_arch = "x86")] - #[cfg(target_arch = "arm")] - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel"))] pub mod arch { pub mod c95 { pub type c_char = i8; @@ -536,9 +534,9 @@ pub mod types { pub type intptr_t = i32; pub type uintptr_t = u32; } - #[cfg(target_arch = "x86")] - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "x86", + target_arch = "mips", + target_arch = "mipsel"))] pub mod posix88 { pub type off_t = i32; pub type dev_t = u64; @@ -652,8 +650,7 @@ pub mod types { pub __size: [u32, ..9] } } - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub mod posix01 { use types::os::arch::c95::{c_long, c_ulong, time_t}; use types::os::arch::posix88::{gid_t, ino_t}; @@ -1660,8 +1657,7 @@ pub mod types { } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] pub mod os { pub mod common { pub mod posix01 { @@ -1793,8 +1789,7 @@ pub mod types { } } - #[cfg(target_arch = "arm")] - #[cfg(target_arch = "x86")] + #[cfg(any(target_arch = "arm", target_arch = "x86"))] pub mod arch { pub mod c95 { pub type c_char = i8; @@ -2383,8 +2378,7 @@ pub mod consts { } - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub mod os { pub mod c95 { use types::os::arch::c95::{c_int, c_uint}; @@ -2407,9 +2401,9 @@ pub mod consts { } pub mod c99 { } - #[cfg(target_arch = "x86")] - #[cfg(target_arch = "x86_64")] - #[cfg(target_arch = "arm")] + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm"))] pub mod posix88 { use types::os::arch::c95::c_int; use types::common::c95::c_void; @@ -2621,8 +2615,7 @@ pub mod consts { pub static EHWPOISON: c_int = 133; } - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub mod posix88 { use types::os::arch::c95::c_int; use types::common::c95::c_void; @@ -2898,13 +2891,14 @@ pub mod consts { #[cfg(target_os = "android")] pub static PTHREAD_STACK_MIN: size_t = 8192; - #[cfg(target_arch = "arm", target_os = "linux")] - #[cfg(target_arch = "x86", target_os = "linux")] - #[cfg(target_arch = "x86_64", target_os = "linux")] + #[cfg(all(target_os = "linux", + any(target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64")))] pub static PTHREAD_STACK_MIN: size_t = 16384; - #[cfg(target_arch = "mips", target_os = "linux")] - #[cfg(target_arch = "mipsel", target_os = "linux")] + #[cfg(all(target_os = "linux", + any(target_arch = "mips", target_arch = "mipsel")))] pub static PTHREAD_STACK_MIN: size_t = 131072; pub static CLOCK_REALTIME: c_int = 0; @@ -2912,9 +2906,9 @@ pub mod consts { } pub mod posix08 { } - #[cfg(target_arch = "arm")] - #[cfg(target_arch = "x86")] - #[cfg(target_arch = "x86_64")] + #[cfg(any(target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64"))] pub mod bsd44 { use types::os::arch::c95::c_int; @@ -2961,8 +2955,7 @@ pub mod consts { pub static SHUT_WR: c_int = 1; pub static SHUT_RDWR: c_int = 2; } - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub mod bsd44 { use types::os::arch::c95::c_int; @@ -3007,9 +3000,9 @@ pub mod consts { pub static SHUT_WR: c_int = 1; pub static SHUT_RDWR: c_int = 2; } - #[cfg(target_arch = "x86")] - #[cfg(target_arch = "x86_64")] - #[cfg(target_arch = "arm")] + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm"))] pub mod extra { use types::os::arch::c95::c_int; @@ -3036,8 +3029,7 @@ pub mod consts { pub static MAP_NONBLOCK : c_int = 0x010000; pub static MAP_STACK : c_int = 0x020000; } - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] + #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub mod extra { use types::os::arch::c95::c_int; @@ -3160,8 +3152,7 @@ pub mod consts { } } - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] pub mod os { pub mod c95 { use types::os::arch::c95::{c_int, c_uint}; @@ -3421,10 +3412,11 @@ pub mod consts { #[cfg(target_arch = "arm")] pub static PTHREAD_STACK_MIN: size_t = 4096; - #[cfg(target_os = "freebsd", target_arch = "mips")] - #[cfg(target_os = "freebsd", target_arch = "mipsel")] - #[cfg(target_os = "freebsd", target_arch = "x86")] - #[cfg(target_os = "freebsd", target_arch = "x86_64")] + #[cfg(all(target_os = "freebsd", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "x86", + target_arch = "x86_64")))] pub static PTHREAD_STACK_MIN: size_t = 2048; #[cfg(target_os = "dragonfly")] @@ -3569,8 +3561,7 @@ pub mod consts { } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] pub mod os { pub mod c95 { use types::os::arch::c95::{c_int, c_uint}; @@ -4261,13 +4252,12 @@ pub mod funcs { } } - - #[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 posix88 { pub mod stat_ { use types::os::arch::c95::{c_char, c_int}; @@ -4278,11 +4268,11 @@ pub mod funcs { pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; - #[cfg(target_os = "linux")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] - #[cfg(target_os = "android")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "android", + target_os = "ios"))] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; #[cfg(target_os = "macos")] @@ -4292,11 +4282,11 @@ pub mod funcs { pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; - #[cfg(target_os = "linux")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] - #[cfg(target_os = "android")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "android", + target_os = "ios"))] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg(target_os = "macos")] @@ -4481,23 +4471,23 @@ pub mod funcs { } - #[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 posix01 { pub mod stat_ { use types::os::arch::c95::{c_char, c_int}; use types::os::arch::posix01::stat; extern { - #[cfg(target_os = "linux")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] - #[cfg(target_os = "android")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "android", + target_os = "ios"))] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg(target_os = "macos")] @@ -4518,8 +4508,7 @@ pub mod funcs { pub fn fsync(fd: c_int) -> c_int; - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub fn fdatasync(fd: c_int) -> c_int; pub fn setenv(name: *const c_char, val: *const c_char, @@ -4598,13 +4587,13 @@ pub mod funcs { } - #[cfg(target_os = "windows")] - #[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 = "windows", + target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] pub mod posix08 { pub mod unistd { } @@ -4687,10 +4676,10 @@ pub mod funcs { } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] pub mod bsd44 { use types::common::c95::{c_void}; use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t}; @@ -4723,8 +4712,7 @@ pub mod funcs { } - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub mod bsd44 { use types::common::c95::{c_void}; use types::os::arch::c95::{c_uchar, c_int, size_t}; @@ -4744,8 +4732,7 @@ pub mod funcs { pub mod bsd44 { } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] pub mod extra { use types::os::arch::c95::{c_char, c_int}; @@ -4755,13 +4742,11 @@ pub mod funcs { } } - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] pub mod extra { } - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub mod extra { } diff --git a/src/libnative/io/c_unix.rs b/src/libnative/io/c_unix.rs index fa7da1de914b4..2601d493443a1 100644 --- a/src/libnative/io/c_unix.rs +++ b/src/libnative/io/c_unix.rs @@ -19,41 +19,42 @@ pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD}; use libc; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] pub static FIONBIO: libc::c_ulong = 0x8004667e; -#[cfg(target_os = "linux", target_arch = "x86")] -#[cfg(target_os = "linux", target_arch = "x86_64")] -#[cfg(target_os = "linux", target_arch = "arm")] -#[cfg(target_os = "android")] +#[cfg(any(all(target_os = "linux", + any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm")), + target_os = "android"))] pub static FIONBIO: libc::c_ulong = 0x5421; -#[cfg(target_os = "linux", target_arch = "mips")] -#[cfg(target_os = "linux", target_arch = "mipsel")] +#[cfg(all(target_os = "linux", + any(target_arch = "mips", target_arch = "mipsel")))] pub static FIONBIO: libc::c_ulong = 0x667e; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] pub static FIOCLEX: libc::c_ulong = 0x20006601; -#[cfg(target_os = "linux", target_arch = "x86")] -#[cfg(target_os = "linux", target_arch = "x86_64")] -#[cfg(target_os = "linux", target_arch = "arm")] -#[cfg(target_os = "android")] +#[cfg(any(all(target_os = "linux", + any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm")), + target_os = "android"))] pub static FIOCLEX: libc::c_ulong = 0x5451; -#[cfg(target_os = "linux", target_arch = "mips")] -#[cfg(target_os = "linux", target_arch = "mipsel")] +#[cfg(all(target_os = "linux", + any(target_arch = "mips", target_arch = "mipsel")))] pub static FIOCLEX: libc::c_ulong = 0x6601; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] pub static MSG_DONTWAIT: libc::c_int = 0x80; -#[cfg(target_os = "linux")] -#[cfg(target_os = "android")] +#[cfg(any(target_os = "linux", target_os = "android"))] pub static MSG_DONTWAIT: libc::c_int = 0x40; pub static WNOHANG: libc::c_int = 1; @@ -86,8 +87,7 @@ extern { pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int; } -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "macos", target_os = "ios"))] mod select { pub static FD_SETSIZE: uint = 1024; @@ -101,10 +101,10 @@ mod select { } } -#[cfg(target_os = "android")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "linux"))] mod select { use std::uint; use libc; @@ -123,10 +123,11 @@ mod select { } } -#[cfg(target_os = "linux", target_arch = "x86")] -#[cfg(target_os = "linux", target_arch = "x86_64")] -#[cfg(target_os = "linux", target_arch = "arm")] -#[cfg(target_os = "android")] +#[cfg(any(all(target_os = "linux", + any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm")), + target_os = "android"))] mod signal { use libc; @@ -173,8 +174,8 @@ mod signal { } } -#[cfg(target_os = "linux", target_arch = "mips")] -#[cfg(target_os = "linux", target_arch = "mipsel")] +#[cfg(all(target_os = "linux", + any(target_arch = "mips", target_arch = "mipsel")))] mod signal { use libc; @@ -215,10 +216,10 @@ mod signal { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] mod signal { use libc; diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 1688b009ad7fb..67aad1904b96f 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -130,8 +130,7 @@ impl rtio::RtioFileStream for FileDesc { fn datasync(&mut self) -> IoResult<()> { return super::mkerr_libc(os_datasync(self.fd())); - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] fn os_datasync(fd: c_int) -> c_int { unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) } } @@ -139,7 +138,7 @@ impl rtio::RtioFileStream for FileDesc { fn os_datasync(fd: c_int) -> c_int { retry(|| unsafe { libc::fdatasync(fd) }) } - #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))] + #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))] fn os_datasync(fd: c_int) -> c_int { retry(|| unsafe { libc::fsync(fd) }) } @@ -445,14 +444,14 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat { // FileStat times are in milliseconds fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 } - #[cfg(not(target_os = "linux"), not(target_os = "android"))] + #[cfg(not(any(target_os = "linux", target_os = "android")))] fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 } - #[cfg(target_os = "linux")] #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] fn flags(_stat: &libc::stat) -> u64 { 0 } - #[cfg(not(target_os = "linux"), not(target_os = "android"))] + #[cfg(not(any(target_os = "linux", target_os = "android")))] fn gen(stat: &libc::stat) -> u64 { stat.st_gen as u64 } - #[cfg(target_os = "linux")] #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] fn gen(_stat: &libc::stat) -> u64 { 0 } rtio::FileStat { diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs index 86f72bf65ddd3..954f7bbc59adc 100644 --- a/src/libnative/io/mod.rs +++ b/src/libnative/io/mod.rs @@ -48,12 +48,12 @@ pub mod file; #[path = "file_windows.rs"] pub mod file; -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] -#[cfg(target_os = "android")] -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "android", + target_os = "linux"))] #[path = "timer_unix.rs"] pub mod timer; diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index 335a52b0bbed6..419748b75c324 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -282,20 +282,20 @@ impl TcpStream { } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, seconds as libc::c_int) } - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, seconds as libc::c_int) } - #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"), - not(target_os = "dragonfly"))] + #[cfg(not(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly")))] fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> { Ok(()) } diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index cb392e1675feb..3a6ae42f9468d 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -840,18 +840,17 @@ fn free_handle(_handle: *mut ()) { #[cfg(unix)] fn translate_status(status: c_int) -> rtio::ProcessExit { #![allow(non_snake_case)] - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] mod imp { pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 } pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff } pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] mod imp { pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 } pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 } diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 06f89d38ca0a1..267ff3d2a8174 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -77,10 +77,9 @@ pub use task::NativeTaskBuilder; pub mod io; pub mod task; -#[cfg(windows)] -#[cfg(android)] +#[cfg(any(windows, android))] static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20; -#[cfg(unix, not(android))] +#[cfg(all(unix, not(android)))] static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20); #[lang = "start"] diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index c51e242026241..d898931cb330b 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -162,15 +162,14 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) // Default per-arch clobbers // Basically what clang does -#[cfg(target_arch = "arm")] -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel"))] fn get_clobbers() -> String { "".to_string() } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn get_clobbers() -> String { "~{dirflag},~{fpsr},~{flags}".to_string() } diff --git a/src/librustc_back/fs.rs b/src/librustc_back/fs.rs index c051b8e60cd80..756516d17a2ea 100644 --- a/src/librustc_back/fs.rs +++ b/src/librustc_back/fs.rs @@ -51,7 +51,7 @@ pub fn realpath(original: &Path) -> io::IoResult { return Ok(result); } -#[cfg(not(windows), test)] +#[cfg(all(not(windows), test))] mod test { use std::io; use std::io::fs::{File, symlink, mkdir, mkdir_recursive}; diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index e0946366abc81..abb594d6e47a8 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -147,7 +147,7 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec { minimized } -#[cfg(unix, test)] +#[cfg(all(unix, test))] mod test { use super::{RPathConfig}; use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; diff --git a/src/librustdoc/flock.rs b/src/librustdoc/flock.rs index 8b72bd9e10283..d1cc37497dc44 100644 --- a/src/librustdoc/flock.rs +++ b/src/librustdoc/flock.rs @@ -84,8 +84,7 @@ mod imp { pub static F_SETLKW: libc::c_int = 9; } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] mod os { use libc; diff --git a/src/librustdoc/plugins.rs b/src/librustdoc/plugins.rs index fe217a6d123aa..2b5595131d0a7 100644 --- a/src/librustdoc/plugins.rs +++ b/src/librustdoc/plugins.rs @@ -85,7 +85,7 @@ fn libname(mut n: String) -> String { n } -#[cfg(not(target_os="windows"), not(target_os="macos"))] +#[cfg(all(not(target_os="windows"), not(target_os="macos")))] fn libname(n: String) -> String { let mut i = String::from_str("lib"); i.push_str(n.as_slice()); diff --git a/src/librustrt/args.rs b/src/librustrt/args.rs index c0a17a7201473..bd63886baeeda 100644 --- a/src/librustrt/args.rs +++ b/src/librustrt/args.rs @@ -39,10 +39,10 @@ pub fn put(args: Vec>) { imp::put(args) } /// Make a clone of the global arguments. pub fn clone() -> Option>> { imp::clone() } -#[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"))] mod imp { use core::prelude::*; @@ -146,9 +146,9 @@ mod imp { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "windows"))] mod imp { use core::prelude::*; use collections::vec::Vec; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index b4ad1f23154b4..72c7d89a3b98b 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -160,7 +160,7 @@ pub unsafe fn cleanup() { pub mod shouldnt_be_public { #[cfg(not(test))] pub use super::local_ptr::native::maybe_tls_key; - #[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))] + #[cfg(all(not(windows), not(target_os = "android"), not(target_os = "ios")))] pub use super::local_ptr::compiled::RT_TLS_PTR; } diff --git a/src/librustrt/libunwind.rs b/src/librustrt/libunwind.rs index aab75d7f7746d..2e7408d91591c 100644 --- a/src/librustrt/libunwind.rs +++ b/src/librustrt/libunwind.rs @@ -16,8 +16,7 @@ use libc; -#[cfg(not(target_arch = "arm"))] -#[cfg(target_os = "ios")] +#[cfg(any(not(target_arch = "arm"), target_os = "ios"))] #[repr(C)] pub enum _Unwind_Action { _UA_SEARCH_PHASE = 1, @@ -62,14 +61,13 @@ pub static unwinder_private_data_size: uint = 5; #[cfg(target_arch = "x86_64")] pub static unwinder_private_data_size: uint = 6; -#[cfg(target_arch = "arm", not(target_os = "ios"))] +#[cfg(all(target_arch = "arm", not(target_os = "ios")))] pub static unwinder_private_data_size: uint = 20; -#[cfg(target_arch = "arm", target_os = "ios")] +#[cfg(all(target_arch = "arm", target_os = "ios"))] pub static unwinder_private_data_size: uint = 5; -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub static unwinder_private_data_size: uint = 2; #[repr(C)] @@ -85,8 +83,7 @@ pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] #[link(name = "gcc_s")] extern {} @@ -101,11 +98,11 @@ extern {} extern "C" { // iOS on armv7 uses SjLj exceptions and requires to link // against corresponding routine (..._SjLj_...) - #[cfg(not(target_os = "ios", target_arch = "arm"))] + #[cfg(not(all(target_os = "ios", target_arch = "arm")))] pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; - #[cfg(target_os = "ios", target_arch = "arm")] + #[cfg(all(target_os = "ios", target_arch = "arm"))] fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; @@ -115,7 +112,7 @@ extern "C" { // ... and now we just providing access to SjLj counterspart // through a standard name to hide those details from others // (see also comment above regarding _Unwind_RaiseException) -#[cfg(target_os = "ios", target_arch = "arm")] +#[cfg(all(target_os = "ios", target_arch = "arm"))] #[inline(always)] pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception) -> _Unwind_Reason_Code { diff --git a/src/librustrt/local_ptr.rs b/src/librustrt/local_ptr.rs index 912e4ef4d40f4..58f8f8b310f55 100644 --- a/src/librustrt/local_ptr.rs +++ b/src/librustrt/local_ptr.rs @@ -22,13 +22,13 @@ use core::prelude::*; use core::mem; use alloc::boxed::Box; -#[cfg(windows)] // mingw-w32 doesn't like thread_local things -#[cfg(target_os = "android")] // see #10686 -#[cfg(target_os = "ios")] +#[cfg(any(windows, // mingw-w32 doesn't like thread_local things + target_os = "android", // see #10686 + target_os = "ios"))] pub use self::native::{init, cleanup, put, take, try_take, unsafe_take, exists, unsafe_borrow, try_unsafe_borrow}; -#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))] +#[cfg(not(any(windows, target_os = "android", target_os = "ios")))] pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists, unsafe_borrow, try_unsafe_borrow}; @@ -82,7 +82,7 @@ pub unsafe fn borrow() -> Borrowed { /// implemented using LLVM's thread_local attribute which isn't necessarily /// working on all platforms. This implementation is faster, however, so we use /// it wherever possible. -#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))] +#[cfg(not(any(windows, target_os = "android", target_os = "ios")))] pub mod compiled { use core::prelude::*; diff --git a/src/librustrt/mutex.rs b/src/librustrt/mutex.rs index f4fff43fd7c4f..86dc9b85a792d 100644 --- a/src/librustrt/mutex.rs +++ b/src/librustrt/mutex.rs @@ -346,8 +346,7 @@ mod imp { type pthread_mutexattr_t = libc::c_void; type pthread_condattr_t = libc::c_void; - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] mod os { use libc; @@ -360,8 +359,7 @@ mod imp { 0 as pthread_cond_t; } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] mod os { use libc; diff --git a/src/librustrt/stack.rs b/src/librustrt/stack.rs index a4cbbf248113f..5c94ef61bfdb7 100644 --- a/src/librustrt/stack.rs +++ b/src/librustrt/stack.rs @@ -156,13 +156,13 @@ pub unsafe fn record_rust_managed_stack_bounds(stack_lo: uint, stack_hi: uint) { #[cfg(not(windows))] #[inline(always)] unsafe fn target_record_stack_bounds(_stack_lo: uint, _stack_hi: uint) {} - #[cfg(windows, target_arch = "x86")] #[inline(always)] + #[cfg(all(windows, target_arch = "x86"))] #[inline(always)] unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) { // stack range is at TIB: %fs:0x04 (top) and %fs:0x08 (bottom) asm!("mov $0, %fs:0x04" :: "r"(stack_hi) :: "volatile"); asm!("mov $0, %fs:0x08" :: "r"(stack_lo) :: "volatile"); } - #[cfg(windows, target_arch = "x86_64")] #[inline(always)] + #[cfg(all(windows, target_arch = "x86_64"))] #[inline(always)] unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) { // stack range is at TIB: %gs:0x08 (top) and %gs:0x10 (bottom) asm!("mov $0, %gs:0x08" :: "r"(stack_hi) :: "volatile"); @@ -189,49 +189,53 @@ pub unsafe fn record_sp_limit(limit: uint) { return target_record_sp_limit(limit); // x86-64 - #[cfg(target_arch = "x86_64", target_os = "macos")] - #[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", + any(target_os = "macos", target_os = "ios")))] + #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movq $$0x60+90*8, %rsi movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile") } - #[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile") } - #[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] unsafe fn target_record_sp_limit(_: uint) { } - #[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile") } - #[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile") } // x86 - #[cfg(target_arch = "x86", target_os = "macos")] - #[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "x86", + any(target_os = "macos", target_os = "ios")))] + #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movl $$0x48+90*4, %eax movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile") } - #[cfg(target_arch = "x86", target_os = "linux")] - #[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)] + #[cfg(all(target_arch = "x86", + any(target_os = "linux", target_os = "freebsd")))] + #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile") } - #[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)] + #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] unsafe fn target_record_sp_limit(_: uint) { } // mips, arm - Some brave soul can port these to inline asm, but it's over // my head personally - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] - #[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)] + #[cfg(any(target_arch = "mips", + target_arch = "mipsel", + all(target_arch = "arm", not(target_os = "ios"))))] + #[inline(always)] unsafe fn target_record_sp_limit(limit: uint) { use libc::c_void; return record_sp_limit(limit as *const c_void); @@ -241,7 +245,7 @@ pub unsafe fn record_sp_limit(limit: uint) { } // iOS segmented stack is disabled for now, see related notes - #[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)] unsafe fn target_record_sp_limit(_: uint) { } } @@ -259,31 +263,32 @@ pub unsafe fn get_sp_limit() -> uint { return target_get_sp_limit(); // x86-64 - #[cfg(target_arch = "x86_64", target_os = "macos")] - #[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", + any(target_os = "macos", target_os = "ios")))] + #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movq $$0x60+90*8, %rsi movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile"); return limit; } - #[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile"); return limit; } - #[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { return 1024; } - #[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile"); return limit; } - #[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)] + #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile"); @@ -292,31 +297,34 @@ pub unsafe fn get_sp_limit() -> uint { // x86 - #[cfg(target_arch = "x86", target_os = "macos")] - #[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "x86", + any(target_os = "macos", target_os = "ios")))] + #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movl $$0x48+90*4, %eax movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile"); return limit; } - #[cfg(target_arch = "x86", target_os = "linux")] - #[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)] + #[cfg(all(target_arch = "x86", + any(target_os = "linux", target_os = "freebsd")))] + #[inline(always)] unsafe fn target_get_sp_limit() -> uint { let limit; asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile"); return limit; } - #[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)] + #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { return 1024; } // mips, arm - Some brave soul can port these to inline asm, but it's over // my head personally - #[cfg(target_arch = "mips")] - #[cfg(target_arch = "mipsel")] - #[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)] + #[cfg(any(target_arch = "mips", + target_arch = "mipsel", + all(target_arch = "arm", not(target_os = "ios"))))] + #[inline(always)] unsafe fn target_get_sp_limit() -> uint { use libc::c_void; return get_sp_limit() as uint; @@ -328,7 +336,7 @@ pub unsafe fn get_sp_limit() -> uint { // iOS doesn't support segmented stacks yet. This function might // be called by runtime though so it is unsafe to mark it as // unreachable, let's return a fixed constant. - #[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)] + #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)] unsafe fn target_get_sp_limit() -> uint { 1024 } diff --git a/src/librustrt/thread_local_storage.rs b/src/librustrt/thread_local_storage.rs index 6078ed990e41d..aee70980bbaf7 100644 --- a/src/librustrt/thread_local_storage.rs +++ b/src/librustrt/thread_local_storage.rs @@ -41,11 +41,11 @@ pub unsafe fn destroy(key: Key) { #[allow(non_camel_case_types)] // foreign type type pthread_key_t = ::libc::c_ulong; -#[cfg(target_os="linux")] -#[cfg(target_os="freebsd")] -#[cfg(target_os="dragonfly")] -#[cfg(target_os="android")] -#[cfg(target_os = "ios")] +#[cfg(any(target_os="linux", + target_os="freebsd", + target_os="dragonfly", + target_os="android", + target_os = "ios"))] #[allow(non_camel_case_types)] // foreign type type pthread_key_t = ::libc::c_uint; diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index d3ab0f27c1328..1561f428ce548 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -235,7 +235,9 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class { // // See also: rt/rust_try.ll -#[cfg(not(target_arch = "arm"), not(windows, target_arch = "x86_64"), not(test))] +#[cfg(all(not(target_arch = "arm"), + not(all(windows, target_arch = "x86_64")), + not(test)))] #[doc(hidden)] pub mod eabi { use libunwind as uw; @@ -288,7 +290,7 @@ pub mod eabi { // iOS on armv7 is using SjLj exceptions and therefore requires to use // a specialized personality routine: __gcc_personality_sj0 -#[cfg(target_os = "ios", target_arch = "arm", not(test))] +#[cfg(all(target_os = "ios", target_arch = "arm", not(test)))] #[doc(hidden)] pub mod eabi { use libunwind as uw; @@ -343,7 +345,7 @@ pub mod eabi { // ARM EHABI uses a slightly different personality routine signature, // but otherwise works the same. -#[cfg(target_arch = "arm", not(target_os = "ios"), not(test))] +#[cfg(all(target_arch = "arm", not(target_os = "ios"), not(test)))] #[doc(hidden)] pub mod eabi { use libunwind as uw; @@ -392,7 +394,7 @@ pub mod eabi { // GCC reuses the same personality routine as for the other architectures by wrapping it // with an "API translator" layer (_GCC_specific_handler). -#[cfg(windows, target_arch = "x86_64", not(test))] +#[cfg(all(windows, target_arch = "x86_64", not(test)))] #[doc(hidden)] #[allow(non_camel_case_types, non_snake_case)] pub mod eabi { diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index c7c278675c182..35bd20c0dd90b 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -723,12 +723,11 @@ extern { // libuv doesn't use pthread on windows // android libc (bionic) provides pthread, so no additional link is required -#[cfg(not(windows), not(target_os = "android"))] +#[cfg(not(any(windows, target_os = "android")))] #[link(name = "pthread")] extern {} -#[cfg(target_os = "linux")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "linux", target_os = "dragonfly"))] #[link(name = "rt")] extern {} @@ -738,7 +737,6 @@ extern {} #[link(name = "iphlpapi")] extern {} -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] #[link(name = "kvm")] extern {} diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index a88448f47e0c6..bd2bd1ad0904a 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -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}; diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 867e8bcca826d..ea1dd12f323a7 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -123,7 +123,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option) // 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(); diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 83890d2b1275e..f97e9f4647ba0 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -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") } diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 1d882bdc0ad9e..79a00e90b4074 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -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}; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 478a40f17b0d3..d904e657e403b 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -653,8 +653,7 @@ pub fn dll_filename(base: &str) -> String { /// ``` pub fn self_exe_name() -> Option { - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] fn load_self() -> Option> { unsafe { use libc::funcs::bsd44::*; @@ -680,8 +679,7 @@ pub fn self_exe_name() -> Option { } } - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] fn load_self() -> Option> { use std::io; @@ -691,8 +689,7 @@ pub fn self_exe_name() -> Option { } } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] fn load_self() -> Option> { 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> { 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> { use rt; diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 120ace1c36a5f..c5b7154ffdb57 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -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; diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index aa9505d83fc27..33f8713e1a13c 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -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 { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 8963185192a8b..1491f02b3f5c1 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -315,14 +315,11 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P], cfg: &ast::Me ast::MetaList(ref pred, ref mis) if pred.get() == "all" => mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)), ast::MetaList(ref pred, ref mis) if pred.get() == "not" => { - // NOTE: turn on after snapshot - /* if mis.len() != 1 { diagnostic.span_warn(cfg.span, "the use of multiple cfgs in the same `not` \ statement is deprecated. Change `not(a, b)` to \ `not(all(a, b))`."); } - */ !mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)) } ast::MetaList(ref pred, _) => { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 5b17f6f004a08..c5ef2399b1a9f 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -260,8 +260,6 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P], attrs: &[ast::Attr _ => continue }; - // NOTE: turn on after snapshot - /* if mis.len() != 1 { diagnostic.span_warn(attr.span, "The use of multiple cfgs in the top level of \ `#[cfg(..)]` is deprecated. Change `#[cfg(a, b)]` to \ @@ -274,7 +272,6 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P], attrs: &[ast::Attr the intersection of the cfgs. Change `#[cfg(a)] \ #[cfg(b)]` to `#[cfg(any(a, b))]`."); } - */ seen_cfg = true; in_cfg |= mis.iter().all(|mi| attr::cfg_matches(diagnostic, cfg, &**mi)); diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index 342e7e6d52e84..74039da6cabdb 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -38,14 +38,11 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, p.expect(&token::COMMA); } - // NOTE: turn on after snapshot - /* if cfgs.len() != 1 { cx.span_warn(sp, "The use of multiple cfgs at the top level of `cfg!` \ is deprecated. Change `cfg!(a, b)` to \ `cfg!(all(a, b))`."); } - */ let matches_cfg = cfgs.iter().all(|cfg| attr::cfg_matches(&cx.parse_sess.span_diagnostic, cx.cfg.as_slice(), &**cfg)); diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 9cec71104d403..c1889af034355 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -47,7 +47,7 @@ mod rustrt { } } -#[cfg(unix, not(target_os = "macos"), not(target_os = "ios"))] +#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios")))] mod imp { use libc::{c_int, timespec}; @@ -61,8 +61,7 @@ mod imp { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "macos", target_os = "ios"))] mod imp { use libc::{timeval, timezone, c_int, mach_timebase_info}; @@ -150,8 +149,7 @@ pub fn get_time() -> Timespec { ((ns_since_1970 % 1000000) * 1000) as i32) } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] unsafe fn os_get_time() -> (i64, i32) { use std::ptr; let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 }; @@ -159,7 +157,7 @@ pub fn get_time() -> Timespec { (tv.tv_sec as i64, tv.tv_usec * 1000) } - #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(windows))] + #[cfg(not(any(target_os = "macos", target_os = "ios", windows)))] unsafe fn os_get_time() -> (i64, i32) { let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 }; imp::clock_gettime(libc::CLOCK_REALTIME, &mut tv); @@ -190,8 +188,7 @@ pub fn precise_time_ns() -> u64 { return (ticks as u64 * 1000000000) / (ticks_per_s as u64); } - #[cfg(target_os = "macos")] - #[cfg(target_os = "ios")] + #[cfg(any(target_os = "macos", target_os = "ios"))] fn os_precise_time_ns() -> u64 { static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0, denom: 0 }; @@ -205,7 +202,7 @@ pub fn precise_time_ns() -> u64 { } } - #[cfg(not(windows), not(target_os = "macos"), not(target_os = "ios"))] + #[cfg(not(any(windows, target_os = "macos", target_os = "ios")))] fn os_precise_time_ns() -> u64 { let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 }; unsafe {