aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorShaun Jackman2017-11-29 11:44:59 -0800
committerShaun Jackman2017-12-01 15:18:35 -0800
commit0ce7a74c585eb01df60f1e9d353825d90bd3d969 (patch)
treeffee0e421487ff3530f5d19a59e11ee577ddd327 /Library/Homebrew/extend
parent1b289226284d87c846825563624661ced315b11a (diff)
downloadbrew-0ce7a74c585eb01df60f1e9d353825d90bd3d969.tar.bz2
Hardware::CPU: Implement OS-agnostic methods
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/os/linux/hardware/cpu.rb28
-rw-r--r--Library/Homebrew/extend/os/mac/hardware/cpu.rb16
2 files changed, 3 insertions, 41 deletions
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
diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb
index a216db6ae..cc41ae911 100644
--- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb
+++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb
@@ -75,22 +75,6 @@ module Hardware
sysctl_int("machdep.cpu.extmodel")
end
- def cores
- sysctl_int("hw.ncpu")
- end
-
- def bits
- sysctl_bool("hw.cpu64bit_capable") ? 64 : 32
- end
-
- def arch_32_bit
- intel? ? :i386 : :ppc
- end
-
- def arch_64_bit
- intel? ? :x86_64 : :ppc64
- end
-
# Returns an array that's been extended with ArchitectureListExtension,
# which provides helpers like #as_arch_flags and #as_cmake_arch_flags.
def universal_archs