Module: OS::Mac::Hardware::CPU::ClassMethods Private

Extended by:
T::Helpers
Defined in:
extend/os/mac/hardware/cpu.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#familySymbol

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



32
33
34
35
36
37
38
39
40
# File 'extend/os/mac/hardware/cpu.rb', line 32

def family
  if ::Hardware::CPU.arm?
    ::Hardware::CPU.arm_family
  elsif ::Hardware::CPU.intel?
    ::Hardware::CPU.intel_family
  else
    :dunno
  end
end

#featuresArray<Symbol>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



57
58
59
60
61
62
63
# File 'extend/os/mac/hardware/cpu.rb', line 57

def features
  @features ||= T.let(::Hardware::CPU.sysctl_n(
    "machdep.cpu.features",
    "machdep.cpu.extfeatures",
    "machdep.cpu.leaf7_features",
  ).split.map { |s| s.downcase.to_sym }, T.nilable(T::Array[Symbol]))
end

#in_rosetta2?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

True when running under an Intel-based shell via Rosetta 2 on an Apple Silicon Mac. This can be detected via seeing if there's a conflict between what uname reports and the underlying sysctl flags, since the sysctl flags don't change behaviour under Rosetta 2.

Returns:

  • (Boolean)


47
48
49
# File 'extend/os/mac/hardware/cpu.rb', line 47

def in_rosetta2?
  ::Hardware::CPU.sysctl_bool!("sysctl.proc_translated")
end

#rosetta_installed?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


52
53
54
# File 'extend/os/mac/hardware/cpu.rb', line 52

def rosetta_installed?
  File.exist?(::Hardware::CPU::ROSETTA_RUNTIME_PATH)
end

#sse4?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


66
67
68
# File 'extend/os/mac/hardware/cpu.rb', line 66

def sse4?
  ::Hardware::CPU.sysctl_bool!("hw.optional.sse4_1")
end

#typeSymbol

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

These methods use info spewed out by sysctl. Look in <mach/machine.h> for decoding info.

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'extend/os/mac/hardware/cpu.rb', line 20

def type
  case ::Hardware::CPU.sysctl_int("hw.cputype")
  when CPU_TYPE_I386
    :intel
  when CPU_TYPE_ARM64
    :arm
  else
    super
  end
end