mirror of
https://github.com/golang/go
synced 2024-11-17 08:14:48 -07:00
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>
This commit is contained in:
parent
bf9d9b7dba
commit
ed1cf6ab3e
3
src/cmd/dist/buildtool.go
vendored
3
src/cmd/dist/buildtool.go
vendored
@ -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
|
||||
|
||||
|
13
src/cmd/link/internal/ld/outbuf_freebsd.go
Normal file
13
src/cmd/link/internal/ld/outbuf_freebsd.go
Normal file
@ -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))
|
||||
}
|
@ -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
|
||||
|
||||
|
18
src/internal/syscall/unix/fallocate_freebsd.go
Normal file
18
src/internal/syscall/unix/fallocate_freebsd.go
Normal file
@ -0,0 +1,18 @@
|
||||
// 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user