1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-15 17:51:07 +00:00

uutils: change every target_os = "macos" to target_vendor = "apple"

This commit is contained in:
aspen 2021-03-17 21:32:34 -04:00
parent 99be7a3172
commit 4e29b693f8
No known key found for this signature in database
GPG key ID: 9CCE5F51B2F8C465
18 changed files with 64 additions and 74 deletions

View file

@ -164,7 +164,7 @@ fn set_main_group(group: &str) {
}
}
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int {
unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) }
}

View file

@ -32,15 +32,15 @@ use std::ffi::CString;
#[cfg(unix)]
use std::mem;
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
use libc::c_int;
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
use libc::statfs;
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
use std::ffi::CStr;
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "windows"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "windows"))]
use std::ptr;
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
use std::slice;
#[cfg(target_os = "freebsd")]
@ -137,7 +137,7 @@ struct MountInfo {
#[cfg(all(
target_os = "freebsd",
not(all(target_os = "macos", target_arch = "x86_64"))
not(all(target_vendor = "apple", target_arch = "x86_64"))
))]
#[repr(C)]
#[derive(Copy, Clone)]
@ -209,20 +209,20 @@ fn get_usage() -> String {
format!("{0} [OPTION]... [FILE]...", executable!())
}
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
extern "C" {
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
#[link_name = "getmntinfo$INODE64"]
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
#[cfg(any(
all(target_os = "freebsd"),
all(target_os = "macos", target_arch = "aarch64")
all(target_vendor = "apple", target_arch = "aarch64")
))]
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
}
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
impl From<statfs> for MountInfo {
fn from(statfs: statfs) -> Self {
let mut info = MountInfo {
@ -585,7 +585,7 @@ fn read_fs_list() -> Vec<MountInfo> {
})
.collect::<Vec<_>>()
}
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
{
let mut mptr: *mut statfs = ptr::null_mut();
let len = unsafe { getmntinfo(&mut mptr, 1 as c_int) };

View file

@ -291,7 +291,7 @@ fn pretty(possible_pw: Option<Passwd>) {
}
}
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
fn pline(possible_uid: Option<uid_t>) {
let uid = possible_uid.unwrap_or_else(getuid);
let pw = Passwd::locate(uid).unwrap();

View file

@ -23,7 +23,7 @@ use uucore::fs::{is_stderr_interactive, is_stdin_interactive, is_stdout_interact
static NAME: &str = "nohup";
static VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
extern "C" {
fn _vprocmgr_detach_from_console(flags: u32) -> *const libc::c_int;
}

View file

@ -15,7 +15,7 @@ use std::env;
#[cfg(target_os = "linux")]
pub const _SC_NPROCESSORS_CONF: libc::c_int = 83;
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
pub const _SC_NPROCESSORS_CONF: libc::c_int = libc::_SC_NPROCESSORS_CONF;
#[cfg(target_os = "freebsd")]
pub const _SC_NPROCESSORS_CONF: libc::c_int = 57;
@ -89,7 +89,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd"
))]
@ -109,7 +109,7 @@ fn num_cpus_all() -> usize {
// Other platforms (e.g., windows), num_cpus::get() directly.
#[cfg(not(any(
target_os = "linux",
target_os = "macos",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd"
)))]

View file

