From 95b9d538b8bda04e222c95d478b97c19d77bb5c6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 7 Jun 2012 21:38:25 -0700 Subject: [PATCH] Use #[cfg(unix)] and #[cfg(windows)] everywhere --- src/libcore/cmath.rs | 12 ++--- src/libcore/comm.rs | 6 +-- src/libcore/io.rs | 6 +-- src/libcore/iter.rs | 4 +- src/libcore/os.rs | 96 +++++++++++++--------------------- src/libcore/path.rs | 22 +++----- src/libcore/priv.rs | 2 +- src/libcore/rand.rs | 4 +- src/libcore/run.rs | 14 ++--- src/libcore/str.rs | 8 +-- src/libcore/task.rs | 12 ++--- src/libcore/uint-template.rs | 4 +- src/libcore/vec.rs | 4 +- src/libstd/c_vec.rs | 4 +- src/libstd/test.rs | 8 ++- src/libstd/uv_ll.rs | 72 +++++++------------------ src/rustc/back/rpath.rs | 4 +- src/rustc/middle/trans/base.rs | 8 +-- 18 files changed, 103 insertions(+), 187 deletions(-) diff --git a/src/libcore/cmath.rs b/src/libcore/cmath.rs index 3af00ea5627..f0b346e32a3 100644 --- a/src/libcore/cmath.rs +++ b/src/libcore/cmath.rs @@ -48,12 +48,10 @@ native mod c_double { pure fn frexp(n: c_double, &value: c_int) -> c_double; pure fn hypot(x: c_double, y: c_double) -> c_double; pure fn ldexp(x: c_double, n: c_int) -> c_double; - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] #[link_name="lgamma_r"] pure fn lgamma(n: c_double, &sign: c_int) -> c_double; - #[cfg(target_os = "win32")] + #[cfg(windows)] #[link_name="__lgamma_r"] pure fn lgamma(n: c_double, &sign: c_int) -> c_double; // renamed: log is a reserved keyword; ln seems more natural, too @@ -131,13 +129,11 @@ native mod c_float { #[link_name="hypotf"] pure fn hypot(x: c_float, y: c_float) -> c_float; #[link_name="ldexpf"] pure fn ldexp(x: c_float, n: c_int) -> c_float; - #[cfg(target_os="linux")] - #[cfg(target_os="macos")] - #[cfg(target_os="freebsd")] + #[cfg(unix)] #[link_name="lgammaf_r"] pure fn lgamma(n: c_float, &sign: c_int) -> c_float; - #[cfg(target_os="win32")] + #[cfg(windows)] #[link_name="__lgammaf_r"] pure fn lgamma(n: c_float, &sign: c_int) -> c_float; diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 4f29e7d982a..7836d05c818 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -420,7 +420,7 @@ fn test_recv_chan() { #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_recv_chan_dead() { let ch = chan(port()); send(ch, "flower"); @@ -428,7 +428,7 @@ fn test_recv_chan_dead() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_recv_chan_wrong_task() { let po = port(); let ch = chan(po); @@ -464,7 +464,7 @@ fn test_listen() { } #[test] -#[ignore(cfg(target_os="win32"))] +#[ignore(cfg(windows))] fn test_port_detach_fail() { iter::repeat(100u) {|| let builder = task::builder(); diff --git a/src/libcore/io.rs b/src/libcore/io.rs index b18be417019..077a178546e 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -398,12 +398,10 @@ fn fd_writer(fd: fd_t, cleanup: bool) -> writer { fn mk_file_writer(path: str, flags: [fileflag]) -> result { - #[cfg(target_os = "win32")] + #[cfg(windows)] fn wb() -> c_int { (O_WRONLY | O_BINARY) as c_int } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn wb() -> c_int { O_WRONLY as c_int } let mut fflags: c_int = wb(); diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 80ccfc1422e..cf903c3bebe 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -229,7 +229,7 @@ fn test_min() { #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_min_empty() { min::([]); } @@ -241,7 +241,7 @@ fn test_max() { #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_max_empty() { max::([]); } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index d2d6f48bceb..8ebb946af21 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -79,7 +79,7 @@ fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) } } -#[cfg(target_os = "win32")] +#[cfg(windows)] mod win32 { import dword = libc::types::os::arch::extra::DWORD; @@ -200,9 +200,7 @@ mod global_env { mod impl { - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn getenv(n: str) -> option unsafe { let s = str::as_c_str(n, libc::getenv); ret if unsafe::reinterpret_cast(s) == 0 { @@ -213,7 +211,7 @@ mod global_env { }; } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn getenv(n: str) -> option unsafe { import libc::types::os::arch::extra::*; import libc::funcs::extra::kernel32::*; @@ -226,9 +224,7 @@ mod global_env { } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn setenv(n: str, v: str) { // FIXME: remove this when export globs work properly. @@ -241,7 +237,7 @@ mod global_env { } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn setenv(n: str, v: str) { // FIXME: remove imports when export globs work properly. import libc::funcs::extra::kernel32::*; @@ -265,7 +261,7 @@ fn fdopen(fd: c_int) -> *FILE { // fsync related -#[cfg(target_os = "win32")] +#[cfg(windows)] fn fsync_fd(fd: c_int, _level: io::fsync::level) -> c_int { import libc::funcs::extra::msvcrt::*; ret commit(fd); @@ -305,14 +301,12 @@ fn fsync_fd(fd: c_int, _l: io::fsync::level) -> c_int { } -#[cfg(target_os = "win32")] +#[cfg(windows)] fn waitpid(pid: pid_t) -> c_int { ret rustrt::rust_process_wait(pid); } -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "macos")] +#[cfg(unix)] fn waitpid(pid: pid_t) -> c_int { import libc::funcs::posix01::wait::*; let status = 0 as c_int; @@ -323,9 +317,7 @@ fn waitpid(pid: pid_t) -> c_int { } -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "macos")] +#[cfg(unix)] fn pipe() -> {in: c_int, out: c_int} { let fds = {mut in: 0 as c_int, mut out: 0 as c_int }; @@ -335,7 +327,7 @@ fn pipe() -> {in: c_int, out: c_int} { -#[cfg(target_os = "win32")] +#[cfg(windows)] fn pipe() -> {in: c_int, out: c_int} { // FIXME: remove this when export globs work properly. import libc::consts::os::extra::*; @@ -359,12 +351,10 @@ fn pipe() -> {in: c_int, out: c_int} { fn dll_filename(base: str) -> str { ret pre() + base + dll_suffix(); - #[cfg(target_os = "macos")] - #[cfg(target_os = "linux")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn pre() -> str { "lib" } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn pre() -> str { "" } } @@ -405,7 +395,7 @@ fn self_exe_path() -> option { } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn load_self() -> option unsafe { // FIXME: remove imports when export globs work properly. import libc::types::os::arch::extra::*; @@ -449,14 +439,12 @@ fn homedir() -> option { } }; - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn secondary() -> option { none } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn secondary() -> option { option::chain(getenv("USERPROFILE")) {|p| if !str::is_empty(p) { @@ -536,7 +524,7 @@ fn make_absolute(p: path) -> path { fn make_dir(p: path, mode: c_int) -> bool { ret mkdir(p, mode); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn mkdir(p: path, _mode: c_int) -> bool unsafe { // FIXME: remove imports when export globs work properly. import libc::types::os::arch::extra::*; @@ -549,9 +537,7 @@ fn make_dir(p: path, mode: c_int) -> bool { } } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn mkdir(p: path, mode: c_int) -> bool { as_c_charp(p) {|c| libc::mkdir(c, mode as mode_t) == (0 as c_int) @@ -562,12 +548,10 @@ fn make_dir(p: path, mode: c_int) -> bool { #[doc = "Lists the contents of a directory"] fn list_dir(p: path) -> [str] { - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn star(p: str) -> str { p } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn star(p: str) -> str { let pl = str::len(p); if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep @@ -602,7 +586,7 @@ fn list_dir_path(p: path) -> [str] { fn remove_dir(p: path) -> bool { ret rmdir(p); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn rmdir(p: path) -> bool { // FIXME: remove imports when export globs work properly. import libc::funcs::extra::kernel32::*; @@ -613,9 +597,7 @@ fn remove_dir(p: path) -> bool { }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn rmdir(p: path) -> bool { ret as_c_charp(p) {|buf| libc::rmdir(buf) == (0 as c_int) @@ -626,7 +608,7 @@ fn remove_dir(p: path) -> bool { fn change_dir(p: path) -> bool { ret chdir(p); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn chdir(p: path) -> bool { // FIXME: remove imports when export globs work properly. import libc::funcs::extra::kernel32::*; @@ -637,9 +619,7 @@ fn change_dir(p: path) -> bool { }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn chdir(p: path) -> bool { ret as_c_charp(p) {|buf| libc::chdir(buf) == (0 as c_int) @@ -651,7 +631,7 @@ fn change_dir(p: path) -> bool { fn copy_file(from: path, to: path) -> bool { ret do_copy_file(from, to); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn do_copy_file(from: path, to: path) -> bool { // FIXME: remove imports when export globs work properly. import libc::funcs::extra::kernel32::*; @@ -664,9 +644,7 @@ fn copy_file(from: path, to: path) -> bool { } } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn do_copy_file(from: path, to: path) -> bool unsafe { let istream = as_c_charp(from) {|fromp| as_c_charp("rb") {|modebuf| @@ -716,7 +694,7 @@ fn copy_file(from: path, to: path) -> bool { fn remove_file(p: path) -> bool { ret unlink(p); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn unlink(p: path) -> bool { // FIXME: remove imports when export globs work properly. // (similar to Issue #2006) @@ -728,9 +706,7 @@ fn remove_file(p: path) -> bool { }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn unlink(p: path) -> bool { ret as_c_charp(p) {|buf| libc::unlink(buf) == (0 as c_int) @@ -755,12 +731,10 @@ fn set_exit_status(code: int) { rustrt::rust_set_exit_status(code as libc::intptr_t); } -#[cfg(target_os = "macos")] -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] fn family() -> str { "unix" } -#[cfg(target_os = "win32")] +#[cfg(windows)] fn family() -> str { "windows" } #[cfg(target_os = "macos")] @@ -824,7 +798,8 @@ mod tests { } #[test] - #[ignore(cgf(target_os = "win32"))] + #[ignore(cfg(windows))] + #[ignore] fn test_setenv_overwrite() { let n = make_rand_name(); setenv(n, "1"); @@ -837,7 +812,8 @@ mod tests { // Windows GetEnvironmentVariable requires some extra work to make sure // the buffer the variable is copied into is the right size #[test] - #[ignore(cgf(target_os = "win32"))] + #[ignore(cfg(windows))] + #[ignore] fn test_getenv_big() { let mut s = ""; let mut i = 0; @@ -902,9 +878,7 @@ mod tests { } #[test] - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn homedir() { let oldhome = getenv("HOME"); @@ -918,7 +892,7 @@ mod tests { } #[test] - #[cfg(target_os = "win32")] + #[cfg(windows)] fn homedir() { let oldhome = getenv("HOME"); diff --git a/src/libcore/path.rs b/src/libcore/path.rs index a771f2b9928..2e62b73063d 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -16,9 +16,7 @@ export normalize; #[doc = "A path or fragment of a filesystem path"] type path = str; -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "linux")] +#[cfg(unix)] mod consts { #[doc = " The primary path seperator character for the platform @@ -34,7 +32,7 @@ mod consts { const alt_path_sep: char = '/'; } -#[cfg(target_os = "win32")] +#[cfg(windows)] mod consts { const path_sep: char = '/'; const alt_path_sep: char = '\\'; @@ -46,14 +44,12 @@ Indicates whether a path is absolute. A path is considered absolute if it begins at the filesystem root (\"/\") or, on Windows, begins with a drive letter. "] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "linux")] +#[cfg(unix)] fn path_is_absolute(p: path) -> bool { str::char_at(p, 0u) == '/' } -#[cfg(target_os = "win32")] +#[cfg(windows)] fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/' || str::char_at(p, 1u) == ':' @@ -271,9 +267,7 @@ fn normalize(p: path) -> path { ret t; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn reabsolute(orig: path, n: path) -> path { if path_is_absolute(orig) { path_sep() + n @@ -282,7 +276,7 @@ fn normalize(p: path) -> path { } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn reabsolute(orig: path, newp: path) -> path { if path_is_absolute(orig) && orig[0] == consts::path_sep as u8 { str::from_char(consts::path_sep) + newp @@ -427,7 +421,7 @@ mod tests { } #[test] - #[cfg(target_os = "win32")] + #[cfg(windows)] fn normalize12() { let actual = normalize("C:/whatever"); let expected = "C:/whatever"; @@ -436,7 +430,7 @@ mod tests { } #[test] - #[cfg(target_os = "win32")] + #[cfg(windows)] fn path_is_absolute_win32() { assert path_is_absolute("C:/whatever"); } diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index d43fc27a019..fc1e547ebde 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -225,7 +225,7 @@ fn test_weaken_task_stress() unsafe { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_weaken_task_fail() unsafe { let res = task::try {|| weaken_task {|_po| diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 71bd1025d1d..f5e404712b9 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -325,7 +325,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn gen_int_from_fail() { rand::rng().gen_int_range(5, -2); } @@ -341,7 +341,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn gen_uint_range_fail() { rand::rng().gen_uint_range(5u, 2u); } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 34ba16844d8..7ffbd24d42f 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -90,9 +90,7 @@ fn with_argv(prog: str, args: [str], vec::as_buf(argptrs, cb) } -#[cfg(target_os = "macos")] -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] fn with_envp(env: option<[(str,str)]>, cb: fn(*c_void) -> T) -> T unsafe { // On posixy systems we can pass a char** for envp, which is @@ -117,7 +115,7 @@ fn with_envp(env: option<[(str,str)]>, } } -#[cfg(target_os = "win32")] +#[cfg(windows)] fn with_envp(env: option<[(str,str)]>, cb: fn(*c_void) -> T) -> T unsafe { // On win32 we pass an "environment block" which is not a char**, but @@ -278,14 +276,12 @@ fn program_output(prog: str, args: [str]) -> fn waitpid(pid: pid_t) -> int { ret waitpid_os(pid); - #[cfg(target_os = "win32")] + #[cfg(windows)] fn waitpid_os(pid: pid_t) -> int { os::waitpid(pid) as int } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn waitpid_os(pid: pid_t) -> int { #[cfg(target_os = "linux")] fn WIFEXITED(status: i32) -> bool { @@ -324,7 +320,7 @@ mod tests { import io::writer_util; // Regression test for memory leaks - #[ignore(cfg(target_os = "win32"))] // FIXME + #[ignore(cfg(windows))] // FIXME fn test_leaks() { run::run_program("echo", []); run::start_program("echo", []); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6c24b656988..af2062f4b1d 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1998,7 +1998,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_pop_char_fail() { let mut data = ""; let _cc3 = pop_char(data); @@ -2419,7 +2419,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_slice_fail() { slice("中华Việt Nam", 0u, 2u); } @@ -2512,7 +2512,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_from_bytes_fail() { let bb = [0xff_u8, 0xb8_u8, 0xa8_u8, 0xe0_u8, 0xb9_u8, 0x84_u8, @@ -2537,7 +2537,7 @@ mod tests { } #[test] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] #[should_fail] fn test_as_bytes_fail() { // Don't double free diff --git a/src/libcore/task.rs b/src/libcore/task.rs index f9e70e0fc39..654d0e92bd6 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -605,7 +605,7 @@ fn test_spawn_raw_simple() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_spawn_raw_unsupervise() { let opts = { supervise: false @@ -617,7 +617,7 @@ fn test_spawn_raw_unsupervise() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_spawn_raw_notify() { let task_po = comm::port(); let task_ch = comm::chan(task_po); @@ -674,7 +674,7 @@ fn test_add_wrapper() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_future_result() { let buildr = builder(); let result = future_result(buildr); @@ -726,7 +726,7 @@ fn test_try_success() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_try_fail() { alt try {|| fail @@ -738,7 +738,7 @@ fn test_try_fail() { #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn test_spawn_sched_no_threads() { spawn_sched(manual_threads(0u)) {|| }; } @@ -957,7 +957,7 @@ fn test_osmain() { } #[test] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] #[should_fail] fn test_unkillable() unsafe { import comm::methods; diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index d1d238d298c..1a14ddc1d8f 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -247,14 +247,14 @@ fn test_parse_buf() { #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn to_str_radix1() { uint::to_str(100u, 1u); } #[test] #[should_fail] -#[ignore(cfg(target_os = "win32"))] +#[ignore(cfg(windows))] fn to_str_radix17() { uint::to_str(100u, 17u); } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 4cfcd6b7517..eef84111875 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -2040,7 +2040,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_init_empty() { init::([]); } @@ -2070,7 +2070,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_windowed_() { let _x = windowed (0u, [1u,2u,3u,4u,5u,6u]); } diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 5133c02b3ea..d60d0c8c84e 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -152,7 +152,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_overrun_get() { let cv = malloc(16u as size_t); @@ -161,7 +161,7 @@ mod tests { #[test] #[should_fail] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_overrun_set() { let cv = malloc(16u as size_t); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 18aaebb3fdb..e693ec2a1ac 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -314,12 +314,10 @@ fn run_tests(opts: test_opts, tests: [test_desc], } // Windows tends to dislike being overloaded with threads. -#[cfg(target_os = "win32")] +#[cfg(windows)] const sched_overcommit : uint = 1u; -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "macos")] +#[cfg(unix)] const sched_overcommit : uint = 4u; fn get_concurrency() -> uint { @@ -449,7 +447,7 @@ mod tests { } #[test] - #[ignore(cfg(target_os = "win32"))] + #[ignore(cfg(windows))] fn test_should_fail() { fn f() { fail; } let desc = { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index f6a99f8aa06..e882eba5d6b 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -67,18 +67,12 @@ type uv_err_t = { // in other types as a pointer to be used in other // operations (so mostly treat it as opaque, once you // have it in this form..) -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "win32")] type uv_stream_t = { fields: uv_handle_fields }; // 64bit unix size: 272 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] type uv_tcp_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -104,7 +98,7 @@ type uv_tcp_t_32bit_unix_riders = { }; // 32bit win32 size: 240 (120) -#[cfg(target_os = "win32")] +#[cfg(windows)] type uv_tcp_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -117,15 +111,13 @@ type uv_tcp_t = { }; // unix size: 48 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] type uv_connect_t = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8 }; // win32 size: 88 (44) -#[cfg(target_os = "win32")] +#[cfg(windows)] type uv_connect_t = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -133,10 +125,6 @@ type uv_connect_t = { }; // unix size: 16 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "win32")] type uv_buf_t = { base: *u8, len: libc::size_t @@ -145,9 +133,7 @@ type uv_buf_t = { // it via uv::direct::buf_init() // unix size: 144 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] type uv_write_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -165,7 +151,7 @@ type uv_write_t_32bit_unix_riders = { a13: *u8, a14: *u8 }; // win32 size: 136 (68) -#[cfg(target_os = "win32")] +#[cfg(windows)] type uv_write_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -175,9 +161,7 @@ type uv_write_t = { }; // 64bit unix size: 120 // 32bit unix size: 152 (76) -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] type uv_async_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -194,7 +178,7 @@ type uv_async_t_32bit_unix_riders = { a10: *u8, a11: *u8, a12: *u8, a13: *u8 }; // win32 size 132 (68) -#[cfg(target_os = "win32")] +#[cfg(windows)] type uv_async_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -205,9 +189,7 @@ type uv_async_t = { // 64bit unix size: 128 // 32bit unix size: 84 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] type uv_timer_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -225,7 +207,7 @@ type uv_timer_t_32bit_unix_riders = { a14: *u8, a15: *u8, a16: *u8 }; // win32 size: 64 -#[cfg(target_os = "win32")] +#[cfg(windows)] type uv_timer_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -234,10 +216,6 @@ type uv_timer_t = { }; // unix size: 16 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "win32")] type sockaddr_in = { mut sin_family: u16, mut sin_port: u16, @@ -246,10 +224,6 @@ type sockaddr_in = { }; // unix size: 28 .. make due w/ 32 -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "win32")] type sockaddr_in6 = { a0: *u8, a1: *u8, a2: *u8, a3: (u8, u8, u8, u8) @@ -316,7 +290,7 @@ mod uv_ll_struct_stubgen { }; } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn gen_stub_os() -> uv_tcp_t { ret { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), @@ -337,9 +311,7 @@ mod uv_ll_struct_stubgen { }; } } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn gen_stub_uv_connect_t() -> uv_connect_t { ret { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -347,7 +319,7 @@ mod uv_ll_struct_stubgen { a04: 0 as *u8, a05: 0 as *u8 }; } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn gen_stub_uv_connect_t() -> uv_connect_t { ret { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -357,9 +329,7 @@ mod uv_ll_struct_stubgen { a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8 }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn gen_stub_uv_async_t() -> uv_async_t { ret gen_stub_arch(); #[cfg(target_arch = "x86_64")] @@ -394,7 +364,7 @@ mod uv_ll_struct_stubgen { }; } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn gen_stub_uv_async_t() -> uv_async_t { ret { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), @@ -408,9 +378,7 @@ mod uv_ll_struct_stubgen { a12: 0 as *u8 }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn gen_stub_uv_timer_t() -> uv_timer_t { ret gen_stub_arch(); #[cfg(target_arch = "x86_64")] @@ -447,7 +415,7 @@ mod uv_ll_struct_stubgen { }; } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn gen_stub_uv_timer_t() -> uv_timer_t { ret { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), @@ -460,9 +428,7 @@ mod uv_ll_struct_stubgen { a11: 0 as *u8 }; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn gen_stub_uv_write_t() -> uv_write_t { ret gen_stub_arch(); #[cfg(target_arch="x86_64")] @@ -494,7 +460,7 @@ mod uv_ll_struct_stubgen { }; } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn gen_stub_uv_write_t() -> uv_write_t { ret { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index 675f1c43745..06376c18cb0 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -188,9 +188,7 @@ fn minimize_rpaths(rpaths: [str]) -> [str] { ret minimized; } -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(unix)] mod test { #[test] fn test_rpaths_to_flags() { diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 34845ceb45a..208e05de886 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -5061,13 +5061,9 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, } fn create_entry_fn(ccx: @crate_ctxt, rust_main: ValueRef) { - #[cfg(target_os = "win32")] + #[cfg(windows)] fn main_name() -> str { ret "WinMain@16"; } - #[cfg(target_os = "macos")] - fn main_name() -> str { ret "main"; } - #[cfg(target_os = "linux")] - fn main_name() -> str { ret "main"; } - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn main_name() -> str { ret "main"; } let llfty = T_fn([ccx.int_type, ccx.int_type], ccx.int_type); let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty);