darwin.system_cmds: remove code for macOS < 11

We need to pull in an additional XNU header for a tool we are now
able to build.
This commit is contained in:
Emily
2024-11-18 00:14:01 +00:00
parent bd002ebb74
commit 1c0adeb5d4
3 changed files with 20 additions and 79 deletions
@@ -76,17 +76,14 @@ install_man('accton/accton.8')
executable(
'arch',
build_by_default : sdk_version.version_compare('>=11'),
dependencies : [ core_foundation ],
install : sdk_version.version_compare('>=11'),
install : true,
sources : 'arch/arch.c',
)
if sdk_version.version_compare('>=11')
install_man(
'arch/arch.1',
'arch/machine.1',
)
endif
install_man(
'arch/arch.1',
'arch/machine.1',
)
executable(
'at',
@@ -192,8 +189,8 @@ install_man('fs_usage/fs_usage.1')
executable(
'gcore',
# Requires XPC private APIs
build_by_default : false and sdk_version.version_compare('>=11'),
install : false and sdk_version.version_compare('>=11'),
build_by_default : false,
install : false,
sources : [
'gcore/convert.c',
'gcore/corefile.c',
@@ -359,13 +356,10 @@ install_man('mkfile/mkfile.8')
executable(
'mslutil',
build_by_default : sdk_version.version_compare('>=10.13'),
install : sdk_version.version_compare('>=10.13'),
install : true,
sources : 'mslutil/mslutil.c',
)
if sdk_version.version_compare('>=10.13')
install_man('mslutil/mslutil.1')
endif
install_man('mslutil/mslutil.1')
executable(
'newgrp',
@@ -495,8 +489,8 @@ executable('shutdown',
executable(
'stackshot',
# Requires private entitlements
build_by_default : false and sdk_version.version_compare('>=10.13'),
install : false and sdk_version.version_compare('>=10.13'),
build_by_default : false,
install : false,
sources : 'stackshot/stackshot.c',
)
# No man pages for `stackshot`.
@@ -520,13 +514,10 @@ install_man(
executable(
'taskpolicy',
build_by_default : sdk_version.version_compare('>=11'),
install : sdk_version.version_compare('>=11'),
install : true,
sources : 'taskpolicy/taskpolicy.c',
)
if sdk_version.version_compare('>=11')
install_man('taskpolicy/taskpolicy.8')
endif
install_man('taskpolicy/taskpolicy.8')
executable(
'vifs',
@@ -546,13 +537,10 @@ executable(
install_man('vipw/vipw.8')
executable('vm_purgeable_stat',
build_by_default : sdk_version.version_compare('>=11'),
install : sdk_version.version_compare('>=11'),
install : true,
sources : 'vm_purgeable_stat/vm_purgeable_stat.c',
)
if sdk_version.version_compare('>=11')
install_man('vm_purgeable_stat/vm_purgeable_stat.1')
endif
install_man('vm_purgeable_stat/vm_purgeable_stat.1')
executable(
'vm_stat',
@@ -593,18 +581,15 @@ install_man('zic/zic.8')
executable(
'zlog',
build_by_default : sdk_version.version_compare('>=11'),
c_args : '-DKERN_NOT_FOUND=56',
dependencies : [ core_foundation, core_symbolication ],
install : sdk_version.version_compare('>=11'),
install : true,
sources : [
'zlog/SymbolicationHelper.c',
'zlog/zlog.c',
],
)
if sdk_version.version_compare('>=11')
install_man('zlog/zlog.1')
endif
install_man('zlog/zlog.1')
executable(
'zprint',
@@ -51,6 +51,9 @@ let
chmod -R u+w "$out/include/dispatch"
find "$out/include/dispatch" -name '*.h' -exec sed -i {} -e 's/, bridgeos([^)]*)//g' \;
install -D -t "$out/include/System/i386" \
'${xnu}/osfmk/i386/cpu_capabilities.h'
install -D -t "$out/include/kern" \
'${xnu}/osfmk/kern/debug.h'
@@ -81,11 +84,6 @@ mkAppleDerivation {
xcodeHash = "sha256-gdtn3zNIneZKy6+X0mQ51CFVLNM6JQYLbd/lotG5/Tw=";
patches = [
# Use availability checks to fall back to older APIs on older macOS versions.
./patches/0001-Add-availability-checks-to-vm_purgeable_stat.patch
];
postPatch = ''
# Replace hard-coded, impure system paths with the output path in the store.
sed -e "s|PATH=[^;]*|PATH='$out/bin'|" -i "pagesize/pagesize.sh"
@@ -1,42 +0,0 @@
From 18a676bc44a8bc24374ab35a258a18049b56b6d4 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Mon, 2 Sep 2024 21:46:34 -0400
Subject: [PATCH] Add availability checks to vm_purgeable_stat
---
vm_purgeable_stat/vm_purgeable_stat.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vm_purgeable_stat/vm_purgeable_stat.c b/vm_purgeable_stat/vm_purgeable_stat.c
index 330704d..9d9041b 100644
--- a/vm_purgeable_stat/vm_purgeable_stat.c
+++ b/vm_purgeable_stat/vm_purgeable_stat.c
@@ -88,7 +88,11 @@ int get_task_from_pid(int pid, task_t *task)
fprintf(stderr, "%s\n", PRIV_ERR_MSG);
return -1;
}
- kr = task_inspect_for_pid(mach_task_self(), pid, task);
+ if (__builtin_available(macOS 11.3, *)) {
+ kr = task_inspect_for_pid(mach_task_self(), pid, task);
+ } else {
+ kr = task_for_pid(mach_task_self(), pid, task);
+ }
if (kr != KERN_SUCCESS) {
fprintf(stderr, "Failed to get task port for pid: %d\n", pid);
return -1;
@@ -128,7 +132,11 @@ int get_system_tasks(task_array_t *tasks, mach_msg_type_number_t *count)
vm_deallocate(mach_task_self(), (vm_address_t)psets, (vm_size_t)psetCount * sizeof(mach_port_t));
/* convert the processor-set-priv to a list of tasks for the processor set */
- ret = processor_set_tasks_with_flavor(pset_priv, TASK_FLAVOR_INSPECT, tasks, count);
+ if (__builtin_available(macOS 11.0, *)) {
+ ret = processor_set_tasks_with_flavor(pset_priv, TASK_FLAVOR_INSPECT, tasks, count);
+ } else {
+ ret = processor_set_tasks(pset_priv, tasks, count);
+ }
if (ret != KERN_SUCCESS) {
fprintf(stderr, "processor_set_tasks_with_flavor() failed: %s\n", mach_error_string(ret));
return -1;
--
2.44.1