diff --git a/helpers.inc.php b/helpers.inc.php index 1153e64..f73e0e0 100644 --- a/helpers.inc.php +++ b/helpers.inc.php @@ -1183,3 +1183,22 @@ function names_hash_changed(string $crc_file, array $names) : bool ensure_write($crc_file, $names_crc); 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; +}