Skip to content

Commit

Permalink
sysinfo: check if cpu has split lock detection flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jrelvas-ipc committed Nov 29, 2023
1 parent 8737a12 commit 15ea9c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
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, sysinfo.HasAVX, sysinfo.HasSplitLockDetect, sysinfo.Kernel, ver)
if sysinfo.InFlatpak {
fmt.Println("* Flatpak: [x]")
}
Expand Down
16 changes: 13 additions & 3 deletions sysinfo/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import (
"bufio"
"os"
"regexp"
"strings"
)

func cpuModel() string {
func cpuModel() (string, bool) {
column := regexp.MustCompile("\t+: ")

f, _ := os.Open("/proc/cpuinfo")
defer f.Close()

s := bufio.NewScanner(f)

n := "unknown cpu"
l := false

for s.Scan() {
sl := column.Split(s.Text(), 2)
if sl == nil {
Expand All @@ -24,9 +28,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]
n = sl[1]
}

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

}

return "unknown cpu"
return n, l
}
15 changes: 8 additions & 7 deletions sysinfo/sysinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import (
)

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

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

Expand Down

0 comments on commit 15ea9c4

Please sign in to comment.