Add Hardware::CPU.intel? and Hardware::CPU.ppc?

This commit is contained in:
Jack Nagel 2013-11-26 20:23:19 -06:00
parent 48e8be2454
commit cb18b9e77e
2 changed files with 15 additions and 9 deletions

View File

@ -30,6 +30,14 @@ class Hardware
def is_64_bit? def is_64_bit?
bits == 64 bits == 64
end end
def intel?
type == :intel
end
def ppc?
type == :ppc
end
end end
if OS.mac? if OS.mac?
@ -53,7 +61,7 @@ class Hardware
end end
def self.oldest_cpu def self.oldest_cpu
if Hardware::CPU.type == :intel if Hardware::CPU.intel?
if Hardware::CPU.is_64_bit? if Hardware::CPU.is_64_bit?
:core2 :core2
else else

View File

@ -27,9 +27,8 @@ module MacCPUs
end end
def family def family
if type == :intel if intel?
@intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i case @intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i
case @intel_family
when 0x73d67300 # Yonah: Core Solo/Duo when 0x73d67300 # Yonah: Core Solo/Duo
:core :core
when 0x426f69ef # Merom: Core 2 Duo when 0x426f69ef # Merom: Core 2 Duo
@ -49,9 +48,8 @@ module MacCPUs
else else
:dunno :dunno
end end
elsif type == :ppc elsif ppc?
@ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i case @ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i
case @ppc_family
when 9 when 9
:g3 # PowerPC 750 :g3 # PowerPC 750
when 10 when 10
@ -81,11 +79,11 @@ module MacCPUs
end end
def arch_32_bit def arch_32_bit
type == :intel ? :i386 : :ppc intel? ? :i386 : :ppc
end end
def arch_64_bit def arch_64_bit
type == :intel ? :x86_64 : :ppc64 intel? ? :x86_64 : :ppc64
end end
# Returns an array that's been extended with ArchitectureListExtension, # Returns an array that's been extended with ArchitectureListExtension,