]> git.lizzy.rs Git - rust.git/commitdiff
Fix libstd
authorSteven Fackler <sfackler@gmail.com>
Mon, 29 Sep 2014 05:31:50 +0000 (22:31 -0700)
committerSteven Fackler <sfackler@palantir.com>
Tue, 30 Sep 2014 19:52:00 +0000 (12:52 -0700)
src/libstd/dynamic_lib.rs
src/libstd/io/net/addrinfo.rs
src/libstd/io/process.rs
src/libstd/io/signal.rs
src/libstd/os.rs
src/libstd/rand/os.rs
src/libstd/rt/backtrace.rs

index a88448f47e0c6e9c62f3bfdc1e783242cba51ca4..bd2bd1ad0904a161fc98a35d96a9416c98435a03 100644 (file)
@@ -154,7 +154,7 @@ pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
     }
 }
 
-#[cfg(test, not(target_os = "ios"))]
+#[cfg(all(test, not(target_os = "ios")))]
 mod test {
     use super::*;
     use prelude::*;
@@ -189,10 +189,10 @@ fn test_loading_cosine() {
     }
 
     #[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 @@ fn test_errors_do_not_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};
index 867e8bcca826d25732c6c94692091667175435c6..ea1dd12f323a7f82a4ac2c1fef803b44e8d2524b 100644 (file)
@@ -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();
index 83890d2b1275e09d7bbb0220b304e8b650043efb..f97e9f4647ba018321fc8f65e85dd9d5ae3fec4a 100644 (file)
@@ -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 @@ pub fn run_output(cmd: Command) -> String {
         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 @@ pub fn run_output(cmd: Command) -> String {
         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 @@ pub fn run_output(cmd: Command) -> String {
         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 @@ pub fn run_output(cmd: Command) -> String {
         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 @@ pub fn run_output(cmd: Command) -> String {
         }
     })
 
-    #[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 @@ pub fn pwd_cmd() -> Command {
         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")
     }
index 1d882bdc0ad9e0fddd53ff318921029f8c43f265..79a00e90b40746d8fde0b6a3ce555bb3f17d8130 100644 (file)
@@ -160,7 +160,7 @@ pub fn unregister(&mut self, signum: Signum) {
     }
 }
 
-#[cfg(test, unix)]
+#[cfg(all(test, unix))]
 mod test_unix {
     use prelude::*;
     use libc;
@@ -218,7 +218,7 @@ fn test_io_signal_unregister() {
     }
 }
 
-#[cfg(test, windows)]
+#[cfg(all(test, windows))]
 mod test_windows {
     use super::{User1, Listener};
     use result::{Ok, Err};
index 478a40f17b0d3c11d0e0bd2e0bc5c3d00261bce9..d904e657e403b082e61110c71af92c7b60732ca6 100644 (file)
@@ -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 @@ fn load_self() -> Option<Vec<u8>> {
         }
     }
 
-    #[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 @@ fn load_self() -> Option<Vec<u8>> {
         }
     }
 
-    #[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 @@ fn chdir(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 @@ fn errno_location() -> *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;
@@ -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;
 
index 120ace1c36a5f99bdb00dbbffd8c44f250760174..c5b7154ffdb57d00dd5d5eb6f03fb33fc31ccf1d 100644 (file)
@@ -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;
index aa9505d83fc275fcae49dc4e446122795029f54f..33f8713e1a13c9f61fa67856ec89997f4f268cd6 100644 (file)
@@ -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 @@ fn backtrace(buf: *mut *mut libc::c_void,
         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 @@ struct Context<'a> {
         }
     }
 
-    #[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 @@ fn dladdr(addr: *const libc::c_void,
         }
     }
 
-    #[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 @@ pub enum _Unwind_Context {}
 
         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 @@ pub fn _Unwind_FindEnclosingFunction(pc: *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 {
@@ -634,8 +634,8 @@ fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
 
         // 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
         {