Module: OS::Mac::Hardware::CPU 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

#familyObject

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.



25
26
27
28
29
30
31
32
33
# File 'extend/os/mac/hardware/cpu.rb', line 25

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

#featuresObject

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.



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

def features
  @features ||= ::Hardware::CPU.sysctl_n(
    "machdep.cpu.features",
    "machdep.cpu.extfeatures",
    "machdep.cpu.leaf7_features",
  ).split.map { |s| s.downcase.to_sym }
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)


39
40
41
# File 'extend/os/mac/hardware/cpu.rb', line 39

def in_rosetta2?
  ::Hardware::CPU.sysctl_bool("sysctl.proc_translated")
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)


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

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

#typeObject

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 for decoding info.



14
15
16
17
18
19
20
21
22
23
# File 'extend/os/mac/hardware/cpu.rb', line 14

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