Module: Hardware

Defined in:
Library/Homebrew/hardware.rb,
Library/Homebrew/extend/os/mac/hardware.rb,
Library/Homebrew/extend/os/mac/hardware/cpu.rb,
Library/Homebrew/extend/os/linux/hardware/cpu.rb

Overview

Helper module for querying hardware information.

Defined Under Namespace

Classes: CPU

Class Method Summary collapse

Class Method Details

.cores_as_wordsObject


161
162
163
164
165
166
167
168
169
170
171
172
# File 'Library/Homebrew/hardware.rb', line 161

def cores_as_words
  case Hardware::CPU.cores
  when 1 then "single"
  when 2 then "dual"
  when 4 then "quad"
  when 6 then "hexa"
  when 8 then "octa"
  when 12 then "dodeca"
  else
    Hardware::CPU.cores
  end
end

.generic_oldest_cpuObject


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'Library/Homebrew/hardware.rb', line 197

def oldest_cpu(_version = nil)
  if Hardware::CPU.intel?
    if Hardware::CPU.is_64_bit?
      :core2
    else
      :core
    end
  elsif Hardware::CPU.arm?
    if Hardware::CPU.is_64_bit?
      :armv8
    else
      :armv6
    end
  elsif Hardware::CPU.ppc? && Hardware::CPU.is_64_bit?
    if Hardware::CPU.little_endian?
      :ppc64le
    else
      :ppc64
    end
  else
    Hardware::CPU.family
  end
end

.oldest_cpu(version = MacOS.version) ⇒ Object


174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'Library/Homebrew/hardware.rb', line 174

def oldest_cpu(_version = nil)
  if Hardware::CPU.intel?
    if Hardware::CPU.is_64_bit?
      :core2
    else
      :core
    end
  elsif Hardware::CPU.arm?
    if Hardware::CPU.is_64_bit?
      :armv8
    else
      :armv6
    end
  elsif Hardware::CPU.ppc? && Hardware::CPU.is_64_bit?
    if Hardware::CPU.little_endian?
      :ppc64le
    else
      :ppc64
    end
  else
    Hardware::CPU.family
  end
end