1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Update to the new cfg syntax

This commit is contained in:
Michael Gehring 2014-10-02 19:55:06 +02:00
parent 24d2730208
commit 7eefe7003b
8 changed files with 14 additions and 28 deletions

View file

@ -24,8 +24,7 @@ extern {
fn chroot(path: *const libc::c_char) -> libc::c_int; fn chroot(path: *const libc::c_char) -> libc::c_int;
} }
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
extern { extern {
fn setgroups(size: libc::c_int, list: *const libc::gid_t) -> libc::c_int; 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(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int { fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int {
unsafe { unsafe {
setgroups(groups.len() as libc::c_int, setgroups(groups.len() as libc::c_int,

View file

@ -8,8 +8,7 @@ use self::libc::{
uid_t, uid_t,
gid_t, gid_t,
}; };
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
use self::libc::time_t; use self::libc::time_t;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
use self::libc::int32_t; use self::libc::int32_t;
@ -22,8 +21,7 @@ use std::os;
use std::ptr::{null_mut, read}; use std::ptr::{null_mut, read};
use std::string::raw::from_buf; use std::string::raw::from_buf;
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
#[repr(C)] #[repr(C)]
pub struct c_passwd { pub struct c_passwd {
pub pw_name: *const c_char, /* user name */ pub pw_name: *const c_char, /* user name */
@ -50,8 +48,7 @@ pub struct c_passwd {
pub pw_shell: *const c_char, pub pw_shell: *const c_char,
} }
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
#[repr(C)] #[repr(C)]
pub struct utsname { pub struct utsname {
pub sysname: [c_char, ..256], pub sysname: [c_char, ..256],
@ -170,8 +167,7 @@ pub fn get_group_list(name: *const c_char, gid: gid_t) -> Vec<gid_t> {
groups groups
} }
#[cfg(target_os = "linux")] #[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
#[inline(always)] #[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 { 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) getgrouplist(name, gid, groups, grcnt)

View file

@ -104,8 +104,7 @@ No Name Default Action Description
*/ */
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
pub static ALL_SIGNALS:[Signal<'static>, ..31] = [ pub static ALL_SIGNALS:[Signal<'static>, ..31] = [
Signal{ name: "HUP", value:1 }, Signal{ name: "HUP", value:1 },
Signal{ name: "INT", value:2 }, Signal{ name: "INT", value:2 },

View file

@ -31,8 +31,7 @@ extern {
fn gethostname(name: *mut libc::c_char, namelen: libc::size_t) -> libc::c_int; fn gethostname(name: *mut libc::c_char, namelen: libc::size_t) -> libc::c_int;
} }
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
extern { extern {
fn sethostname(name: *const libc::c_char, namelen: libc::c_int) -> libc::c_int; 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() str::from_utf8(name.slice_to(last_char)).unwrap().to_string()
} }
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
fn xsethostname(name: &str) { fn xsethostname(name: &str) {
let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as libc::c_char).collect(); let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as libc::c_char).collect();

View file

@ -251,8 +251,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
} }
} }
#[cfg(target_os = "macos")] #[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
fn pline(possible_pw: Option<c_passwd>) { fn pline(possible_pw: Option<c_passwd>) {
let pw = if possible_pw.is_none() { let pw = if possible_pw.is_none() {
unsafe { read(getpwuid(getuid())) } unsafe { read(getpwuid(getuid())) }

View file

@ -41,12 +41,10 @@ fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(s: &mut T) {
} }
} }
#[cfg(target_os = "linux")] #[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() }
#[cfg(target_os = "linux")] #[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(_: &mut T) {} fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(_: &mut T) {}
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> int {

View file

@ -43,8 +43,7 @@ extern {
fn setutxent(); fn setutxent();
fn endutxent(); fn endutxent();
#[cfg(target_os = "linux")] #[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(target_os = "macos")]
fn utmpxname(file: *const c_char) -> c_int; fn utmpxname(file: *const c_char) -> c_int;
} }

View file

@ -41,8 +41,7 @@ extern {
fn setutxent(); fn setutxent();
fn endutxent(); fn endutxent();
#[cfg(target_os = "linux")] #[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(target_os = "macos")]
fn utmpxname(file: *const libc::c_char) -> libc::c_int; fn utmpxname(file: *const libc::c_char) -> libc::c_int;
} }