diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2025-08-06 17:50:14 +0200 |
|---|---|---|
| committer | Tobias Klauser <tklauser@distanz.ch> | 2025-08-11 15:25:38 -0700 |
| commit | ce3f3e2ae73dcc0c270bc73a59ea5e7be6cf6a8d (patch) | |
| tree | d2150a07215ad3569c725b23b4dca3df54be524e /src/internal/syscall | |
| parent | 3dbef65bf37f1b7ccd1f884761341a5a15456ffa (diff) | |
| download | go-ce3f3e2ae73dcc0c270bc73a59ea5e7be6cf6a8d.tar.xz | |
cmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on netbsd
The posix_fallocate system call is available since NetBSD 7.0, see
https://man.netbsd.org/posix_fallocate.2
Re-use the syscall wrappers already in place for freebsd. Note that
posix_fallocate on netbsd also returns the result in r1 rather than in
errno:
> If successful, posix_fallocate() returns zero. It returns an error on failure, without
> setting errno.
Source: https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES
Cq-Include-Trybots: luci.golang.try:gotip-netbsd-arm64
Change-Id: Iaa1f6a805d511645da7f1d2737235bfd42da3407
Reviewed-on: https://go-review.googlesource.com/c/go/+/480475
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/syscall')
| -rw-r--r-- | src/internal/syscall/unix/at_sysnum_netbsd.go | 21 | ||||
| -rw-r--r-- | src/internal/syscall/unix/fallocate_bsd_386.go (renamed from src/internal/syscall/unix/fallocate_freebsd_386.go) | 3 | ||||
| -rw-r--r-- | src/internal/syscall/unix/fallocate_bsd_64bit.go (renamed from src/internal/syscall/unix/fallocate_freebsd_64bit.go) | 3 | ||||
| -rw-r--r-- | src/internal/syscall/unix/fallocate_bsd_arm.go (renamed from src/internal/syscall/unix/fallocate_freebsd_arm.go) | 3 |
4 files changed, 19 insertions, 11 deletions
diff --git a/src/internal/syscall/unix/at_sysnum_netbsd.go b/src/internal/syscall/unix/at_sysnum_netbsd.go index b59b5e0cf9..db17852b74 100644 --- a/src/internal/syscall/unix/at_sysnum_netbsd.go +++ b/src/internal/syscall/unix/at_sysnum_netbsd.go @@ -7,16 +7,17 @@ package unix import "syscall" const ( - unlinkatTrap uintptr = syscall.SYS_UNLINKAT - openatTrap uintptr = syscall.SYS_OPENAT - fstatatTrap uintptr = syscall.SYS_FSTATAT - readlinkatTrap uintptr = syscall.SYS_READLINKAT - mkdiratTrap uintptr = syscall.SYS_MKDIRAT - fchmodatTrap uintptr = syscall.SYS_FCHMODAT - fchownatTrap uintptr = syscall.SYS_FCHOWNAT - renameatTrap uintptr = syscall.SYS_RENAMEAT - linkatTrap uintptr = syscall.SYS_LINKAT - symlinkatTrap uintptr = syscall.SYS_SYMLINKAT + unlinkatTrap uintptr = syscall.SYS_UNLINKAT + openatTrap uintptr = syscall.SYS_OPENAT + fstatatTrap uintptr = syscall.SYS_FSTATAT + readlinkatTrap uintptr = syscall.SYS_READLINKAT + mkdiratTrap uintptr = syscall.SYS_MKDIRAT + fchmodatTrap uintptr = syscall.SYS_FCHMODAT + fchownatTrap uintptr = syscall.SYS_FCHOWNAT + renameatTrap uintptr = syscall.SYS_RENAMEAT + linkatTrap uintptr = syscall.SYS_LINKAT + symlinkatTrap uintptr = syscall.SYS_SYMLINKAT + posixFallocateTrap uintptr = 479 ) const ( diff --git a/src/internal/syscall/unix/fallocate_freebsd_386.go b/src/internal/syscall/unix/fallocate_bsd_386.go index 535b23dbc5..1dcdff4a53 100644 --- a/src/internal/syscall/unix/fallocate_freebsd_386.go +++ b/src/internal/syscall/unix/fallocate_bsd_386.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 (freebsd || netbsd) && 386 + package unix import "syscall" @@ -9,6 +11,7 @@ import "syscall" func PosixFallocate(fd int, off int64, size int64) error { // If successful, posix_fallocate() returns zero. It returns an error on failure, without // setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 + // and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES r1, _, _ := syscall.Syscall6(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(size), uintptr(size>>32), 0) if r1 != 0 { return syscall.Errno(r1) diff --git a/src/internal/syscall/unix/fallocate_freebsd_64bit.go b/src/internal/syscall/unix/fallocate_bsd_64bit.go index a9d52283f0..177bb48382 100644 --- a/src/internal/syscall/unix/fallocate_freebsd_64bit.go +++ b/src/internal/syscall/unix/fallocate_bsd_64bit.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 freebsd && (amd64 || arm64 || riscv64) +//go:build (freebsd || netbsd) && (amd64 || arm64 || riscv64) package unix @@ -11,6 +11,7 @@ import "syscall" func PosixFallocate(fd int, off int64, size int64) error { // If successful, posix_fallocate() returns zero. It returns an error on failure, without // setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 + // and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES r1, _, _ := syscall.Syscall(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(size)) if r1 != 0 { return syscall.Errno(r1) diff --git a/src/internal/syscall/unix/fallocate_freebsd_arm.go b/src/internal/syscall/unix/fallocate_bsd_arm.go index 1ded50f3b9..15e99d02b1 100644 --- a/src/internal/syscall/unix/fallocate_freebsd_arm.go +++ b/src/internal/syscall/unix/fallocate_bsd_arm.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 (freebsd || netbsd) && arm + package unix import "syscall" @@ -9,6 +11,7 @@ import "syscall" func PosixFallocate(fd int, off int64, size int64) error { // If successful, posix_fallocate() returns zero. It returns an error on failure, without // setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 + // and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES // // The padding 0 argument is needed because the ARM calling convention requires that if an // argument (off in this case) needs double-word alignment (8-byte), the NCRN (next core |
