1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #1836 from aspenluxxxy/ios-compat

Change target_os = "macos" to target_vendor = "apple"
This commit is contained in:
Sylvestre Ledru 2021-03-18 14:37:26 +01:00 committed by GitHub
commit a482e28798
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 54 additions and 64 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";

View file

@ -115,7 +115,7 @@ fn test_reference() {
}
#[test]
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn test_reference() {
new_ucmd!()
.arg("-v")

View file

@ -12,7 +12,7 @@ fn test_du_basics() {
assert!(result.success);
assert_eq!(result.stderr, "");
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn _du_basics(s: String) {
let answer = "32\t./subdir
8\t./subdir/deeper
@ -21,7 +21,7 @@ fn _du_basics(s: String) {
";
assert_eq!(s, answer);
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
fn _du_basics(s: String) {
let answer = "28\t./subdir
8\t./subdir/deeper
@ -41,11 +41,11 @@ fn test_du_basics_subdir() {
_du_basics_subdir(result.stdout);
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn _du_basics_subdir(s: String) {
assert_eq!(s, "4\tsubdir/deeper\n");
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
fn _du_basics_subdir(s: String) {
// MS-WSL linux has altered expected output
if !is_wsl() {
@ -80,12 +80,12 @@ fn test_du_soft_link() {
_du_soft_link(result.stdout);
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn _du_soft_link(s: String) {
// 'macos' host variants may have `du` output variation for soft links
assert!((s == "12\tsubdir/links\n") || (s == "16\tsubdir/links\n"));
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
fn _du_soft_link(s: String) {
// MS-WSL linux has altered expected output
if !is_wsl() {
@ -109,11 +109,11 @@ fn test_du_hard_link() {
_du_hard_link(result.stdout);
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn _du_hard_link(s: String) {
assert_eq!(s, "12\tsubdir/links\n")
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
fn _du_hard_link(s: String) {
// MS-WSL linux has altered expected output
if !is_wsl() {
@ -133,11 +133,11 @@ fn test_du_d_flag() {
_du_d_flag(result.stdout);
}
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn _du_d_flag(s: String) {
assert_eq!(s, "16\t./subdir\n20\t./\n");
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
fn _du_d_flag(s: String) {
// MS-WSL linux has altered expected output
if !is_wsl() {

View file

@ -11,7 +11,7 @@ fn test_hostname() {
}
// FixME: fails for "MacOS"
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
#[test]
fn test_hostname_ip() {
let result = new_ucmd!().arg("-i").run();

View file

@ -285,7 +285,7 @@ fn test_ls_ls_color() {
scene.ucmd().arg("--color=never").arg("z").succeeds();
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))] // Truncate not available on mac or win
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))] // Truncate not available on mac or win
#[test]
fn test_ls_human() {
let scene = TestScenario::new(util_name!());