Skip to content

Commit

Permalink
x/sys/windows: use SyscallN in mkwinsyscall
Browse files Browse the repository at this point in the history
The mkwinsyscall command has a hard limit of 15 on the
number of syscall arguments. Windows has several system
calls with more than 15 arguments, for example CreateFontPackage
has 18 arguments.

If the number of arguments is higher than 15 we use SyscallN.

Updates golang/go#57914
  • Loading branch information
mauri870 committed Aug 12, 2023
1 parent 552c4e8 commit e1f3de4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions windows/mkwinsyscall/mkwinsyscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import (
"go/parser"
"go/token"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -568,6 +567,8 @@ func (f *Fn) SyscallParamCount() int {
return 12
case n <= 15:
return 15
case n <= 42: // current SyscallN limit
return n
default:
panic("too many arguments to system call")
}
Expand All @@ -578,6 +579,8 @@ func (f *Fn) Syscall() string {
c := f.SyscallParamCount()
if c == 3 {
return syscalldot() + "Syscall"
} else if c > 15 {
return syscalldot() + "SyscallN"
}
return syscalldot() + "Syscall" + strconv.Itoa(c)
}
Expand Down Expand Up @@ -923,7 +926,7 @@ func main() {
if *filename == "" {
_, err = os.Stdout.Write(data)
} else {
err = ioutil.WriteFile(*filename, data, 0644)
err = os.WriteFile(*filename, data, 0644)
}
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -1011,7 +1014,7 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{if le .ParamCount 15}}{{.ParamCount}},{{end}} {{.SyscallParamList}}){{end}}
{{define "tmpvarsreadback"}}{{range .Params}}{{if .TmpVarReadbackCode}}
{{.TmpVarReadbackCode}}{{end}}{{end}}{{end}}
Expand Down

0 comments on commit e1f3de4

Please sign in to comment.