Skip to content

Commit

Permalink
sysinfo: check if cpu has split lock detection flag (#289)
Browse files Browse the repository at this point in the history
* sysinfo: check if cpu has split lock detection flag

* sysinfo: Consolidate cpu fields into struct

* sysinfo: (reluctantly) expanded cpu struct

* Revert "sysinfo: (reluctantly) expanded cpu struct"

This reverts commit de1159e.

wael moment

* sysinfo: implement cpu struct in a sane and non-awful way

* sysinfo: yet another cpu struct initialization change
when will the pain end
  • Loading branch information
jrelvas-ipc authored Nov 30, 2023
1 parent b59f430 commit 4b63ff9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cmd/vinegar/vinegar.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,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

0 comments on commit 4b63ff9

Please sign in to comment.