aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-07-29 20:02:26 -0600
committerMike McQuaid2016-07-29 21:21:02 -0600
commit5566757f60a66337644eba11d92821d0938da5bd (patch)
tree908a3fed9d906ff1ccea3fd380f9fd4c5c2cfd3b /Library
parent696f497e3224f0ff4d91895f819de3325aa44e20 (diff)
downloadbrew-5566757f60a66337644eba11d92821d0938da5bd.tar.bz2
linux/hardware/cpu: import family from Linuxbrew.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/os/linux/hardware/cpu.rb46
1 files changed, 44 insertions, 2 deletions
diff --git a/Library/Homebrew/extend/os/linux/hardware/cpu.rb b/Library/Homebrew/extend/os/linux/hardware/cpu.rb
index d8c281bfc..2e5b3d07d 100644
--- a/Library/Homebrew/extend/os/linux/hardware/cpu.rb
+++ b/Library/Homebrew/extend/os/linux/hardware/cpu.rb
@@ -18,9 +18,51 @@ module Hardware
end
def family
- cpuinfo[/^cpu family\s*: ([0-9]+)/, 1].to_i
+ return :arm if arm?
+ return :dunno unless intel?
+ # See https://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers
+ cpu_family = cpuinfo[/^cpu family\s*: ([0-9]+)/, 1].to_i
+ cpu_model = cpuinfo[/^model\s*: ([0-9]+)/, 1].to_i
+ cpu_family_model = "0x" + ((cpu_family << 8) | cpu_model).to_s(16)
+ case cpu_family
+ when 0x06
+ case cpu_model
+ when 0x3a, 0x3e
+ :ivybridge
+ when 0x2a, 0x2d
+ :sandybridge
+ when 0x25, 0x2c, 0x2f
+ :westmere
+ when 0x1e, 0x1a, 0x2e
+ :nehalem
+ when 0x17, 0x1d
+ :penryn
+ when 0x0f, 0x16
+ :merom
+ when 0x0d
+ :dothan
+ when 0x36, 0x26, 0x1c
+ :atom
+ when 0x3c, 0x3f, 0x46
+ :haswell
+ when 0x3d, 0x47, 0x4f, 0x56
+ :broadwell
+ else
+ cpu_family_model
+ end
+ when 0x0f
+ case cpu_model
+ when 0x06
+ :presler
+ when 0x03, 0x04
+ :prescott
+ else
+ cpu_family_model
+ end
+ else
+ cpu_family_model
+ end
end
- alias_method :intel_family, :family
def cores
cpuinfo.scan(/^processor/).size