From 7eefe7003b92c21ffd5829b082b0f4ca226e64eb Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Thu, 2 Oct 2014 19:55:06 +0200 Subject: [PATCH] Update to the new cfg syntax --- src/chroot/chroot.rs | 6 ++---- src/common/c_types.rs | 12 ++++-------- src/common/signals.rs | 3 +-- src/hostname/hostname.rs | 6 ++---- src/id/id.rs | 3 +-- src/nohup/nohup.rs | 6 ++---- src/uptime/uptime.rs | 3 +-- src/users/users.rs | 3 +-- 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 555ff6f5f..249d3800f 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -24,8 +24,7 @@ extern { fn chroot(path: *const libc::c_char) -> libc::c_int; } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] extern { fn setgroups(size: libc::c_int, list: *const libc::gid_t) -> libc::c_int; } @@ -151,8 +150,7 @@ fn set_main_group(group: &str) { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] fn set_groups(groups: Vec) -> libc::c_int { unsafe { setgroups(groups.len() as libc::c_int, diff --git a/src/common/c_types.rs b/src/common/c_types.rs index 465d163db..2330ab17d 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -8,8 +8,7 @@ use self::libc::{ uid_t, gid_t, }; -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] use self::libc::time_t; #[cfg(target_os = "macos")] use self::libc::int32_t; @@ -22,8 +21,7 @@ use std::os; use std::ptr::{null_mut, read}; use std::string::raw::from_buf; -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] #[repr(C)] pub struct c_passwd { pub pw_name: *const c_char, /* user name */ @@ -50,8 +48,7 @@ pub struct c_passwd { pub pw_shell: *const c_char, } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] #[repr(C)] pub struct utsname { pub sysname: [c_char, ..256], @@ -170,8 +167,7 @@ pub fn get_group_list(name: *const c_char, gid: gid_t) -> Vec { groups } -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] #[inline(always)] unsafe fn get_group_list_internal(name: *const c_char, gid: gid_t, groups: *mut gid_t, grcnt: *mut c_int) -> c_int { getgrouplist(name, gid, groups, grcnt) diff --git a/src/common/signals.rs b/src/common/signals.rs index ac0542751..3a5bd17bf 100644 --- a/src/common/signals.rs +++ b/src/common/signals.rs @@ -104,8 +104,7 @@ No Name Default Action Description */ -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] pub static ALL_SIGNALS:[Signal<'static>, ..31] = [ Signal{ name: "HUP", value:1 }, Signal{ name: "INT", value:2 }, diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 063a5773a..35360b90d 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -31,8 +31,7 @@ extern { fn gethostname(name: *mut libc::c_char, namelen: libc::size_t) -> libc::c_int; } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] extern { fn sethostname(name: *const libc::c_char, namelen: libc::c_int) -> libc::c_int; } @@ -148,8 +147,7 @@ fn xgethostname() -> String { str::from_utf8(name.slice_to(last_char)).unwrap().to_string() } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] fn xsethostname(name: &str) { let vec_name: Vec = name.bytes().map(|c| c as libc::c_char).collect(); diff --git a/src/id/id.rs b/src/id/id.rs index f58c2f4c2..ce7d1024a 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -251,8 +251,7 @@ fn pretty(possible_pw: Option) { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "macos", target_os = "freebsd"))] fn pline(possible_pw: Option) { let pw = if possible_pw.is_none() { unsafe { read(getpwuid(getuid())) } diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 2d25ed451..0f45d131c 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -41,12 +41,10 @@ fn rewind_stdout(s: &mut T) { } } -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] fn rewind_stdout(_: &mut T) {} pub fn uumain(args: Vec) -> int { diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 772b077b4..d310ed5c3 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -43,8 +43,7 @@ extern { fn setutxent(); fn endutxent(); - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "linux"))] fn utmpxname(file: *const c_char) -> c_int; } diff --git a/src/users/users.rs b/src/users/users.rs index 57b0ccbb3..7062cbd99 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -41,8 +41,7 @@ extern { fn setutxent(); fn endutxent(); - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "linux"))] fn utmpxname(file: *const libc::c_char) -> libc::c_int; }