Module: Seccomp::Arch
- Defined in:
- lib/seccomp/arch.rb
Overview
Architecture tokens and name conversion.
Class Method Summary collapse
-
.all ⇒ Hash<Symbol, Integer>
Constants available in the linked header.
-
.name(token) ⇒ Symbol?
Known name.
-
.native ⇒ Integer
Native runtime architecture token.
-
.resolve(value) ⇒ Integer
Architecture token.
Class Method Details
.all ⇒ Hash<Symbol, Integer>
Returns constants available in the linked header.
10 11 12 13 14 |
# File 'lib/seccomp/arch.rb', line 10 def all @all ||= constants(false).grep_v(:NAMES).to_h do |name| [name.to_s.downcase.to_sym, const_get(name)] end.freeze end |
.name(token) ⇒ Symbol?
Returns known name.
44 45 46 |
# File 'lib/seccomp/arch.rb', line 44 def name(token) all.key(token) || (token == native ? all.key(native) : nil) end |
.native ⇒ Integer
Returns native runtime architecture token.
18 19 20 |
# File 'lib/seccomp/arch.rb', line 18 def native LowLevel.arch_native end |
.resolve(value) ⇒ Integer
Returns architecture token.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/seccomp/arch.rb', line 26 def resolve(value) return value if value.is_a?(Integer) unless value.respond_to?(:to_sym) raise ArgumentError, "unknown architecture: #{value.inspect}" end key = value.to_sym all.fetch(key) do token = LowLevel.arch_resolve_name(value.to_s) raise ArgumentError, "unknown architecture: #{value.inspect}" if token.zero? token end end |