hardware: more porting to generic layer.

This commit is contained in:
Mike McQuaid 2016-07-16 21:05:07 +01:00
parent 270b0ec783
commit 892a3239bc
2 changed files with 15 additions and 4 deletions

View File

@ -28,7 +28,11 @@ module Hardware
end end
def type def type
:dunno case RUBY_PLATFORM
when /x86_64/, /i\d86/ then :intel
when /ppc\d+/ then :ppc
else :dunno
end
end end
def family def family
@ -40,7 +44,14 @@ module Hardware
end end
def bits def bits
64 case RUBY_PLATFORM
when /x86_64/, /ppc64/ then 64
when /i\d86/, /ppc/ then 32
end
end
def sse4?
RUBY_PLATFORM.to_s.include?("x86_64")
end end
def is_32_bit? def is_32_bit?

View File

@ -3,11 +3,11 @@ require "hardware"
class HardwareTests < Homebrew::TestCase class HardwareTests < Homebrew::TestCase
def test_hardware_cpu_type def test_hardware_cpu_type
assert_includes [:intel, :ppc], Hardware::CPU.type assert_includes [:intel, :ppc, :dunno], Hardware::CPU.type
end end
def test_hardware_intel_family def test_hardware_intel_family
families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake] families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :dunno]
assert_includes families, Hardware::CPU.family assert_includes families, Hardware::CPU.family
end if Hardware::CPU.intel? end if Hardware::CPU.intel?
end end