MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / GetCpuArchitecture

Method GetCpuArchitecture

internal/system/system_386.go:7–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5)
6
7func (s *System) GetCpuArchitecture() (string, error) {
8 // Check if we are on i686; otherwiese we know it is i586 with MMX as Go does require MMX instructions
9 isI686 := hasCMOV()
10 // We need to check for LM (Long Mode) as there are CPUs that support SSE2 but not x86_64 (e.g. Core Duo)
11 isX86_64 := isI686 && hasLM() && cpu.X86.HasSSE2
12 isX86_64V2 := isX86_64 && cpu.X86.HasPOPCNT && cpu.X86.HasSSE3 && cpu.X86.HasSSE41 && cpu.X86.HasSSE42 && cpu.X86.HasSSSE3
13 isX86_64V3 := isX86_64V2 && cpu.X86.HasAVX && cpu.X86.HasAVX2 && cpu.X86.HasBMI1 && cpu.X86.HasBMI2 && cpu.X86.HasFMA && cpu.X86.HasOSXSAVE
14 isX86_64V4 := isX86_64V3 && cpu.X86.HasAVX512F && cpu.X86.HasAVX512BW && cpu.X86.HasAVX512CD && cpu.X86.HasAVX512DQ && cpu.X86.HasAVX512VL
15
16 switch {
17 case isX86_64V4:
18 return X86_64_V4, nil
19 case isX86_64V3:
20 return X86_64_V3, nil
21 case isX86_64V2:
22 return X86_64_V2, nil
23 case isX86_64:
24 return X86_64, nil
25 case isI686:
26 return I686, nil
27 default:
28 return I586, nil
29 }
30}
31
32// Implemented at system_386.s
33func hasLM() bool

Callers 6

validateSubmitRequestFunction · 0.95
TestShowArchitectureFunction · 0.95
newArchitectureCmdFunction · 0.95
newSystemArchitectureCmdFunction · 0.95

Calls 2

hasCMOVFunction · 0.85
hasLMFunction · 0.85

Tested by 4

validateSubmitRequestFunction · 0.76
TestShowArchitectureFunction · 0.76