Skip to content
Snippets Groups Projects
Commit ed1cf6ab authored by Tobias Klauser's avatar Tobias Klauser Committed by Gopher Robot
Browse files

cmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on freebsd

The posix_fallocate system call is available since FreeBSD 9.0, see
https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate

Change-Id: Ie65e0a44341909707617d3b0d9a4f1710c45b935
Reviewed-on: https://go-review.googlesource.com/c/go/+/478035


TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: default avatarCherry Mui <cherryyz@google.com>
Reviewed-by: default avatarThan McIntosh <thanm@google.com>
parent bf9d9b7d
No related branches found
No related tags found
No related merge requests found
......@@ -68,10 +68,11 @@ var bootstrapDirs = []string{
"internal/goroot",
"internal/goversion",
"internal/pkgbits",
"internal/platform",
"internal/profile",
"internal/race",
"internal/saferio",
"internal/platform",
"internal/syscall/unix",
"internal/types/errors",
"internal/unsafeheader",
"internal/xcoff",
......
......@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || linux
// +build darwin linux
//go:build darwin || (freebsd && go1.21) || linux
package ld
......
// Copyright 2023 The Go Authors. All rights reserved.
// 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
package ld
import "internal/syscall/unix"
func (out *OutBuf) fallocate(size uint64) error {
return unix.PosixFallocate(int(out.f.Fd()), 0, int64(size))
}
......@@ -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 !darwin && !linux
//go:build !darwin && !(freebsd && go1.21) && !linux
package ld
......
......@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build !darwin
// +build !darwin
package ld
......
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package unix
import "syscall"
// FreeBSD posix_fallocate system call number.
const posixFallocateTrap uintptr = 530
func PosixFallocate(fd int, off int64, size int64) error {
_, _, errno := syscall.Syscall(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(size))
if errno != 0 {
return errno
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment