diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2022-08-26 12:09:34 +0200 |
|---|---|---|
| committer | Tobias Klauser <tobias.klauser@gmail.com> | 2022-08-31 16:59:38 +0000 |
| commit | 0d6a7f9d2eb2e5e9b96cd1b144d122f6eb5aac81 (patch) | |
| tree | 0a0d9741b6f3159a9cd38511445e6ebe0979c93c /src/internal/syscall | |
| parent | 59b15726d113324d0c91d8aae559e9fb7cb04495 (diff) | |
| download | go-0d6a7f9d2eb2e5e9b96cd1b144d122f6eb5aac81.tar.xz | |
internal/poll, internal/syscall/unix, net, runtime: convert openbsd (except mips64) to direct libc calls
Call libc wrappers directly rather than calling using syscall(2).
Updates golang/go#36435
Change-Id: I40be410c7472f7d89cbec2ebdc7c841c7726ca4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425637
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Diffstat (limited to 'src/internal/syscall')
| -rw-r--r-- | src/internal/syscall/unix/at.go | 2 | ||||
| -rw-r--r-- | src/internal/syscall/unix/at_fstatat.go | 2 | ||||
| -rw-r--r-- | src/internal/syscall/unix/at_libc2.go (renamed from src/internal/syscall/unix/at_darwin.go) | 2 | ||||
| -rw-r--r-- | src/internal/syscall/unix/getentropy_openbsd.go | 24 | ||||
| -rw-r--r-- | src/internal/syscall/unix/getentropy_openbsd_mips64.go | 25 | ||||
| -rw-r--r-- | src/internal/syscall/unix/nonblocking.go | 2 | ||||
| -rw-r--r-- | src/internal/syscall/unix/nonblocking_libc.go | 2 |
7 files changed, 39 insertions, 20 deletions
diff --git a/src/internal/syscall/unix/at.go b/src/internal/syscall/unix/at.go index 965162e3d2..876ca9ff57 100644 --- a/src/internal/syscall/unix/at.go +++ b/src/internal/syscall/unix/at.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux || openbsd || netbsd || dragonfly +//go:build dragonfly || linux || netbsd || (openbsd && mips64) package unix diff --git a/src/internal/syscall/unix/at_fstatat.go b/src/internal/syscall/unix/at_fstatat.go index 25318d2014..8f25fe9f64 100644 --- a/src/internal/syscall/unix/at_fstatat.go +++ b/src/internal/syscall/unix/at_fstatat.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (linux && !loong64) || openbsd || netbsd || dragonfly +//go:build dragonfly || (linux && !loong64) || netbsd || (openbsd && mips64) package unix diff --git a/src/internal/syscall/unix/at_darwin.go b/src/internal/syscall/unix/at_libc2.go index a88a27e0c6..93d0cf4443 100644 --- a/src/internal/syscall/unix/at_darwin.go +++ b/src/internal/syscall/unix/at_libc2.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || (openbsd && !mips64) + package unix import ( diff --git a/src/internal/syscall/unix/getentropy_openbsd.go b/src/internal/syscall/unix/getentropy_openbsd.go index d5caa8095a..ad0914da90 100644 --- a/src/internal/syscall/unix/getentropy_openbsd.go +++ b/src/internal/syscall/unix/getentropy_openbsd.go @@ -1,25 +1,17 @@ -// Copyright 2016 The Go Authors. All rights reserved. +// Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package unix +//go:build openbsd && !mips64 -import ( - "syscall" - "unsafe" -) +package unix -// getentropy(2)'s syscall number, from /usr/src/sys/kern/syscalls.master -const entropyTrap uintptr = 7 +import _ "unsafe" // for linkname // GetEntropy calls the OpenBSD getentropy system call. func GetEntropy(p []byte) error { - _, _, errno := syscall.Syscall(entropyTrap, - uintptr(unsafe.Pointer(&p[0])), - uintptr(len(p)), - 0) - if errno != 0 { - return errno - } - return nil + return getentropy(p) } + +//go:linkname getentropy syscall.getentropy +func getentropy(p []byte) error diff --git a/src/internal/syscall/unix/getentropy_openbsd_mips64.go b/src/internal/syscall/unix/getentropy_openbsd_mips64.go new file mode 100644 index 0000000000..d5caa8095a --- /dev/null +++ b/src/internal/syscall/unix/getentropy_openbsd_mips64.go @@ -0,0 +1,25 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import ( + "syscall" + "unsafe" +) + +// getentropy(2)'s syscall number, from /usr/src/sys/kern/syscalls.master +const entropyTrap uintptr = 7 + +// GetEntropy calls the OpenBSD getentropy system call. +func GetEntropy(p []byte) error { + _, _, errno := syscall.Syscall(entropyTrap, + uintptr(unsafe.Pointer(&p[0])), + uintptr(len(p)), + 0) + if errno != 0 { + return errno + } + return nil +} diff --git a/src/internal/syscall/unix/nonblocking.go b/src/internal/syscall/unix/nonblocking.go index 9e5f0fb4a2..a0becd1e01 100644 --- a/src/internal/syscall/unix/nonblocking.go +++ b/src/internal/syscall/unix/nonblocking.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || freebsd || linux || netbsd || openbsd +//go:build dragonfly || freebsd || linux || netbsd || (openbsd && mips64) package unix diff --git a/src/internal/syscall/unix/nonblocking_libc.go b/src/internal/syscall/unix/nonblocking_libc.go index 84940714c3..bff6684962 100644 --- a/src/internal/syscall/unix/nonblocking_libc.go +++ b/src/internal/syscall/unix/nonblocking_libc.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build aix || darwin || solaris +//go:build aix || darwin || (openbsd && !mips64) || solaris package unix |
