aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-07-21 10:39:28 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-07-24 13:30:14 -0700
commit5c45fe1385ff30b1a138dd3dae7fc670f85dfcc9 (patch)
tree8f988c5af1a6e3e7f25eeb8eb35252150a7f2f76 /src
parent592c2db868c7465ae06a447a861c313ba071f3e6 (diff)
downloadgo-5c45fe1385ff30b1a138dd3dae7fc670f85dfcc9.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/internal/objabi/pkgspecial.go4
-rw-r--r--src/go/build/deps_test.go2
-rw-r--r--src/internal/coverage/pkid.go4
-rw-r--r--src/internal/runtime/cgroup/cgroup_linux.go38
-rw-r--r--src/internal/runtime/cgroup/line_reader.go2
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_386.s (renamed from src/internal/runtime/syscall/asm_linux_386.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_amd64.s (renamed from src/internal/runtime/syscall/asm_linux_amd64.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_arm.s (renamed from src/internal/runtime/syscall/asm_linux_arm.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_arm64.s (renamed from src/internal/runtime/syscall/asm_linux_arm64.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_loong64.s (renamed from src/internal/runtime/syscall/asm_linux_loong64.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_mips64x.s (renamed from src/internal/runtime/syscall/asm_linux_mips64x.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_mipsx.s (renamed from src/internal/runtime/syscall/asm_linux_mipsx.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_ppc64x.s (renamed from src/internal/runtime/syscall/asm_linux_ppc64x.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_riscv64.s (renamed from src/internal/runtime/syscall/asm_linux_riscv64.s)0
-rw-r--r--src/internal/runtime/syscall/linux/asm_linux_s390x.s (renamed from src/internal/runtime/syscall/asm_linux_s390x.s)0
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux.go (renamed from src/internal/runtime/syscall/defs_linux.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_386.go (renamed from src/internal/runtime/syscall/defs_linux_386.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_amd64.go (renamed from src/internal/runtime/syscall/defs_linux_amd64.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_arm.go (renamed from src/internal/runtime/syscall/defs_linux_arm.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_arm64.go (renamed from src/internal/runtime/syscall/defs_linux_arm64.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_loong64.go (renamed from src/internal/runtime/syscall/defs_linux_loong64.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_mips64x.go (renamed from src/internal/runtime/syscall/defs_linux_mips64x.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_mipsx.go (renamed from src/internal/runtime/syscall/defs_linux_mipsx.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_ppc64x.go (renamed from src/internal/runtime/syscall/defs_linux_ppc64x.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_riscv64.go (renamed from src/internal/runtime/syscall/defs_linux_riscv64.go)2
-rw-r--r--src/internal/runtime/syscall/linux/defs_linux_s390x.go (renamed from src/internal/runtime/syscall/defs_linux_s390x.go)2
-rw-r--r--src/internal/runtime/syscall/linux/syscall_linux.go (renamed from src/internal/runtime/syscall/syscall_linux.go)7
-rw-r--r--src/internal/runtime/syscall/linux/syscall_linux_test.go (renamed from src/internal/runtime/syscall/syscall_linux_test.go)6
-rw-r--r--src/runtime/netpoll_epoll.go34
-rw-r--r--src/runtime/os_linux.go10
-rw-r--r--src/runtime/os_linux_riscv64.go4
-rw-r--r--src/runtime/set_vma_name_linux.go4
-rw-r--r--src/syscall/syscall_linux.go4
33 files changed, 70 insertions, 71 deletions
diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go
index e09aeadbc2..522337f583 100644
--- a/src/cmd/internal/objabi/pkgspecial.go
+++ b/src/cmd/internal/objabi/pkgspecial.go
@@ -56,7 +56,7 @@ var runtimePkgs = []string{
"internal/runtime/math",
"internal/runtime/strconv",
"internal/runtime/sys",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/abi",
"internal/bytealg",
@@ -94,7 +94,7 @@ var allowAsmABIPkgs = []string{
"syscall",
"internal/bytealg",
"internal/chacha8rand",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/runtime/startlinetest",
}
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index 6d92542e31..b3d8f66bc7 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -91,7 +91,7 @@ var depsRules = `
< internal/msan
< internal/asan
< internal/runtime/sys
- < internal/runtime/syscall
+ < internal/runtime/syscall/linux
< internal/runtime/atomic
< internal/runtime/exithook
< internal/runtime/gc
diff --git a/src/internal/coverage/pkid.go b/src/internal/coverage/pkid.go
index 30b5ad49ac..c9bcce2b6c 100644
--- a/src/internal/coverage/pkid.go
+++ b/src/internal/coverage/pkid.go
@@ -31,7 +31,7 @@ package coverage
// 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
//
@@ -66,7 +66,7 @@ var rtPkgs = [...]string{
"internal/runtime/strconv",
"internal/runtime/sys",
"internal/runtime/maps",
- "internal/runtime/syscall",
+ "internal/runtime/syscall/linux",
"internal/runtime/cgroup",
"internal/stringslite",
"runtime",
diff --git a/src/internal/runtime/cgroup/cgroup_linux.go b/src/internal/runtime/cgroup/cgroup_linux.go
index 2fc3b225c5..91815b4a1d 100644
--- a/src/internal/runtime/cgroup/cgroup_linux.go
+++ b/src/internal/runtime/cgroup/cgroup_linux.go
@@ -7,7 +7,7 @@ package cgroup
import (
"internal/bytealg"
"internal/runtime/strconv"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
)
var (
@@ -77,10 +77,10 @@ type CPU struct {
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")
}
@@ -112,7 +112,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
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
@@ -122,7 +122,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
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
@@ -139,7 +139,7 @@ func OpenCPU(scratch []byte) (CPU, error) {
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
@@ -200,7 +200,7 @@ func readV1Number(fd int) (int64, error) {
//
// 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
}
@@ -248,7 +248,7 @@ func readV2Limit(fd int) (float64, bool, error) {
//
// 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
}
@@ -345,8 +345,8 @@ func FindCPU(out []byte, scratch []byte) (int, Version, error) {
// 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
@@ -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
// 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
}
@@ -489,19 +489,19 @@ func FindCPUMountPoint(out []byte, scratch []byte) (int, error) {
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
}
diff --git a/src/internal/runtime/cgroup/line_reader.go b/src/internal/runtime/cgroup/line_reader.go
index 382cfd70d1..9a7213327c 100644
--- a/src/internal/runtime/cgroup/line_reader.go
+++ b/src/internal/runtime/cgroup/line_reader.go
@@ -55,7 +55,7 @@ type lineReader struct {
// 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{
diff --git a/src/internal/runtime/syscall/asm_linux_386.s b/src/internal/runtime/syscall/linux/asm_linux_386.s
index 15aae4d8bd..15aae4d8bd 100644
--- a/src/internal/runtime/syscall/asm_linux_386.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_386.s
diff --git a/src/internal/runtime/syscall/asm_linux_amd64.s b/src/internal/runtime/syscall/linux/asm_linux_amd64.s
index 3740ef1beb..3740ef1beb 100644
--- a/src/internal/runtime/syscall/asm_linux_amd64.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_amd64.s
diff --git a/src/internal/runtime/syscall/asm_linux_arm.s b/src/internal/runtime/syscall/linux/asm_linux_arm.s
index dbf1826d94..dbf1826d94 100644
--- a/src/internal/runtime/syscall/asm_linux_arm.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_arm.s
diff --git a/src/internal/runtime/syscall/asm_linux_arm64.s b/src/internal/runtime/syscall/linux/asm_linux_arm64.s
index 83e862ff72..83e862ff72 100644
--- a/src/internal/runtime/syscall/asm_linux_arm64.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_arm64.s
diff --git a/src/internal/runtime/syscall/asm_linux_loong64.s b/src/internal/runtime/syscall/linux/asm_linux_loong64.s
index ff8ad75b05..ff8ad75b05 100644
--- a/src/internal/runtime/syscall/asm_linux_loong64.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_loong64.s
diff --git a/src/internal/runtime/syscall/asm_linux_mips64x.s b/src/internal/runtime/syscall/linux/asm_linux_mips64x.s
index 6b7c524689..6b7c524689 100644
--- a/src/internal/runtime/syscall/asm_linux_mips64x.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_mips64x.s
diff --git a/src/internal/runtime/syscall/asm_linux_mipsx.s b/src/internal/runtime/syscall/linux/asm_linux_mipsx.s
index 561310f8a1..561310f8a1 100644
--- a/src/internal/runtime/syscall/asm_linux_mipsx.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_mipsx.s
diff --git a/src/internal/runtime/syscall/asm_linux_ppc64x.s b/src/internal/runtime/syscall/linux/asm_linux_ppc64x.s
index 3e985edea0..3e985edea0 100644
--- a/src/internal/runtime/syscall/asm_linux_ppc64x.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_ppc64x.s
diff --git a/src/internal/runtime/syscall/asm_linux_riscv64.s b/src/internal/runtime/syscall/linux/asm_linux_riscv64.s
index 15e50ec153..15e50ec153 100644
--- a/src/internal/runtime/syscall/asm_linux_riscv64.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_riscv64.s
diff --git a/src/internal/runtime/syscall/asm_linux_s390x.s b/src/internal/runtime/syscall/linux/asm_linux_s390x.s
index 1b27f29390..1b27f29390 100644
--- a/src/internal/runtime/syscall/asm_linux_s390x.s
+++ b/src/internal/runtime/syscall/linux/asm_linux_s390x.s
diff --git a/src/internal/runtime/syscall/defs_linux.go b/src/internal/runtime/syscall/linux/defs_linux.go
index 4c131e23cf..1ca3c35238 100644
--- a/src/internal/runtime/syscall/defs_linux.go
+++ b/src/internal/runtime/syscall/linux/defs_linux.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.
-package syscall
+package linux
const (
AT_FDCWD = -0x64
diff --git a/src/internal/runtime/syscall/defs_linux_386.go b/src/internal/runtime/syscall/linux/defs_linux_386.go
index 6f05fd7306..7fdf5d3f80 100644
--- a/src/internal/runtime/syscall/defs_linux_386.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_386.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.
-package syscall
+package linux
const (
SYS_CLOSE = 6
diff --git a/src/internal/runtime/syscall/defs_linux_amd64.go b/src/internal/runtime/syscall/linux/defs_linux_amd64.go
index 6c62818100..2c8676e6e9 100644
--- a/src/internal/runtime/syscall/defs_linux_amd64.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_amd64.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.
-package syscall
+package linux
const (
SYS_CLOSE = 3
diff --git a/src/internal/runtime/syscall/defs_linux_arm.go b/src/internal/runtime/syscall/linux/defs_linux_arm.go
index 2b6005a3da..a0b395d676 100644
--- a/src/internal/runtime/syscall/defs_linux_arm.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_arm.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.
-package syscall
+package linux
const (
SYS_CLOSE = 6
diff --git a/src/internal/runtime/syscall/defs_linux_arm64.go b/src/internal/runtime/syscall/linux/defs_linux_arm64.go
index 05922fbf7a..223dce0c5b 100644
--- a/src/internal/runtime/syscall/defs_linux_arm64.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_arm64.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.
-package syscall
+package linux
const (
SYS_CLOSE = 57
diff --git a/src/internal/runtime/syscall/defs_linux_loong64.go b/src/internal/runtime/syscall/linux/defs_linux_loong64.go
index 2501434ceb..8aa61c391d 100644
--- a/src/internal/runtime/syscall/defs_linux_loong64.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_loong64.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.
-package syscall
+package linux
const (
SYS_CLOSE = 57
diff --git a/src/internal/runtime/syscall/defs_linux_mips64x.go b/src/internal/runtime/syscall/linux/defs_linux_mips64x.go
index 92ba3f7398..84b760dc1b 100644
--- a/src/internal/runtime/syscall/defs_linux_mips64x.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_mips64x.go
@@ -4,7 +4,7 @@
//go:build linux && (mips64 || mips64le)
-package syscall
+package linux
const (
SYS_CLOSE = 5003
diff --git a/src/internal/runtime/syscall/defs_linux_mipsx.go b/src/internal/runtime/syscall/linux/defs_linux_mipsx.go
index 7b4dee08af..a9be21414c 100644
--- a/src/internal/runtime/syscall/defs_linux_mipsx.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_mipsx.go
@@ -4,7 +4,7 @@
//go:build linux && (mips || mipsle)
-package syscall
+package linux
const (
SYS_CLOSE = 4006
diff --git a/src/internal/runtime/syscall/defs_linux_ppc64x.go b/src/internal/runtime/syscall/linux/defs_linux_ppc64x.go
index 4656517628..63f4e5d786 100644
--- a/src/internal/runtime/syscall/defs_linux_ppc64x.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_ppc64x.go
@@ -4,7 +4,7 @@
//go:build linux && (ppc64 || ppc64le)
-package syscall
+package linux
const (
SYS_CLOSE = 6
diff --git a/src/internal/runtime/syscall/defs_linux_riscv64.go b/src/internal/runtime/syscall/linux/defs_linux_riscv64.go
index 2501434ceb..8aa61c391d 100644
--- a/src/internal/runtime/syscall/defs_linux_riscv64.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_riscv64.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.
-package syscall
+package linux
const (
SYS_CLOSE = 57
diff --git a/src/internal/runtime/syscall/defs_linux_s390x.go b/src/internal/runtime/syscall/linux/defs_linux_s390x.go
index 8005890e45..52945db0e5 100644
--- a/src/internal/runtime/syscall/defs_linux_s390x.go
+++ b/src/internal/runtime/syscall/linux/defs_linux_s390x.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.
-package syscall
+package linux
const (
SYS_CLOSE = 6
diff --git a/src/internal/runtime/syscall/syscall_linux.go b/src/internal/runtime/syscall/linux/syscall_linux.go
index 49e5f8de2c..8201e7d190 100644
--- a/src/internal/runtime/syscall/syscall_linux.go
+++ b/src/internal/runtime/syscall/linux/syscall_linux.go
@@ -2,16 +2,15 @@
// 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)
diff --git a/src/internal/runtime/syscall/syscall_linux_test.go b/src/internal/runtime/syscall/linux/syscall_linux_test.go
index 14bb31c4b8..10eb2d56bf 100644
--- a/src/internal/runtime/syscall/syscall_linux_test.go
+++ b/src/internal/runtime/syscall/linux/syscall_linux_test.go
@@ -2,15 +2,15 @@
// 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 {
diff --git a/src/runtime/netpoll_epoll.go b/src/runtime/netpoll_epoll.go
index c43bab0882..48c03d119f 100644
--- a/src/runtime/netpoll_epoll.go
+++ b/src/runtime/netpoll_epoll.go
@@ -8,7 +8,7 @@ package runtime
import (
"internal/runtime/atomic"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
@@ -20,21 +20,21 @@ var (
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")
@@ -47,16 +47,16 @@ func netpollIsPollDescriptor(fd uintptr) bool {
}
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) {
@@ -114,9 +114,9 @@ func netpoll(delay int64) (gList, int32) {
// 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)
@@ -138,7 +138,7 @@ retry:
}
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")
}
@@ -156,10 +156,10 @@ retry:
}
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 {
@@ -167,7 +167,7 @@ retry:
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)
}
}
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index fd560ddf5a..0ec5e43007 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -9,7 +9,7 @@ import (
"internal/goarch"
"internal/runtime/atomic"
"internal/runtime/strconv"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
@@ -470,7 +470,7 @@ func pipe2(flags int32) (r, w int32, errno int32)
//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)
}
@@ -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
// 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
@@ -884,7 +884,7 @@ func runPerThreadSyscall() {
}
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
@@ -923,6 +923,6 @@ func (c *sigctxt) sigFromSeccomp() bool {
//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)
}
diff --git a/src/runtime/os_linux_riscv64.go b/src/runtime/os_linux_riscv64.go
index c4a4d4e50d..65fa601a29 100644
--- a/src/runtime/os_linux_riscv64.go
+++ b/src/runtime/os_linux_riscv64.go
@@ -5,7 +5,7 @@
package runtime
import (
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"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
// 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
}
diff --git a/src/runtime/set_vma_name_linux.go b/src/runtime/set_vma_name_linux.go
index 100c2bfeca..9b6654f332 100644
--- a/src/runtime/set_vma_name_linux.go
+++ b/src/runtime/set_vma_name_linux.go
@@ -8,7 +8,7 @@ package runtime
import (
"internal/runtime/atomic"
- "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"unsafe"
)
@@ -24,7 +24,7 @@ func setVMAName(start unsafe.Pointer, length uintptr, name string) {
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)
}
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
index d733ca9bf9..ec9f771daa 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
@@ -13,7 +13,7 @@ package syscall
import (
"internal/itoa"
- runtimesyscall "internal/runtime/syscall"
+ "internal/runtime/syscall/linux"
"runtime"
"slices"
"unsafe"
@@ -62,7 +62,7 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
//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
}