mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/runtime/syscall: rename to internal/runtime/syscall/linux
All code in internal/runtime/syscall is Linux-specific, so better move it to a new linux sub-directory. This way it will be easier to factor out runtime syscall code from other platforms, e.g. Windows. Updates #51087. Change-Id: Idd2a52444b33bf3ad576b47fd232e990cdc8ae75 Reviewed-on: https://go-review.googlesource.com/c/go/+/689155 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
592c2db868
commit
5c45fe1385
33 changed files with 70 additions and 71 deletions
|
|
@ -56,7 +56,7 @@ var runtimePkgs = []string{
|
||||||
"internal/runtime/math",
|
"internal/runtime/math",
|
||||||
"internal/runtime/strconv",
|
"internal/runtime/strconv",
|
||||||
"internal/runtime/sys",
|
"internal/runtime/sys",
|
||||||
"internal/runtime/syscall",
|
"internal/runtime/syscall/linux",
|
||||||
|
|
||||||
"internal/abi",
|
"internal/abi",
|
||||||
"internal/bytealg",
|
"internal/bytealg",
|
||||||
|
|
@ -94,7 +94,7 @@ var allowAsmABIPkgs = []string{
|
||||||
"syscall",
|
"syscall",
|
||||||
"internal/bytealg",
|
"internal/bytealg",
|
||||||
"internal/chacha8rand",
|
"internal/chacha8rand",
|
||||||
"internal/runtime/syscall",
|
"internal/runtime/syscall/linux",
|
||||||
"internal/runtime/startlinetest",
|
"internal/runtime/startlinetest",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ var depsRules = `
|
||||||
< internal/msan
|
< internal/msan
|
||||||
< internal/asan
|
< internal/asan
|
||||||
< internal/runtime/sys
|
< internal/runtime/sys
|
||||||
< internal/runtime/syscall
|
< internal/runtime/syscall/linux
|
||||||
< internal/runtime/atomic
|
< internal/runtime/atomic
|
||||||
< internal/runtime/exithook
|
< internal/runtime/exithook
|
||||||
< internal/runtime/gc
|
< internal/runtime/gc
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ package coverage
|
||||||
// slot: 6 path='internal/runtime/math' hard-coded id: 6
|
// slot: 6 path='internal/runtime/math' hard-coded id: 6
|
||||||
// slot: 7 path='internal/bytealg' hard-coded id: 7
|
// slot: 7 path='internal/bytealg' hard-coded id: 7
|
||||||
// slot: 8 path='internal/goexperiment'
|
// slot: 8 path='internal/goexperiment'
|
||||||
// slot: 9 path='internal/runtime/syscall' hard-coded id: 8
|
// slot: 9 path='internal/runtime/syscall/linux' hard-coded id: 8
|
||||||
// slot: 10 path='runtime' hard-coded id: 9
|
// slot: 10 path='runtime' hard-coded id: 9
|
||||||
// fatal error: runtime.addCovMeta
|
// fatal error: runtime.addCovMeta
|
||||||
//
|
//
|
||||||
|
|
@ -66,7 +66,7 @@ var rtPkgs = [...]string{
|
||||||
"internal/runtime/strconv",
|
"internal/runtime/strconv",
|
||||||
"internal/runtime/sys",
|
"internal/runtime/sys",
|
||||||
"internal/runtime/maps",
|
"internal/runtime/maps",
|
||||||
"internal/runtime/syscall",
|
"internal/runtime/syscall/linux",
|
||||||
"internal/runtime/cgroup",
|
"internal/runtime/cgroup",
|
||||||
"internal/stringslite",
|
"internal/stringslite",
|
||||||
"runtime",
|
"runtime",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ package cgroup
|
||||||
import (
|
import (
|
||||||
"internal/bytealg"
|
"internal/bytealg"
|
||||||
"internal/runtime/strconv"
|
"internal/runtime/strconv"
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -77,10 +77,10 @@ type CPU struct {
|
||||||
func (c CPU) Close() {
|
func (c CPU) Close() {
|
||||||
switch c.version {
|
switch c.version {
|
||||||
case V1:
|
case V1:
|
||||||
syscall.Close(c.quotaFD)
|
linux.Close(c.quotaFD)
|
||||||
syscall.Close(c.periodFD)
|
linux.Close(c.periodFD)
|
||||||
case V2:
|
case V2:
|
||||||
syscall.Close(c.quotaFD)
|
linux.Close(c.quotaFD)
|
||||||
default:
|
default:
|
||||||
throw("impossible cgroup version")
|
throw("impossible cgroup version")
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
|
||||||
case 1:
|
case 1:
|
||||||
n2 := copy(base[n:], v1QuotaFile)
|
n2 := copy(base[n:], v1QuotaFile)
|
||||||
path := base[:n+n2]
|
path := base[:n+n2]
|
||||||
quotaFD, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
|
quotaFD, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
// This may fail if this process was migrated out of
|
// This may fail if this process was migrated out of
|
||||||
// the cgroup found by FindCPU and that cgroup has been
|
// the cgroup found by FindCPU and that cgroup has been
|
||||||
|
|
@ -122,7 +122,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
|
||||||
|
|
||||||
n2 = copy(base[n:], v1PeriodFile)
|
n2 = copy(base[n:], v1PeriodFile)
|
||||||
path = base[:n+n2]
|
path = base[:n+n2]
|
||||||
periodFD, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
|
periodFD, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
// This may fail if this process was migrated out of
|
// This may fail if this process was migrated out of
|
||||||
// the cgroup found by FindCPU and that cgroup has been
|
// the cgroup found by FindCPU and that cgroup has been
|
||||||
|
|
@ -139,7 +139,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
|
||||||
case 2:
|
case 2:
|
||||||
n2 := copy(base[n:], v2MaxFile)
|
n2 := copy(base[n:], v2MaxFile)
|
||||||
path := base[:n+n2]
|
path := base[:n+n2]
|
||||||
maxFD, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
|
maxFD, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
// This may fail if this process was migrated out of
|
// This may fail if this process was migrated out of
|
||||||
// the cgroup found by FindCPU and that cgroup has been
|
// the cgroup found by FindCPU and that cgroup has been
|
||||||
|
|
@ -200,7 +200,7 @@ func readV1Number(fd int) (int64, error) {
|
||||||
//
|
//
|
||||||
// Always read from the beginning of the file to get a fresh value.
|
// Always read from the beginning of the file to get a fresh value.
|
||||||
var b [64]byte
|
var b [64]byte
|
||||||
n, errno := syscall.Pread(fd, b[:], 0)
|
n, errno := linux.Pread(fd, b[:], 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return 0, errSyscallFailed
|
return 0, errSyscallFailed
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ func readV2Limit(fd int) (float64, bool, error) {
|
||||||
//
|
//
|
||||||
// Always read from the beginning of the file to get a fresh value.
|
// Always read from the beginning of the file to get a fresh value.
|
||||||
var b [64]byte
|
var b [64]byte
|
||||||
n, errno := syscall.Pread(fd, b[:], 0)
|
n, errno := linux.Pread(fd, b[:], 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return 0, false, errSyscallFailed
|
return 0, false, errSyscallFailed
|
||||||
}
|
}
|
||||||
|
|
@ -345,8 +345,8 @@ func FindCPU(out []byte, scratch []byte) (int, Version, error) {
|
||||||
// Returns ErrNoCgroup if the process is not in a CPU cgroup.
|
// Returns ErrNoCgroup if the process is not in a CPU cgroup.
|
||||||
func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) {
|
func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) {
|
||||||
path := []byte("/proc/self/cgroup\x00")
|
path := []byte("/proc/self/cgroup\x00")
|
||||||
fd, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
|
fd, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
|
||||||
if errno == syscall.ENOENT {
|
if errno == linux.ENOENT {
|
||||||
return 0, 0, ErrNoCgroup
|
return 0, 0, ErrNoCgroup
|
||||||
} else if errno != 0 {
|
} else if errno != 0 {
|
||||||
return 0, 0, errSyscallFailed
|
return 0, 0, errSyscallFailed
|
||||||
|
|
@ -354,13 +354,13 @@ func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) {
|
||||||
|
|
||||||
// The relative path always starts with /, so we can directly append it
|
// The relative path always starts with /, so we can directly append it
|
||||||
// to the mount point.
|
// to the mount point.
|
||||||
n, version, err := parseCPURelativePath(fd, syscall.Read, out[:], scratch)
|
n, version, err := parseCPURelativePath(fd, linux.Read, out[:], scratch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syscall.Close(fd)
|
linux.Close(fd)
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall.Close(fd)
|
linux.Close(fd)
|
||||||
return n, version, nil
|
return n, version, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -489,19 +489,19 @@ func FindCPUMountPoint(out []byte, scratch []byte) (int, error) {
|
||||||
checkBufferSize(scratch, ParseSize)
|
checkBufferSize(scratch, ParseSize)
|
||||||
|
|
||||||
path := []byte("/proc/self/mountinfo\x00")
|
path := []byte("/proc/self/mountinfo\x00")
|
||||||
fd, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
|
fd, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
|
||||||
if errno == syscall.ENOENT {
|
if errno == linux.ENOENT {
|
||||||
return 0, ErrNoCgroup
|
return 0, ErrNoCgroup
|
||||||
} else if errno != 0 {
|
} else if errno != 0 {
|
||||||
return 0, errSyscallFailed
|
return 0, errSyscallFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := parseCPUMount(fd, syscall.Read, out, scratch)
|
n, err := parseCPUMount(fd, linux.Read, out, scratch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syscall.Close(fd)
|
linux.Close(fd)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
syscall.Close(fd)
|
linux.Close(fd)
|
||||||
|
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ type lineReader struct {
|
||||||
// remainder of the line skipped. See next for more details.
|
// remainder of the line skipped. See next for more details.
|
||||||
//
|
//
|
||||||
// read is the function used to read more bytes from fd. This is usually
|
// read is the function used to read more bytes from fd. This is usually
|
||||||
// internal/runtime/syscall.Read. Note that this follows syscall semantics (not
|
// internal/runtime/syscall/linux.Read. Note that this follows syscall semantics (not
|
||||||
// io.Reader), so EOF is indicated with n=0, errno=0.
|
// io.Reader), so EOF is indicated with n=0, errno=0.
|
||||||
func newLineReader(fd int, scratch []byte, read func(fd int, b []byte) (n int, errno uintptr)) *lineReader {
|
func newLineReader(fd int, scratch []byte, read func(fd int, b []byte) (n int, errno uintptr)) *lineReader {
|
||||||
return &lineReader{
|
return &lineReader{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AT_FDCWD = -0x64
|
AT_FDCWD = -0x64
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 6
|
SYS_CLOSE = 6
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 3
|
SYS_CLOSE = 3
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 6
|
SYS_CLOSE = 6
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 57
|
SYS_CLOSE = 57
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 57
|
SYS_CLOSE = 57
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//go:build linux && (mips64 || mips64le)
|
//go:build linux && (mips64 || mips64le)
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 5003
|
SYS_CLOSE = 5003
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//go:build linux && (mips || mipsle)
|
//go:build linux && (mips || mipsle)
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 4006
|
SYS_CLOSE = 4006
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//go:build linux && (ppc64 || ppc64le)
|
//go:build linux && (ppc64 || ppc64le)
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 6
|
SYS_CLOSE = 6
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 57
|
SYS_CLOSE = 57
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SYS_CLOSE = 6
|
SYS_CLOSE = 6
|
||||||
|
|
@ -2,16 +2,15 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package syscall provides the syscall primitives required for the runtime.
|
// Package linux provides the syscall primitives required for the runtime.
|
||||||
package syscall
|
package linux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/goarch"
|
"internal/goarch"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(https://go.dev/issue/51087): This package is incomplete and currently
|
// TODO(https://go.dev/issue/51087): Move remaining syscalls to this package.
|
||||||
// only contains very minimal support for Linux.
|
|
||||||
|
|
||||||
// Syscall6 calls system call number 'num' with arguments a1-6.
|
// Syscall6 calls system call number 'num' with arguments a1-6.
|
||||||
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
|
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
|
||||||
|
|
@ -2,15 +2,15 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package syscall_test
|
package linux_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEpollctlErrorSign(t *testing.T) {
|
func TestEpollctlErrorSign(t *testing.T) {
|
||||||
v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{})
|
v := linux.EpollCtl(-1, 1, -1, &linux.EpollEvent{})
|
||||||
|
|
||||||
const EBADF = 0x09
|
const EBADF = 0x09
|
||||||
if v != EBADF {
|
if v != EBADF {
|
||||||
|
|
@ -8,7 +8,7 @@ package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/runtime/atomic"
|
"internal/runtime/atomic"
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -20,21 +20,21 @@ var (
|
||||||
|
|
||||||
func netpollinit() {
|
func netpollinit() {
|
||||||
var errno uintptr
|
var errno uintptr
|
||||||
epfd, errno = syscall.EpollCreate1(syscall.EPOLL_CLOEXEC)
|
epfd, errno = linux.EpollCreate1(linux.EPOLL_CLOEXEC)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
println("runtime: epollcreate failed with", errno)
|
println("runtime: epollcreate failed with", errno)
|
||||||
throw("runtime: netpollinit failed")
|
throw("runtime: netpollinit failed")
|
||||||
}
|
}
|
||||||
efd, errno := syscall.Eventfd(0, syscall.EFD_CLOEXEC|syscall.EFD_NONBLOCK)
|
efd, errno := linux.Eventfd(0, linux.EFD_CLOEXEC|linux.EFD_NONBLOCK)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
println("runtime: eventfd failed with", -errno)
|
println("runtime: eventfd failed with", -errno)
|
||||||
throw("runtime: eventfd failed")
|
throw("runtime: eventfd failed")
|
||||||
}
|
}
|
||||||
ev := syscall.EpollEvent{
|
ev := linux.EpollEvent{
|
||||||
Events: syscall.EPOLLIN,
|
Events: linux.EPOLLIN,
|
||||||
}
|
}
|
||||||
*(**uintptr)(unsafe.Pointer(&ev.Data)) = &netpollEventFd
|
*(**uintptr)(unsafe.Pointer(&ev.Data)) = &netpollEventFd
|
||||||
errno = syscall.EpollCtl(epfd, syscall.EPOLL_CTL_ADD, efd, &ev)
|
errno = linux.EpollCtl(epfd, linux.EPOLL_CTL_ADD, efd, &ev)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
println("runtime: epollctl failed with", errno)
|
println("runtime: epollctl failed with", errno)
|
||||||
throw("runtime: epollctl failed")
|
throw("runtime: epollctl failed")
|
||||||
|
|
@ -47,16 +47,16 @@ func netpollIsPollDescriptor(fd uintptr) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func netpollopen(fd uintptr, pd *pollDesc) uintptr {
|
func netpollopen(fd uintptr, pd *pollDesc) uintptr {
|
||||||
var ev syscall.EpollEvent
|
var ev linux.EpollEvent
|
||||||
ev.Events = syscall.EPOLLIN | syscall.EPOLLOUT | syscall.EPOLLRDHUP | syscall.EPOLLET
|
ev.Events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLRDHUP | linux.EPOLLET
|
||||||
tp := taggedPointerPack(unsafe.Pointer(pd), pd.fdseq.Load())
|
tp := taggedPointerPack(unsafe.Pointer(pd), pd.fdseq.Load())
|
||||||
*(*taggedPointer)(unsafe.Pointer(&ev.Data)) = tp
|
*(*taggedPointer)(unsafe.Pointer(&ev.Data)) = tp
|
||||||
return syscall.EpollCtl(epfd, syscall.EPOLL_CTL_ADD, int32(fd), &ev)
|
return linux.EpollCtl(epfd, linux.EPOLL_CTL_ADD, int32(fd), &ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
func netpollclose(fd uintptr) uintptr {
|
func netpollclose(fd uintptr) uintptr {
|
||||||
var ev syscall.EpollEvent
|
var ev linux.EpollEvent
|
||||||
return syscall.EpollCtl(epfd, syscall.EPOLL_CTL_DEL, int32(fd), &ev)
|
return linux.EpollCtl(epfd, linux.EPOLL_CTL_DEL, int32(fd), &ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
func netpollarm(pd *pollDesc, mode int) {
|
func netpollarm(pd *pollDesc, mode int) {
|
||||||
|
|
@ -114,9 +114,9 @@ func netpoll(delay int64) (gList, int32) {
|
||||||
// 1e9 ms == ~11.5 days.
|
// 1e9 ms == ~11.5 days.
|
||||||
waitms = 1e9
|
waitms = 1e9
|
||||||
}
|
}
|
||||||
var events [128]syscall.EpollEvent
|
var events [128]linux.EpollEvent
|
||||||
retry:
|
retry:
|
||||||
n, errno := syscall.EpollWait(epfd, events[:], int32(len(events)), waitms)
|
n, errno := linux.EpollWait(epfd, events[:], int32(len(events)), waitms)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
if errno != _EINTR {
|
if errno != _EINTR {
|
||||||
println("runtime: epollwait on fd", epfd, "failed with", errno)
|
println("runtime: epollwait on fd", epfd, "failed with", errno)
|
||||||
|
|
@ -138,7 +138,7 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
if *(**uintptr)(unsafe.Pointer(&ev.Data)) == &netpollEventFd {
|
if *(**uintptr)(unsafe.Pointer(&ev.Data)) == &netpollEventFd {
|
||||||
if ev.Events != syscall.EPOLLIN {
|
if ev.Events != linux.EPOLLIN {
|
||||||
println("runtime: netpoll: eventfd ready for", ev.Events)
|
println("runtime: netpoll: eventfd ready for", ev.Events)
|
||||||
throw("runtime: netpoll: eventfd ready for something unexpected")
|
throw("runtime: netpoll: eventfd ready for something unexpected")
|
||||||
}
|
}
|
||||||
|
|
@ -156,10 +156,10 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode int32
|
var mode int32
|
||||||
if ev.Events&(syscall.EPOLLIN|syscall.EPOLLRDHUP|syscall.EPOLLHUP|syscall.EPOLLERR) != 0 {
|
if ev.Events&(linux.EPOLLIN|linux.EPOLLRDHUP|linux.EPOLLHUP|linux.EPOLLERR) != 0 {
|
||||||
mode += 'r'
|
mode += 'r'
|
||||||
}
|
}
|
||||||
if ev.Events&(syscall.EPOLLOUT|syscall.EPOLLHUP|syscall.EPOLLERR) != 0 {
|
if ev.Events&(linux.EPOLLOUT|linux.EPOLLHUP|linux.EPOLLERR) != 0 {
|
||||||
mode += 'w'
|
mode += 'w'
|
||||||
}
|
}
|
||||||
if mode != 0 {
|
if mode != 0 {
|
||||||
|
|
@ -167,7 +167,7 @@ retry:
|
||||||
pd := (*pollDesc)(tp.pointer())
|
pd := (*pollDesc)(tp.pointer())
|
||||||
tag := tp.tag()
|
tag := tp.tag()
|
||||||
if pd.fdseq.Load() == tag {
|
if pd.fdseq.Load() == tag {
|
||||||
pd.setEventErr(ev.Events == syscall.EPOLLERR, tag)
|
pd.setEventErr(ev.Events == linux.EPOLLERR, tag)
|
||||||
delta += netpollready(&toRun, pd, mode)
|
delta += netpollready(&toRun, pd, mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"internal/goarch"
|
"internal/goarch"
|
||||||
"internal/runtime/atomic"
|
"internal/runtime/atomic"
|
||||||
"internal/runtime/strconv"
|
"internal/runtime/strconv"
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -470,7 +470,7 @@ func pipe2(flags int32) (r, w int32, errno int32)
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func fcntl(fd, cmd, arg int32) (ret int32, errno int32) {
|
func fcntl(fd, cmd, arg int32) (ret int32, errno int32) {
|
||||||
r, _, err := syscall.Syscall6(syscall.SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
|
r, _, err := linux.Syscall6(linux.SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
|
||||||
return int32(r), int32(err)
|
return int32(r), int32(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -773,7 +773,7 @@ func syscall_runtime_doAllThreadsSyscall(trap, a1, a2, a3, a4, a5, a6 uintptr) (
|
||||||
// ensuring all threads execute system calls from multiple calls in the
|
// ensuring all threads execute system calls from multiple calls in the
|
||||||
// same order.
|
// same order.
|
||||||
|
|
||||||
r1, r2, errno := syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
|
r1, r2, errno := linux.Syscall6(trap, a1, a2, a3, a4, a5, a6)
|
||||||
if GOARCH == "ppc64" || GOARCH == "ppc64le" {
|
if GOARCH == "ppc64" || GOARCH == "ppc64le" {
|
||||||
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
|
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
|
||||||
r2 = 0
|
r2 = 0
|
||||||
|
|
@ -884,7 +884,7 @@ func runPerThreadSyscall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
args := perThreadSyscall
|
args := perThreadSyscall
|
||||||
r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6)
|
r1, r2, errno := linux.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6)
|
||||||
if GOARCH == "ppc64" || GOARCH == "ppc64le" {
|
if GOARCH == "ppc64" || GOARCH == "ppc64le" {
|
||||||
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
|
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
|
||||||
r2 = 0
|
r2 = 0
|
||||||
|
|
@ -923,6 +923,6 @@ func (c *sigctxt) sigFromSeccomp() bool {
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func mprotect(addr unsafe.Pointer, n uintptr, prot int32) (ret int32, errno int32) {
|
func mprotect(addr unsafe.Pointer, n uintptr, prot int32) (ret int32, errno int32) {
|
||||||
r, _, err := syscall.Syscall6(syscall.SYS_MPROTECT, uintptr(addr), n, uintptr(prot), 0, 0, 0)
|
r, _, err := linux.Syscall6(linux.SYS_MPROTECT, uintptr(addr), n, uintptr(prot), 0, 0, 0)
|
||||||
return int32(r), int32(err)
|
return int32(r), int32(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -32,6 +32,6 @@ func internal_cpu_riscvHWProbe(pairs []riscvHWProbePairs, flags uint) bool {
|
||||||
}
|
}
|
||||||
// Passing in a cpuCount of 0 and a cpu of nil ensures that only extensions supported by all the
|
// Passing in a cpuCount of 0 and a cpu of nil ensures that only extensions supported by all the
|
||||||
// cores are returned, which is the behaviour we want in internal/cpu.
|
// cores are returned, which is the behaviour we want in internal/cpu.
|
||||||
_, _, e1 := syscall.Syscall6(sys_RISCV_HWPROBE, uintptr(unsafe.Pointer(&pairs[0])), uintptr(len(pairs)), uintptr(0), uintptr(unsafe.Pointer(nil)), uintptr(flags), 0)
|
_, _, e1 := linux.Syscall6(sys_RISCV_HWPROBE, uintptr(unsafe.Pointer(&pairs[0])), uintptr(len(pairs)), uintptr(0), uintptr(unsafe.Pointer(nil)), uintptr(flags), 0)
|
||||||
return e1 == 0
|
return e1 == 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/runtime/atomic"
|
"internal/runtime/atomic"
|
||||||
"internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ func setVMAName(start unsafe.Pointer, length uintptr, name string) {
|
||||||
n := copy(sysName[:], " Go: ")
|
n := copy(sysName[:], " Go: ")
|
||||||
copy(sysName[n:79], name) // leave final byte zero
|
copy(sysName[n:79], name) // leave final byte zero
|
||||||
|
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_PRCTL, syscall.PR_SET_VMA, syscall.PR_SET_VMA_ANON_NAME, uintptr(start), length, uintptr(unsafe.Pointer(&sysName[0])), 0)
|
_, _, err := linux.Syscall6(linux.SYS_PRCTL, linux.PR_SET_VMA, linux.PR_SET_VMA_ANON_NAME, uintptr(start), length, uintptr(unsafe.Pointer(&sysName[0])), 0)
|
||||||
if err == _EINVAL {
|
if err == _EINVAL {
|
||||||
prSetVMAUnsupported.Store(true)
|
prSetVMAUnsupported.Store(true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/itoa"
|
"internal/itoa"
|
||||||
runtimesyscall "internal/runtime/syscall"
|
"internal/runtime/syscall/linux"
|
||||||
"runtime"
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
@ -62,7 +62,7 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
|
||||||
//go:linkname RawSyscall6
|
//go:linkname RawSyscall6
|
||||||
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
|
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
|
||||||
var errno uintptr
|
var errno uintptr
|
||||||
r1, r2, errno = runtimesyscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
|
r1, r2, errno = linux.Syscall6(trap, a1, a2, a3, a4, a5, a6)
|
||||||
err = Errno(errno)
|
err = Errno(errno)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue