Fix build of fallocate_darwin.go

This commit is contained in:
Kovid Goyal
2023-09-23 10:08:04 +05:30
parent 2e4f3dab41
commit 38bac98c12

View File

@@ -3,9 +3,12 @@
package shm package shm
import ( import (
"errors"
"fmt" "fmt"
"syscall" "syscall"
"unsafe" "unsafe"
"golang.org/x/sys/unix"
) )
var _ = fmt.Print var _ = fmt.Print
@@ -15,15 +18,12 @@ func Fallocate_simple(fd int, size int64) (err error) {
Flags: syscall.F_ALLOCATEALL, Flags: syscall.F_ALLOCATEALL,
Posmode: syscall.F_PEOFPOSMODE, Posmode: syscall.F_PEOFPOSMODE,
Offset: 0, Offset: 0,
Length: int64(size), Length: size,
} }
for { for {
if _, _, err = syscall.Syscall(syscall.SYS_FCNTL, uintptr(out.f.Fd()), syscall.F_PREALLOCATE, uintptr(unsafe.Pointer(store))); !errors.Is(err, unix.EINTR) { if _, _, err = syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_PREALLOCATE, uintptr(unsafe.Pointer(store))); !errors.Is(err, unix.EINTR) {
if err != 0 { return err
return err
}
return nil
} }
} }
} }