mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-30 05:46:45 -04:00
unix: add riscv_hwprobe for riscv64
The riscv_hwprobe system call was introduced in Linux 6.4 and allows the caller to determine a number of interesting pieces of information about the underlying RISC-V CPUs, e.g., which extensions they support and whether they allow fast unaligned memory accesses. For more information please see: https://docs.kernel.org/riscv/hwprobe.html We also update linux/mksysnum.go to ensure that the generated syscall constants written to the zsysnum_linux_*.go files are always sorted by their syscall numbers in ascending order. Updates golang/go#61416 Change-Id: Iedb0a86adb65faac9061b9a5969ffa09eb5b303a Reviewed-on: https://go-review.googlesource.com/c/sys/+/510795 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
@@ -112,6 +112,12 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if goos == "linux" && goarch != "riscv64" {
|
||||
// The RISCV_HWPROBE_ constants are only defined on Linux for riscv64
|
||||
hwprobeConstRexexp := regexp.MustCompile(`const\s+\(\s+RISCV_HWPROBE_[^\)]+\)`)
|
||||
b = hwprobeConstRexexp.ReplaceAll(b, nil)
|
||||
}
|
||||
|
||||
// Intentionally export __val fields in Fsid and Sigset_t
|
||||
valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__(bits|val)(\s+\S+\s+)}`)
|
||||
b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$4}"))
|
||||
@@ -138,6 +144,11 @@ func main() {
|
||||
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
|
||||
b = ptraceRexexp.ReplaceAll(b, nil)
|
||||
|
||||
// If we have an empty RISCVHWProbePairs struct, we should delete it. Only riscv64 emits
|
||||
// nonempty RISCVHWProbePairs structs.
|
||||
hwprobeRexexp := regexp.MustCompile(`type RISCVHWProbePairs struct {\s*}`)
|
||||
b = hwprobeRexexp.ReplaceAll(b, nil)
|
||||
|
||||
// Replace the control_regs union with a blank identifier for now.
|
||||
controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
|
||||
b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
|
||||
|
||||
Reference in New Issue
Block a user