"internal/runtime/math",
"internal/runtime/strconv",
"internal/runtime/sys",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/abi",
"internal/bytealg",
"syscall",
"internal/bytealg",
"internal/chacha8rand",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/runtime/startlinetest",
}
< internal/msan
< internal/asan
< internal/runtime/sys
- < internal/runtime/syscall
+ < internal/runtime/syscall/linux
< internal/runtime/atomic
< internal/runtime/exithook
< internal/runtime/gc
// slot: 6 path='internal/runtime/math' hard-coded id: 6
// slot: 7 path='internal/bytealg' hard-coded id: 7
// 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
// fatal error: runtime.addCovMeta
//
"internal/runtime/strconv",
"internal/runtime/sys",
"internal/runtime/maps",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/runtime/cgroup",
"internal/stringslite",
"runtime",
import (
"internal/bytealg"
"internal/runtime/strconv"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
)
var (
func (c CPU) Close() {
switch c.version {
case V1:
- syscall.Close(c.quotaFD)
- syscall.Close(c.periodFD)
+ linux.Close(c.quotaFD)
+ linux.Close(c.periodFD)
case V2:
- syscall.Close(c.quotaFD)
+ linux.Close(c.quotaFD)
default:
throw("impossible cgroup version")
}
case 1:
n2 := copy(base[n:], v1QuotaFile)
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 {
// This may fail if this process was migrated out of
// the cgroup found by FindCPU and that cgroup has been
n2 = copy(base[n:], v1PeriodFile)
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 {
// This may fail if this process was migrated out of
// the cgroup found by FindCPU and that cgroup has been
case 2:
n2 := copy(base[n:], v2MaxFile)
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 {
// This may fail if this process was migrated out of
// the cgroup found by FindCPU and that cgroup has been
//
// Always read from the beginning of the file to get a fresh value.
var b [64]byte
- n, errno := syscall.Pread(fd, b[:], 0)
+ n, errno := linux.Pread(fd, b[:], 0)
if errno != 0 {
return 0, errSyscallFailed
}
//
// Always read from the beginning of the file to get a fresh value.
var b [64]byte
- n, errno := syscall.Pread(fd, b[:], 0)
+ n, errno := linux.Pread(fd, b[:], 0)
if errno != 0 {
return 0, false, errSyscallFailed
}
// Returns ErrNoCgroup if the process is not in a CPU cgroup.
func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) {
path := []byte("/proc/self/cgroup\x00")
- fd, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
- if errno == syscall.ENOENT {
+ fd, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
+ if errno == linux.ENOENT {
return 0, 0, ErrNoCgroup
} else if errno != 0 {
return 0, 0, errSyscallFailed
// The relative path always starts with /, so we can directly append it
// 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 {
- syscall.Close(fd)
+ linux.Close(fd)
return 0, 0, err
}
- syscall.Close(fd)
+ linux.Close(fd)
return n, version, nil
}
checkBufferSize(scratch, ParseSize)
path := []byte("/proc/self/mountinfo\x00")
- fd, errno := syscall.Open(&path[0], syscall.O_RDONLY|syscall.O_CLOEXEC, 0)
- if errno == syscall.ENOENT {
+ fd, errno := linux.Open(&path[0], linux.O_RDONLY|linux.O_CLOEXEC, 0)
+ if errno == linux.ENOENT {
return 0, ErrNoCgroup
} else if errno != 0 {
return 0, errSyscallFailed
}
- n, err := parseCPUMount(fd, syscall.Read, out, scratch)
+ n, err := parseCPUMount(fd, linux.Read, out, scratch)
if err != nil {
- syscall.Close(fd)
+ linux.Close(fd)
return 0, err
}
- syscall.Close(fd)
+ linux.Close(fd)
return n, nil
}
// remainder of the line skipped. See next for more details.
//
// 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.
func newLineReader(fd int, scratch []byte, read func(fd int, b []byte) (n int, errno uintptr)) *lineReader {
return &lineReader{
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
AT_FDCWD = -0x64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 6
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 3
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 6
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 57
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 57
//go:build linux && (mips64 || mips64le)
-package syscall
+package linux
const (
SYS_CLOSE = 5003
//go:build linux && (mips || mipsle)
-package syscall
+package linux
const (
SYS_CLOSE = 4006
//go:build linux && (ppc64 || ppc64le)
-package syscall
+package linux
const (
SYS_CLOSE = 6
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 57
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall
+package linux
const (
SYS_CLOSE = 6
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package syscall provides the syscall primitives required for the runtime.
-package syscall
+// Package linux provides the syscall primitives required for the runtime.
+package linux
import (
"internal/goarch"
"unsafe"
)
-// TODO(https://go.dev/issue/51087): This package is incomplete and currently
-// only contains very minimal support for Linux.
+// TODO(https://go.dev/issue/51087): Move remaining syscalls to this package.
// Syscall6 calls system call number 'num' with arguments a1-6.
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package syscall_test
+package linux_test
import (
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"testing"
)
func TestEpollctlErrorSign(t *testing.T) {
- v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{})
+ v := linux.EpollCtl(-1, 1, -1, &linux.EpollEvent{})
const EBADF = 0x09
if v != EBADF {
import (
"internal/runtime/atomic"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
func netpollinit() {
var errno uintptr
- epfd, errno = syscall.EpollCreate1(syscall.EPOLL_CLOEXEC)
+ epfd, errno = linux.EpollCreate1(linux.EPOLL_CLOEXEC)
if errno != 0 {
println("runtime: epollcreate failed with", errno)
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 {
println("runtime: eventfd failed with", -errno)
throw("runtime: eventfd failed")
}
- ev := syscall.EpollEvent{
- Events: syscall.EPOLLIN,
+ ev := linux.EpollEvent{
+ Events: linux.EPOLLIN,
}
*(**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 {
println("runtime: epollctl failed with", errno)
throw("runtime: epollctl failed")
}
func netpollopen(fd uintptr, pd *pollDesc) uintptr {
- var ev syscall.EpollEvent
- ev.Events = syscall.EPOLLIN | syscall.EPOLLOUT | syscall.EPOLLRDHUP | syscall.EPOLLET
+ var ev linux.EpollEvent
+ ev.Events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLRDHUP | linux.EPOLLET
tp := taggedPointerPack(unsafe.Pointer(pd), pd.fdseq.Load())
*(*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 {
- var ev syscall.EpollEvent
- return syscall.EpollCtl(epfd, syscall.EPOLL_CTL_DEL, int32(fd), &ev)
+ var ev linux.EpollEvent
+ return linux.EpollCtl(epfd, linux.EPOLL_CTL_DEL, int32(fd), &ev)
}
func netpollarm(pd *pollDesc, mode int) {
// 1e9 ms == ~11.5 days.
waitms = 1e9
}
- var events [128]syscall.EpollEvent
+ var events [128]linux.EpollEvent
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 != _EINTR {
println("runtime: epollwait on fd", epfd, "failed with", errno)
}
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)
throw("runtime: netpoll: eventfd ready for something unexpected")
}
}
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'
}
- if ev.Events&(syscall.EPOLLOUT|syscall.EPOLLHUP|syscall.EPOLLERR) != 0 {
+ if ev.Events&(linux.EPOLLOUT|linux.EPOLLHUP|linux.EPOLLERR) != 0 {
mode += 'w'
}
if mode != 0 {
pd := (*pollDesc)(tp.pointer())
tag := tp.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)
}
}
"internal/goarch"
"internal/runtime/atomic"
"internal/runtime/strconv"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
//go:nosplit
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)
}
// ensuring all threads execute system calls from multiple calls in the
// 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" {
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
r2 = 0
}
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" {
// TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2.
r2 = 0
//go:nosplit
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)
}
package runtime
import (
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
}
// 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.
- _, _, 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
}
import (
"internal/runtime/atomic"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
n := copy(sysName[:], " Go: ")
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 {
prSetVMAUnsupported.Store(true)
}
import (
"internal/itoa"
- runtimesyscall "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"runtime"
"slices"
"unsafe"
//go:linkname RawSyscall6
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
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)
return
}