diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2023-03-27 20:52:43 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-03-27 19:14:57 +0000 |
| commit | ed1cf6ab3ef94c603f9d883aa6806a5a82d2bee3 (patch) | |
| tree | 0d490702b1610c95ef64089a5427363fea820185 /src/cmd/link/internal | |
| parent | bf9d9b7dba25ecd2956f4f613ff83c1a3624a038 (diff) | |
| download | go-ed1cf6ab3ef94c603f9d883aa6806a5a82d2bee3.tar.xz | |
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: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/link/internal')
| -rw-r--r-- | src/cmd/link/internal/ld/fallocate_test.go | 3 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/outbuf_freebsd.go | 13 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/outbuf_nofallocate.go | 2 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/outbuf_notdarwin.go | 1 |
4 files changed, 15 insertions, 4 deletions
diff --git a/src/cmd/link/internal/ld/fallocate_test.go b/src/cmd/link/internal/ld/fallocate_test.go index 1ed0eb2ca7..ad77be536f 100644 --- a/src/cmd/link/internal/ld/fallocate_test.go +++ b/src/cmd/link/internal/ld/fallocate_test.go @@ -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 diff --git a/src/cmd/link/internal/ld/outbuf_freebsd.go b/src/cmd/link/internal/ld/outbuf_freebsd.go new file mode 100644 index 0000000000..5ff17300c1 --- /dev/null +++ b/src/cmd/link/internal/ld/outbuf_freebsd.go @@ -0,0 +1,13 @@ +// 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)) +} diff --git a/src/cmd/link/internal/ld/outbuf_nofallocate.go b/src/cmd/link/internal/ld/outbuf_nofallocate.go index dd5afc61db..435be5e09f 100644 --- a/src/cmd/link/internal/ld/outbuf_nofallocate.go +++ b/src/cmd/link/internal/ld/outbuf_nofallocate.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 !darwin && !linux +//go:build !darwin && !(freebsd && go1.21) && !linux package ld diff --git a/src/cmd/link/internal/ld/outbuf_notdarwin.go b/src/cmd/link/internal/ld/outbuf_notdarwin.go index f9caa413e3..3e5c67a5c2 100644 --- a/src/cmd/link/internal/ld/outbuf_notdarwin.go +++ b/src/cmd/link/internal/ld/outbuf_notdarwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !darwin -// +build !darwin package ld |
