/** * Function that attempts to return the kind of CPU. * @return string CPU kind ('amd', 'intel' or 'ppc'). */ protected static function _getCPU() { if (self::$_cpu == '') { switch (self::_getOS()) { case 'lin': // TODO: use uname -m or -a, by the way, this is about 32bit vs 64bit not amd vs intel! if (`grep -i amd /proc/cpuinfo` != '') { self::$_cpu = 'amd'; } elseif (`grep -i intel /proc/cpuinfo` != '') { self::$_cpu = 'intel'; } break; case 'osx': // TODO: use uname -m or -a if (`machine | grep -i ppc` != '') { self::$_cpu = 'ppc'; } elseif (`machine | grep -i i` != '') { self::$_cpu = 'intel'; } break; case 'win': $cpu = strtolower(getenv('PROCESSOR_IDENTIFIER')); if (strpos($cpu, 'intel') !== false) { self::$_cpu = 'intel'; } if (strpos($cpu, 'amd') !== false) { self::$_cpu = 'amd'; } break; default: throw new Exception('WKPDF CPU detection on ' . self::_getOS() . ' OS not supported.'); break; } if (self::$_cpu == '') { throw new Exception('WKPDF couldn\'t determine CPU (' . self::_getOS() . ' OS).'); } } return self::$_cpu; }
private static function _getCPU() { if (self::$_cpu == '') { $arch = `uname -m`; if (preg_match("/^x(86_)*64\$/", $arch)) { self::$_cpu = 'amd64'; } elseif (preg_match("/^(i[3-6]|x)86\$/", $arch)) { self::$_cpu = 'i386'; } else { throw new Exception('WKPDF couldn\'t determine CPU ("' . `grep -i vendor_id /proc/cpuinfo` . '").'); } } return self::$_cpu; }