Skip to content

Commit e7e99a8

Browse files
committed
syscall: add support for openbsd/ppc64
Add syscall support for the openbsd/ppc64 port. Updates #56001 Change-Id: I695c5c296e90645515de0c8f89f1bc57e976679d Reviewed-on: https://go-review.googlesource.com/c/go/+/475636 Reviewed-by: Eric Grosse <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Joel Sing <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent c140105 commit e7e99a8

10 files changed

+4784
-36
lines changed

src/syscall/asm_openbsd_ppc64.s

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2023 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
#include "textflag.h"
6+
7+
//
8+
// System call support for PPC64, OpenBSD
9+
//
10+
11+
// Provide these function names via assembly so they are provided as ABI0,
12+
// rather than ABIInternal.
13+
14+
// func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
15+
TEXT ·Syscall(SB),NOSPLIT,$0-56
16+
JMP ·syscallInternal(SB)
17+
18+
// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
19+
TEXT ·Syscall6(SB),NOSPLIT,$0-80
20+
JMP ·syscall6Internal(SB)
21+
22+
// func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
23+
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
24+
JMP ·rawSyscallInternal(SB)
25+
26+
// func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
27+
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28+
JMP ·rawSyscall6Internal(SB)
29+
30+
// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
31+
TEXT ·Syscall9(SB),NOSPLIT,$0-104
32+
JMP ·syscall9Internal(SB)

src/syscall/mkall.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,18 @@ openbsd_mips64)
355355
# API consistent between platforms.
356356
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
357357
;;
358+
openbsd_ppc64)
359+
GOOSARCH_in="syscall_openbsd_libc.go syscall_openbsd_$GOARCH.go"
360+
mkerrors="$mkerrors -m64"
361+
mksyscall="./mksyscall.pl -openbsd -libc"
362+
mksysctl="./mksysctl_openbsd.pl"
363+
zsysctl="zsysctl_openbsd.go"
364+
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
365+
# Let the type of C char be signed to make the bare syscall
366+
# API consistent between platforms.
367+
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
368+
mkasm="go run mkasm.go"
369+
;;
358370
plan9_386)
359371
mkerrors=
360372
mksyscall="./mksyscall.pl -l32 -plan9"

src/syscall/mkasm.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ func main() {
5454
if !trampolines[fn] {
5555
trampolines[fn] = true
5656
fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
57-
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
57+
if goos == "openbsd" && arch == "ppc64" {
58+
fmt.Fprintf(&out, "\tCALL\t%s(SB)\n", fn)
59+
fmt.Fprintf(&out, "\tRET\n")
60+
} else {
61+
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
62+
}
5863
}
5964
}
6065
err = os.WriteFile(fmt.Sprintf("zsyscall_%s_%s.s", goos, arch), out.Bytes(), 0644)

src/syscall/syscall_openbsd_ppc64.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2023 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package syscall
6+
7+
func setTimespec(sec, nsec int64) Timespec {
8+
return Timespec{Sec: sec, Nsec: nsec}
9+
}
10+
11+
func setTimeval(sec, usec int64) Timeval {
12+
return Timeval{Sec: sec, Usec: usec}
13+
}
14+
15+
func SetKevent(k *Kevent_t, fd, mode, flags int) {
16+
k.Ident = uint64(fd)
17+
k.Filter = int16(mode)
18+
k.Flags = uint16(flags)
19+
}
20+
21+
func (iov *Iovec) SetLen(length int) {
22+
iov.Len = uint64(length)
23+
}
24+
25+
func (msghdr *Msghdr) SetControllen(length int) {
26+
msghdr.Controllen = uint32(length)
27+
}
28+
29+
func (cmsg *Cmsghdr) SetLen(length int) {
30+
cmsg.Len = uint32(length)
31+
}
32+
33+
// RTM_LOCK only exists in OpenBSD 6.3 and earlier.
34+
const RTM_LOCK = 0x8
35+
36+
// SYS___SYSCTL only exists in OpenBSD 5.8 and earlier, when it was
37+
// was renamed to SYS_SYSCTL.
38+
const SYS___SYSCTL = SYS_SYSCTL

0 commit comments

Comments
 (0)