diff options
| author | Misty De Meo | 2014-06-21 21:57:03 -0700 |
|---|---|---|
| committer | Misty De Meo | 2014-06-21 21:59:51 -0700 |
| commit | 07660bb7b6066c4c87afee1b5876dae3b348ec1d (patch) | |
| tree | 0bc3a1c1e03b377954a2db2766a64d9ff72c9355 /Library | |
| parent | d9e73c9d43c37f7f03bb1e81baae161b708b9ec6 (diff) | |
| download | brew-07660bb7b6066c4c87afee1b5876dae3b348ec1d.tar.bz2 | |
Hardware: add new .features method
This returns a list of symbols with the various CPU features supported
by the active hardware.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/os/linux/hardware.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/hardware.rb | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Library/Homebrew/os/linux/hardware.rb b/Library/Homebrew/os/linux/hardware.rb index 84a13cc03..507639e3a 100644 --- a/Library/Homebrew/os/linux/hardware.rb +++ b/Library/Homebrew/os/linux/hardware.rb @@ -36,6 +36,12 @@ module LinuxCPUs @flags ||= cpuinfo[/^flags.*/, 0].split end + # Compatibility with Mac method, which returns lowercase symbols + # instead of strings + def features + @features ||= flags[1..-1].map(&:intern) + end + %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each { |flag| define_method(flag + "?") { flags.include? flag } } diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb index 7bda71fa4..a6b5ccf2c 100644 --- a/Library/Homebrew/os/mac/hardware.rb +++ b/Library/Homebrew/os/mac/hardware.rb @@ -98,6 +98,12 @@ module MacCPUs end end + def features + @features ||= `/usr/sbin/sysctl -n machdep.cpu.features`.split(" ").map do |s| + s.downcase.intern + end + end + def aes? sysctl_bool('hw.optional.aes') end |
