From 0ce7a74c585eb01df60f1e9d353825d90bd3d969 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Wed, 29 Nov 2017 11:44:59 -0800 Subject: Hardware::CPU: Implement OS-agnostic methods --- Library/Homebrew/extend/os/linux/hardware/cpu.rb | 28 +++--------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'Library/Homebrew/extend/os/linux') diff --git a/Library/Homebrew/extend/os/linux/hardware/cpu.rb b/Library/Homebrew/extend/os/linux/hardware/cpu.rb index 8bf67bec8..0c1078fdf 100644 --- a/Library/Homebrew/extend/os/linux/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/linux/hardware/cpu.rb @@ -1,26 +1,13 @@ module Hardware class CPU class << self - def universal_archs - [].extend ArchitectureListExtension - end - def cpuinfo @cpuinfo ||= File.read("/proc/cpuinfo") end - def type - @type ||= if cpuinfo =~ /Intel|AMD/ - :intel - elsif cpuinfo =~ /ARM|Marvell/ - :arm - else - :dunno - end - end - def family return :arm if arm? + return :ppc if ppc? 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 @@ -70,12 +57,9 @@ module Hardware end end - def cores - cpuinfo.scan(/^processor/).size - end - def flags - @flags ||= cpuinfo[/^(flags|Features).*/, 0].split + @flags ||= cpuinfo[/^(flags|Features).*/, 0]&.split + @flags ||= [] end # Compatibility with Mac method, which returns lowercase symbols @@ -95,12 +79,6 @@ module Hardware def sse4? flags.include? "sse4_1" end - - alias is_64_bit? lm? - - def bits - is_64_bit? ? 64 : 32 - end end end end -- cgit v1.2.3