Skip to content

Commit fbc7d0a

Browse files
4a6f656cgopherbot
authored andcommitted
unix: convert openbsd/386 to direct libc calls
The current code has continued to work on OpenBSD, since it has been using syscall(2) via libc. However, the system call numbers are still hardcoded in golang.org/sys/unix. Various system call changes have been made in OpenBSD, resulting in changes to the system call numbers and arguments, which now fail when this package is used. Switch to calling various system calls directly via libc, rather than calling via libc using syscall(2). Updates golang/go#36435 Change-Id: Ib42d5415ef35c7f7b9cbc55adaf7ca15973ab287 Reviewed-on: https://go-review.googlesource.com/c/sys/+/421798 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 5f8f020 commit fbc7d0a

File tree

5 files changed

+1470
-139
lines changed

5 files changed

+1470
-139
lines changed

unix/mkall.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ netbsd_arm64)
142142
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
143143
;;
144144
openbsd_386)
145+
mkasm="go run mkasm.go"
145146
mkerrors="$mkerrors -m32"
146-
mksyscall="go run mksyscall.go -l32 -openbsd"
147+
mksyscall="go run mksyscall.go -l32 -openbsd -libc"
147148
mksysctl="go run mksysctl_openbsd.go"
148-
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
149149
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
150150
;;
151151
openbsd_amd64)

unix/syscall_openbsd_libc.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build (openbsd && amd64) || (openbsd && arm64)
6-
// +build openbsd,amd64 openbsd,arm64
5+
//go:build (openbsd && 386) || (openbsd && amd64) || (openbsd && arm64)
6+
// +build openbsd,386 openbsd,amd64 openbsd,arm64
77

88
package unix
99

@@ -12,10 +12,16 @@ import _ "unsafe"
1212
// Implemented in the runtime package (runtime/sys_openbsd3.go)
1313
func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
1414
func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
15+
func syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno)
1516
func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
1617
func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
1718

1819
//go:linkname syscall_syscall syscall.syscall
1920
//go:linkname syscall_syscall6 syscall.syscall6
21+
//go:linkname syscall_syscall10 syscall.syscall10
2022
//go:linkname syscall_rawSyscall syscall.rawSyscall
2123
//go:linkname syscall_rawSyscall6 syscall.rawSyscall6
24+
25+
func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) {
26+
return syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0)
27+
}

0 commit comments

Comments
 (0)