This commit is contained in:
Alexey Chubar 2023-12-01 18:43:35 +03:00
parent 60e9ad293b
commit 3aeb5a23db
1 changed files with 19 additions and 0 deletions

View File

@ -1183,3 +1183,22 @@ function names_hash_changed(string $crc_file, array $names) : bool
ensure_write($crc_file, $names_crc); ensure_write($crc_file, $names_crc);
return $changed; return $changed;
} }
function is_apple_silicon()
{
$arch = php_uname('m');
// Check if the machine type contains 'arm' (ARM architecture)
if (strpos($arch, 'arm') !== false) {
return true;
}
// If running on x86_64, check for Apple Silicon using sysctl
// (because we might get 'x86_64' when running under Rosetta)
if ($arch === 'x86_64') {
$sysctl = shell_exec('sysctl -n machdep.cpu.brand_string');
return strpos($sysctl, 'Apple') !== false;
}
return false;
}