Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysinfo: check if cpu has split lock detection flag #289

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/vinegar/vinegar.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ func Sysinfo(pfx *wine.Prefix) {
* Distro: %s
* Processor: %s
* Supports AVX: %t
* Supports split lock detection: %t
* Kernel: %s
* Wine: %s`

fmt.Printf(info, Version, revision, sysinfo.Distro, sysinfo.CPU, sysinfo.HasAVX, sysinfo.Kernel, ver)
fmt.Printf(info, Version, revision, sysinfo.Distro, sysinfo.CPU.Name, sysinfo.CPU.AVX, sysinfo.CPU.SplitLockDetect, sysinfo.Kernel, ver)
if sysinfo.InFlatpak {
fmt.Println("* Flatpak: [x]")
}
Expand Down
26 changes: 23 additions & 3 deletions sysinfo/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ import (
"bufio"
"os"
"regexp"
"strings"

cpulib "golang.org/x/sys/cpu"
)

func cpuModel() string {
type cpu struct {
Name string
AVX bool
SplitLockDetect bool
}

func getCPU() cpu {
c := cpu{
Name: "unknown cpu",
AVX: cpulib.X86.HasAVX,
}

column := regexp.MustCompile("\t+: ")

f, _ := os.Open("/proc/cpuinfo")
Expand All @@ -24,9 +38,15 @@ func cpuModel() string {

// pfft, who needs multiple cpus? just return if we got all we need
if sl[0] == "model name" {
return sl[1]
c.Name = sl[1]
}

if sl[0] == "flags" {
c.SplitLockDetect = strings.Contains(sl[1], "split_lock_detect")
break
}

}

return "unknown cpu"
return c
}
7 changes: 2 additions & 5 deletions sysinfo/sysinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ package sysinfo

import (
"os"

"golang.org/x/sys/cpu"
)

var (
Kernel string
CPU string
CPU cpu
Cards []Card
Distro string
HasAVX = cpu.X86.HasAVX
InFlatpak bool
)

func init() {
Kernel = getKernel()
CPU = cpuModel()
CPU = getCPU()
Cards = getCards()
Distro = getDistro()

Expand Down
Loading