aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2021-10-11 09:32:52 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2021-10-12 06:55:50 +0000
commitd887d3be5f8f143f2475ddb2ea6c48ceb32def17 (patch)
tree66f9d5dac3be8072b8fa75dd5e1fcdfda00059a6 /src/cmd/link
parent6372e7efbab5a613b73271938acbd1c6f558814e (diff)
downloadgo-d887d3be5f8f143f2475ddb2ea6c48ceb32def17.tar.gz
go-d887d3be5f8f143f2475ddb2ea6c48ceb32def17.zip
cmd/link/internal/ld: use libc based fcntl for (*OutBuf).fallocate on darwin
Direct syscalls are no longer supported on darwin. Instead, use libc fcntl go:linkname'd from the syscall package. Change-Id: Ieeec64810452455faedd200f661a8b5839ca1fa0 Reviewed-on: https://go-review.googlesource.com/c/go/+/255260 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/link')
-rw-r--r--src/cmd/link/internal/ld/outbuf_darwin.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/link/internal/ld/outbuf_darwin.go b/src/cmd/link/internal/ld/outbuf_darwin.go
index 9444b6567e..6920a0a843 100644
--- a/src/cmd/link/internal/ld/outbuf_darwin.go
+++ b/src/cmd/link/internal/ld/outbuf_darwin.go
@@ -9,6 +9,10 @@ import (
"unsafe"
)
+// Implemented in the syscall package.
+//go:linkname fcntl syscall.fcntl
+func fcntl(fd int, cmd int, arg int) (int, error)
+
func (out *OutBuf) fallocate(size uint64) error {
stat, err := out.f.Stat()
if err != nil {
@@ -29,12 +33,8 @@ func (out *OutBuf) fallocate(size uint64) error {
Length: int64(size - cursize),
}
- _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(out.f.Fd()), syscall.F_PREALLOCATE, uintptr(unsafe.Pointer(store)))
- if errno != 0 {
- return errno
- }
-
- return nil
+ _, err = fcntl(int(out.f.Fd()), syscall.F_PREALLOCATE, int(uintptr(unsafe.Pointer(store))))
+ return err
}
func (out *OutBuf) purgeSignatureCache() {