From: Tobias Klauser Date: Mon, 11 Oct 2021 07:32:52 +0000 (+0200) Subject: cmd/link/internal/ld: use libc based fcntl for (*OutBuf).fallocate on darwin X-Git-Tag: go1.18beta1~940 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d887d3be5f8f143f2475ddb2ea6c48ceb32def17;p=gostls13.git 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 Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui --- 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() {