Hardware: add new .features method
This returns a list of symbols with the various CPU features supported by the active hardware.
This commit is contained in:
parent
d9e73c9d43
commit
07660bb7b6
@ -36,6 +36,12 @@ module LinuxCPUs
|
|||||||
@flags ||= cpuinfo[/^flags.*/, 0].split
|
@flags ||= cpuinfo[/^flags.*/, 0].split
|
||||||
end
|
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|
|
%w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each { |flag|
|
||||||
define_method(flag + "?") { flags.include? flag }
|
define_method(flag + "?") { flags.include? flag }
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,12 @@ module MacCPUs
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def features
|
||||||
|
@features ||= `/usr/sbin/sysctl -n machdep.cpu.features`.split(" ").map do |s|
|
||||||
|
s.downcase.intern
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def aes?
|
def aes?
|
||||||
sysctl_bool('hw.optional.aes')
|
sysctl_bool('hw.optional.aes')
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user