@ -149,7 +149,7 @@ use std::path::Path;
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_vendor = "apple",
target_os = "android",
target_os = "freebsd"
))]
@ -165,7 +165,7 @@ use uucore::libc::statvfs as Sstatfs;
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_vendor = "apple",
target_os = "android",
target_os = "freebsd"
))]
@ -211,11 +211,11 @@ impl FsMeta for Sstatfs {
fn free_fnodes(&self) -> u64 {
self.f_ffree as u64
}
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd"))]
fn fs_type(&self) -> i64 {
self.f_type as i64
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))]
#[cfg(not(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd")))]
fn fs_type(&self) -> i64 {
// FIXME: statvfs doesn't have an equivalent, so we need to do something else
unimplemented!()
@ -225,12 +225,12 @@ impl FsMeta for Sstatfs {
fn iosize(&self) -> u64 {
self.f_frsize as u64
}
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
fn iosize(&self) -> u64 {
self.f_iosize as u64
}
// XXX: dunno if this is right
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
fn iosize(&self) -> u64 {
self.f_bsize as u64
}
@ -241,13 +241,13 @@ impl FsMeta for Sstatfs {
//
// Solaris, Irix and POSIX have a system call statvfs(2) that returns a
// struct statvfs, containing an unsigned long f_fsid
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "linux"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux"))]
fn fsid(&self) -> u64 {
let f_fsid: &[u32; 2] =
unsafe { &*(&self.f_fsid as *const uucore::libc::fsid_t as *const [u32; 2]) };
(u64::from(f_fsid[0])) << 32 | u64::from(f_fsid[1])
}
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
fn fsid(&self) -> u64 {
self.f_fsid as u64
}
@ -256,7 +256,7 @@ impl FsMeta for Sstatfs {
fn namelen(&self) -> u64 {
self.f_namelen as u64
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn namelen(&self) -> u64 {
1024
}
@ -265,7 +265,7 @@ impl FsMeta for Sstatfs {
self.f_namemax as u64
}
// XXX: should everything just use statvfs?
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
fn namelen(&self) -> u64 {
self.f_namemax as u64
}

View file

@ -4,12 +4,12 @@ use std::env;
use std::fs;
use std::path::Path;
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))]
mod platform {
pub const DYLIB_EXT: &str = ".so";
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_vendor = "apple"))]
mod platform {
pub const DYLIB_EXT: &str = ".dylib";
}

View file

@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) {
("LD_PRELOAD", "so")
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn preload_strings() -> (&'static str, &'static str) {
("DYLD_LIBRARY_PATH", "dylib")
}
@ -67,7 +67,7 @@ fn preload_strings() -> (&'static str, &'static str) {
target_os = "freebsd",
target_os = "netbsd",
target_os = "dragonflybsd",
target_os = "macos"
target_vendor = "apple"
)))]
fn preload_strings() -> (&'static str, &'static str) {
crash!(1, "Command not supported for this operating system!")

View file

@ -39,7 +39,7 @@ const HOST_OS: &str = "Windows NT";
const HOST_OS: &str = "FreeBSD";
#[cfg(target_os = "openbsd")]
const HOST_OS: &str = "OpenBSD";
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
const HOST_OS: &str = "Darwin";
#[cfg(target_os = "fuchsia")]
const HOST_OS: &str = "Fuchsia";

View file

@ -60,12 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
"count",
"all login names and number of users logged on",
);
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "linux",
target_os = "android"
))]
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))]
opts.optflag("r", "runlevel", "print current runlevel");
opts.optflag("s", "short", "print only name, line, and time (default)");
opts.optflag("t", "time", "print last system clock change");
@ -305,12 +300,7 @@ impl Who {
#[allow(unused_assignments)]
let mut res = false;
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "linux",
target_os = "android"
))]
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))]
{
res = record == utmpx::RUN_LVL;
}

View file

@ -34,7 +34,7 @@
//! assert!(entries::Group::locate(root_group).is_ok());
//! ```
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
use libc::time_t;
use libc::{c_char, c_int, gid_t, uid_t};
use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd};
@ -119,19 +119,19 @@ impl Passwd {
}
/// AKA passwd.pw_class
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
pub fn user_access_class(&self) -> Cow<str> {
cstr2cow!(self.inner.pw_class)
}
/// AKA passwd.pw_change
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
pub fn passwd_change_time(&self) -> time_t {
self.inner.pw_change
}
/// AKA passwd.pw_expire
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
pub fn expiration(&self) -> time_t {
self.inner.pw_expire
}

View file

@ -197,7 +197,7 @@ No Name Default Action Description
*/
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
pub static ALL_SIGNALS: [Signal<'static>; 31] = [
Signal {
name: "HUP",

View file

@ -47,7 +47,7 @@ use libc::utmpx;
pub use libc::endutxent;
pub use libc::getutxent;
pub use libc::setutxent;
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
pub use libc::utmpxname;
#[cfg(target_os = "freebsd")]
pub unsafe extern "C" fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
@ -85,7 +85,7 @@ mod ut {
pub use libc::USER_PROCESS;
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
mod ut {
pub static DEFAULT_FILE: &str = "/var/run/utmpx";