// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build darwin || (freebsd && go1.21) || linux
+//go:build darwin || (freebsd && go1.21) || linux || (netbsd && go1.25)
package ld
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build freebsd && go1.21
+//go:build (freebsd && go1.21) || (netbsd && go1.25)
package ld
// Some file systems do not support fallocate. We ignore that error as linking
// can still take place, but you might SIGBUS when you write to the mmapped
// area.
- if err != syscall.ENOTSUP && err != syscall.EPERM && err != errNoFallocate {
+ if err != syscall.ENOTSUP && err != syscall.EOPNOTSUPP && err != syscall.EPERM && err != errNoFallocate {
return err
}
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build !darwin && !(freebsd && go1.21) && !linux
+//go:build !darwin && !(freebsd && go1.21) && !linux && !(netbsd && go1.25)
package ld
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 (
// 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"
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)
// 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
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)
// 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"
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