]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: use libc based fcntl for (*OutBuf).fallocate on darwin
authorTobias Klauser <tklauser@distanz.ch>
Mon, 11 Oct 2021 07:32:52 +0000 (09:32 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Tue, 12 Oct 2021 06:55:50 +0000 (06:55 +0000)
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>
src/cmd/link/internal/ld/outbuf_darwin.go

index 9444b6567e8b723b03560154e1271f65ae3c4907..6920a0a843aea4303fd89ff9e93ec45708d4285c 100644 (file)
@@ -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() {