Skip to content

Commit

Permalink
Consolidate struct definition (#229)
Browse files Browse the repository at this point in the history
The struct on Cgo non-amd64 and non-arm64 platforms didn't have the struct fields updated. To avoid forgetting to update all the structs I've moved it where every platform shares the same type def.

Closes #228
  • Loading branch information
TotallyGamerJet authored Apr 7, 2024
1 parent 5438b70 commit 0e63021
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
6 changes: 6 additions & 0 deletions syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const (
numOfFloats = 8 // arm64 and amd64 both have 8 float registers
)

type syscall15Args struct {
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr
f1, f2, f3, f4, f5, f6, f7, f8 uintptr
arm64_r8 uintptr
}

// SyscallN takes fn, a C function pointer and a list of arguments as uintptr.
// There is an internal maximum number of arguments that SyscallN can take. It panics
// when the maximum is exceeded. It returns the result and the libc error code if there is one.
Expand Down
8 changes: 0 additions & 8 deletions syscall_cgo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ import (

var syscall15XABI0 = uintptr(cgo.Syscall15XABI0)

// this is only here to make the assembly files happy :)
type syscall15Args struct {
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr
f1, f2, f3, f4, f5, f6, f7, f8 uintptr
r1, r2, err uintptr
arm64_r8 uintptr
}

//go:nosplit
func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
Expand Down
6 changes: 0 additions & 6 deletions syscall_sysv.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import (

var syscall15XABI0 uintptr

type syscall15Args struct {
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr
f1, f2, f3, f4, f5, f6, f7, f8 uintptr
arm64_r8 uintptr
}

//go:nosplit
func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
args := syscall15Args{
Expand Down
6 changes: 0 additions & 6 deletions syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import (

var syscall15XABI0 uintptr

type syscall15Args struct {
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr
f1, f2, f3, f4, f5, f6, f7, f8 uintptr
arm64_r8 uintptr
}

func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
r1, r2, errno := syscall.Syscall15(fn, 15, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
return r1, r2, uintptr(errno)
Expand Down

0 comments on commit 0e63021

Please sign in to comment.