From 2476801613a293d7810c5faf2e3383a653b1389c Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Sun, 17 Mar 2013 13:30:12 -0500 Subject: Hardware: separate out CPU values into CPU module * CPU functions now exist in Hardware::CPU * Added compatibility functions in compat/hardware_compat.rb * Names are less specific to Mac hardware, e.g. CPU.family instead of Hardware.intel_family * Hardware::CPU.family works for both Intel and PowerPC * New helper methods on CPU, like .sse4? and .altivec? Signed-off-by: Misty De Meo --- Library/Homebrew/os/linux/hardware.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Library/Homebrew/os/linux') diff --git a/Library/Homebrew/os/linux/hardware.rb b/Library/Homebrew/os/linux/hardware.rb index 8fd4b09b9..9dc454956 100644 --- a/Library/Homebrew/os/linux/hardware.rb +++ b/Library/Homebrew/os/linux/hardware.rb @@ -1,6 +1,9 @@ -module LinuxHardware - def cpu_type - @@cpu_type ||= case `uname -m` +module LinuxCPUs + OPTIMIZATION_FLAGS = {} + def optimization_flags; OPTIMIZATION_FLAGS.dup; end + + def type + @cpu_type ||= case `uname -m` when /x86_64/ :intel when /i386/ @@ -10,16 +13,21 @@ module LinuxHardware end end - def intel_family + def family :dunno end + alias_method :intel_family, :cpu_family - def processor_count + def cores `grep -c ^processor /proc/cpuinfo`.to_i end + def bits + is_64_bit? ? 64 : 32 + end + def is_64_bit? - return @@is_64_bit if defined? @@is_64_bit - @@is_64_bit = /64/ === `uname -m` + return @is_64_bit if defined? @is_64_bit + @is_64_bit = /64/ === `uname -m` end end -- cgit v1.2.3